0
我想在彈出的對話框中彈出一個表格行,但它不起作用(primefaces組件p:dataTable和p:dialog )它看起來像selectioMode不能正常工作。這是爲什麼發生?爲什麼這個對話框不會彈出?(JSF2.0 + PRIMEFACES)
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 =「單」):
不,我不能這樣做,我的團隊的設計師希望它在點擊行時工作,他們說這種方式更加用戶友好。 我只是在列內試過這個 ,但是當我點擊瀏覽器時顯示這個: -213543501213498845:-6468415484 {「validationFailed」:false}那是什麼? –
sfrj
2011-03-31 08:51:27
然後查看http://www.primefaces.org/showcase/ui/datatableRowSelectionInstant.jsf – 2011-04-02 14:41:14