【发布时间】:2011-07-26 16:40:24
【问题描述】:
我想在单击表格行时弹出一个对话框,但它不起作用。(primefaces 组件 p:dataTable 和 p:dialog)而且看起来 selectioMode 无法正常工作。为什么会这样?
JSF 页面:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:t="http://myfaces.apache.org/tomahawk"
xmlns:p="http://primefaces.prime.com.tr/ui">
<ui:composition template="WEB-INF/templates/BasicTemplate.xhtml">
<ui:define name="resultsForm2">
<h:form enctype="multipart/form-data">
<p:dataTable var="garbage" value="#{resultsController.allGarbage}" dynamic="true" paginator="true" paginatorPosition="bottom" rows="10"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15" selection="#{resultsController.selectedGarbage}" selectionMode="single"
onRowSelectStart="fileDialog.show()">
<p:column>
<h:outputText value="#{garbage.filename}"/>
</p:column>
</p:dataTable>
</h:form>
<p:dialog widgetVar="fileDialog">
<h:outputText value="Dialog open"/>
</p:dialog>
</ui:define>
</ui:composition>
</html>
这里是托管 bean:
@ManagedBean
@ViewScoped
public class ResultsController implements Serializable{
@EJB
private ISearchEJB searchEJB;
private Garbage garbage;
private List<Garbage> allGarbage;
private Garbage selectedGarbage;
public List<Garbage> getAllGarbage() {
allGarbage = new ArrayList<Garbage>();
for(Garbage g :searchEJB.findAllGarbage()) {
allGarbage.add(g);
}
return allGarbage;
}
public void setAllGarbage(List<Garbage> allGarbage) {
this.allGarbage = allGarbage;
}
public Garbage getGarbage() {
return garbage;
}
public void setGarbage(Garbage garbage) {
this.garbage = garbage;
}
public void onRowSelect(SelectEvent event){
garbage = (Garbage)event.getObject();
}
public Garbage getSelectedGarbage() {
return selectedGarbage;
}
public void setSelectedGarbage(Garbage selectedGarbage) {
this.selectedGarbage = selectedGarbage;
}
还请注意,在输出中我可以看到值,但是当我单击一行时,它会变成彩色但没有弹出对话框(另外我看起来我可以单击多行,这不应该像因为我使用 selectionMode="single"):
【问题讨论】:
标签: java jsf jakarta-ee jsf-2 primefaces