【问题标题】:simple primefaces dialog does not affect value to property简单的 primefaces 对话框不会影响属性的值
【发布时间】:2015-03-05 21:04:09
【问题描述】:

我在 primefaces 对话框中有一个简单的输入文本,带有一个命令按钮来测试变量是否获得他的值,但是当我单击命令按钮时(process="@this" 当我删除它时,按钮不再工作)打印属性的值,它始终显示为空...对话框由数据网格中的命令链接租用,当我删除对话框时,一切正常,属性获取值,这是 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());
    }

【问题讨论】:

  • 我认为您必须回到一些基础知识并从开发人员的角度进行描述,例如如果删除了process 属性,则按钮不起作用。这可能有很多原因not work

标签: jsf primefaces datagrid


【解决方案1】:

解决方案是将 p:dialog 的内容放在&lt;h:form&gt;&lt;/h:form&gt; 之间并添加到对话框appendToBody="false"

【讨论】:

  • 是其中之一。两者都不需要
猜你喜欢
  • 1970-01-01
  • 2012-06-15
  • 1970-01-01
  • 2013-11-22
  • 1970-01-01
  • 2012-09-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多