“简单素数”对话框不会影响属性的值



我在带有命令按钮的 primefaces 对话框中有一个简单的输入文本来测试变量是否获得他的值,但是当我单击命令按钮时(process="@this"当我删除它时,按钮不再起作用)打印它显示的属性的值总是 null ...该对话框由数据网格中的命令链接租用,当我删除对话框时,一切正常,属性获取值,这是JSF页面:

<p:layoutUnit id="center" position="center"
                style="min-height:400px;min-width:300px;overflow-y:hidden !important"
                header="#{messages['layout.center.header']}">
 <f:view>
<h:form >
                    <p:dataGrid var="c" value="#{rentMB.carsList}" columns="3"
                        layout="grid" rows="12" paginator="true" id="cars"
                        paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                        rowsPerPageTemplate="6,12,16">
                        <f:facet name="header">
                 Available Cars 
                 </f:facet>
                        <p:panel header="#{c.car_brand.brand_name}"
                            style="text-align:center">
                            <h:panelGrid columns="1" style="width:100%">
                                <p:graphicImage url="/images/#{c.image}.jpg" />
                                <p:commandLink 
                                    oncomplete="PF('carDialog').show()" title="View Detail">
                                    <h:outputText styleClass="ui-icon ui-icon-key"
                                        style="margin:0 auto;" />
                                    <f:setPropertyActionListener value="#{c}"
                                        target="#{rentMB.selectedCar}"  />
                                </p:commandLink>
                            </h:panelGrid>
                        </p:panel>
                    </p:dataGrid>
</h:form>

 <h:form>
                    <p:dialog header="Car Info" id="carInfo" widgetVar="carDialog" width="900px"
                        height="400px" showEffect="fade" hideEffect="fade"
                        resizable="false" appendToBody="true">
              <p:outputPanel>                       
<h:panelGrid columns="3" >
                                    <f:facet name="header">
        Client informations
                      </f:facet>

                                 <h:outputLabel for="adress" value="Adress : *" />
                                    <p:inputText id="adress" value="#{rentMB.adress}"
                                        />
                                        <p:watermark for="adress" value="Adress" />
                                    <p:commandButton action="#{rentMB.affiche}"   process="@this" value="Rent" oncomplete="carInfo.hide();" >  </p:commandButton>
                                    <p:commandButton type="reset" value="Reset">  </p:commandButton>
                            </h:panelGrid>
                            </p:outputPanel> 
                        </p:dialog>
                </h:form>
                </f:view>
            </p:layoutUnit>
        </p:layout>
    </h:body>
</f:view>
</html>

rentMB.affiche() 的代码:

public void affiche()
    {
        System.out.println(this.getAdress());
    }

解决方案是将 p:dialog 的内容放在 <h:form></h:form> 和 add to dialog appendToBody="false"

最新更新