[英]Why this dialog doesn't pop up?(JSF2.0+PRIMEFACES)
I want to make a dialog pop up when i click on a table row, but it doesnt work.(primefaces components p:dataTable and p:dialog) Also it looks like the selectioMode doesnt work correctly. 当我单击表格行时,我想弹出一个对话框,但它不起作用。(primefaces组件p:dataTable和p:dialog)而且看起来selectioMode无法正常工作。 Why is this happening?
为什么会这样呢?
The JSF page: 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>
Here the managed bean: 这里是托管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;
}
Also notice that in the output i can see the values but when i click on a row it gets colored but no dialog pops up(Also i looks like i can click on more than one row, that is not supposed to be like that since i use selectionMode="single"): 还要注意,在输出中我可以看到值,但是当我单击一行时它会变色但没有弹出对话框(而且我看起来我可以单击多个行,所以我不应该那样做)使用selectionMode =“ single”):
Did you have a look at this? 你看这个了吗?
http://www.primefaces.org/showcase/ui/datatableRowSelectionSingle.jsf http://www.primefaces.org/showcase/ui/datatableRowSelectionSingle.jsf
You can use a button in the footer of the dataTable for dispatching an Action. 您可以使用dataTable页脚中的按钮来分派Action。 You have to set the dialog to visible by processing the Action.
您必须通过处理操作将对话框设置为可见。
Hope this helps a bit. 希望这个对你有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.