JSF2.0 primefaces

时间:2013-05-22 22:42:27

标签: jsf-2 primefaces

我需要你对JSF2的帮助。我创建了一个数据表来列出数据库中的数据项。我想从该列表中选择一个项目,然后在编辑对话框中打印它。问题是项目的数据没有显示在该对话框中。这是用于生成它的JSF代码:

<p:dataTable value="#{airportController.items}" var="item" style="border: 0px;">
    <f:facet name="header">Airports</f:facet>
    <p:column>
        <f:facet name="header">ID</f:facet>
        <h:outputText value="#{item.airportId}"/>
    </p:column>

    <p:column>
        <f:facet name="header"></f:facet>
        <p:commandButton title="View" value="" update=":airportForm:airportEditForm" icon="edit_icon.gif"oncomplete="editAirportDlg.show();">
            <f:setPropertyActionListener value="#{item}" target="#{airportController.selected}"/>
        </p:commandButton>
    </p:column>
    <p:commandButton value="Ajouter" onclick="createAirportDgl.show();"/>    
</p:dataTable>

<p:dialog id="airportEditForm" widgetVar="editAirportDlg" modal="false"  header="Modifier" rendered="true" resizable="false">
    <h:panelGrid id="airportDisplay" columns="2" paginator="true" rows="10" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"   rowsPerPageTemplate="5,10,15">
        <h:outputText value="Pays"/>
        <p:inputText value="#{airportController.selected.country}"/>
        <h:outputText value="Ville"/>
        <p:inputText value="#{airportController.selected.city}"/>
        <h:outputText value="Nom"/>
        <p:inputText value="#{airportController.selected.name}"/>
        <h:outputText value="Addresse"/>
        <p:inputText value="#{airportController.selected.hqAddress}"/>
        <p:commandButton value="Valider" action="#{airportController.update()}"/>
    </h:panelGrid>
</p:dialog>

所有这些都放在index.xhtml页面中。 我不知道我做错了什么。

3 个答案:

答案 0 :(得分:0)

你能发送整个xhtml内容吗?这可能是一个验证问题。尝试在commandButton上使用process =“@ this”并改为更改airportDisplay。

<p:commandButton title="View" value=""
    update=":airportForm:airportDisplay"
    icon="edit_icon.gif"oncomplete="editAirportDlg.show();" process="@this">
    <f:setPropertyActionListener value="#{item}" target="#{airportController.selected}"/> 
</p:commandButton>

答案 1 :(得分:0)

尝试将datatabledialog内的所有内容h:form放入:form:airportDisplay,然后

在编辑按钮上单击更新关于网格ID的对话框,如<h:form id="form"> <p:growl id="growl" showDetail="true" life="3000"/> <p:dataTable value="#{airportController.items}" var="item" style="border: 0px;"> <f:facet name="header">Airports</f:facet> <p:column> <f:facet name="header">ID</f:facet> <h:outputText value="#{item.airportId}"/> </p:column> <p:column> <f:facet name="header"></f:facet> <p:commandButton title="View" value="" update=":form:airportDisplay" icon="edit_icon.gif"oncomplete="editAirportDlg.show();"> <f:setPropertyActionListener value="#{item}" target="#{airportController.selected}"/> </p:commandButton> </p:column> <p:commandButton value="Ajouter" onclick="createAirportDgl.show();"/> </p:dataTable> <p:dialog id="airportEditForm" widgetVar="editAirportDlg" modal="false" header="Modifier" rendered="true" resizable="false"> <h:panelGrid id="airportDisplay" columns="2" paginator="true" rows="10" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10,15"> <h:outputText value="Pays"/> <p:inputText value="#{airportController.selected.country}"/> <h:outputText value="Ville"/> <p:inputText value="#{airportController.selected.city}"/> <h:outputText value="Nom"/> <p:inputText value="#{airportController.selected.name}"/> <h:outputText value="Addresse"/> <p:inputText value="#{airportController.selected.hqAddress}"/> <p:commandButton value="Valider" action="#{airportController.update()}"/> </h:panelGrid> </p:dialog> </h:form> ,如下所示。

{{1}}

答案 2 :(得分:0)

感谢您的帮助,这是页面内容,

<强>的index.xhtml

  

  

<ui:define name="title">
    Airports
</ui:define>

<ui:define name="header">
    header
</ui:define>

<ui:define name="menu">
    menu
</ui:define>

<ui:define name="content">
    <h:form id="airportForm">
        <ui:include src="list.xhtml"/>
        <ui:include src="edit.xhtml"/>
        <ui:include src="create.xhtml"/>
    </h:form>
</ui:define> </ui:composition>

<强> list.xhtml

  

  

<p:dataTable value="#{airportController.items}" var="item" style="border: 0px;" >paginator="true"
             rowKey="#{item.airportId}" selection="#{airportController.selected}" >selectionMode="single"
     

sortBy = “#{item.airportId}” &GT;           机场                          ID                                                        喃                                                        支付                                                    威乐                                                    Addesse                                                    的onclick = “editAirportDlg.show();”/&GT;                     

    

更新= “:airportForm:airportCreateForm”     的onclick = “createAirportDgl.show();”/&GT;                      

  
     

<强> edit.xhtml

  

  

<p:dialog widgetVar="editAirportDlg" modal="false" 
          header="Modifier" rendered="true" resizable="false">
    <h:form id="airportEditForm">
    <h:panelGrid columns="2">
        <h:outputText value="Pays :"/>
        <p:inputText value="#{airportController.selected.country}"/>
        <h:outputText value="Ville: "/>
        <p:inputText value="#{airportController.selected.city}"/>
        <h:outputText value="Nom: "/>
        <p:inputText value="#{airportController.selected.name}"/>
        <h:outputText value="Addresse: "/>
        <p:inputText value="#{airportController.selected.hqAddress}"/>
        <f:facet name="footer">
            <p:commandButton value="Valider" icon="ui-icon-disk" action=" {airportController.update()}"/>
        </f:facet>
    </h:panelGrid>
    </h:form>
</p:dialog> </ui:composition>