jsf required = true销毁setPropertyActionListener吗? [英] jsf required=true destroys setPropertyActionListener?

查看:49
本文介绍了jsf required = true销毁setPropertyActionListener吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用primefaces 4.0和jsf 2.2.5

Using primefaces 4.0 and jsf 2.2.5

stmt.xhtml具有2个包含.IncludeDetail.xhtml和IncludeDuo.xhtml.IncludeDuo还包括IncludeDetail.

stmt.xhtml has 2 includes. IncludeDetail.xhtml and IncludeDuo.xhtml. IncludeDuo also includes IncludeDetail.

IncludeDetail.xhtml 中,< ui:composition> 元素不具有< form> id -属性或任何其他特殊元素.仅< h:panelGrid> < h:selectOneMenu> < h:selectOneMenu> .没什么特别的.

In IncludeDetail.xhtml the <ui:composition> Element owns no <form>, id-Attribute or any other special elements. Only <h:panelGrid>, <h:selectOneMenu> and <h:selectOneMenu>. Nothing special.

IncludeDuo.xhtml 拥有< p:layout> < p:message> 作为<ui:composition> .在< p:layout> 的更深层次中,我们找到了这段代码:

IncludeDuo.xhtml owns <p:layout> and <p:message> as child elements of <ui:composition>. Deeper inside the <p:layout> we find this piece of code:

<h:panelGrid columns="1" style="padding-left: 10px">
   <h:outputText value="AS" />
      <h:selectManyMenu value="#{regelBean.selectedASForNewElement}" required="true" style="height:115px">
         <f:selectItems value="#{aSBean.elementList}" var="var" itemLabel="#{var.vaSl}"
                    itemValue="#{var.vaSl}" />
   </h:selectManyMenu>
</h:panelGrid>

如果我删除 required ="true" ,一切都会按预期进行.如果我把它留在那里,下面的setPropertyActionListener将不再起作用:

If I remove required="true" everything works as expected. If I leave it there, the following setPropertyActionListener won't do it's job anymore:

<h:form id="form1">
        <p:dialog header="Neue Regel" widgetVar="newDuoDialog" resizable="false" id="newDuoDlg" showEffect="fade"
            hideEffect="fade" modal="true" styleClass="newDialog" width="1220">
            <ui:insert name="insertDuo">
                <ui:include src="/includes/duoRegelStmt.xhtml" />
            </ui:insert>
        </p:dialog>
        <p:growl id="msgs" showDetail="true" life="20000"/>
        <div class="nvg-dataTable">
            <p:dataTable id="dt1" var="tVar" value="#{stmtBean.elementList}"
                scrollable="false" styleClass="nvg-mainTable" paginator="true"
                paginatorAlwaysVisible="false" rows="10"
                rowsPerPageTemplate="10,25,100" paginatorPosition="bottom"
                currentPageReportTemplate="({startRecord}-{endRecord} von {totalRecords})"
                emptyMessage="Keine Statements gefunden" filteredValue="#{stmtBean.filteredElements}">

                <p:column styleClass="padding2" style="width:6%">
                    <p:commandButton value="?" update=":dlgForm"
                        oncomplete="PF('detDialog').show()" icon="" title="Detail">
                        <f:setPropertyActionListener value="#{tVar}" target="#{stmtBean.selectedElement}" />
                    </p:commandButton>
                    <p:commandButton value="N" update=""
                        oncomplete="PF('newDuoDialog').show()" icon="" title="Neue Regel mit diesem Statement als Grundlage">
                        <f:setPropertyActionListener value="#{tVar}" target="#{stmtBean.selectedElement}" />
                    </p:commandButton>
[ ... ]

这是错误还是我误用了某物?

Is this a bug or am I misusing sth?

推荐答案

这是预期的行为:当您在提交表单时设置属性时,仅在成功提交表单后才设置属性,情况并非如此验证失败时,即必填字段为空.

This is expected behaviour: As you are setting the property on submit of the form the property is only set when the form is successfully submitted, which is not the case when validation fails i.e. a required field is empty.

p:commandButton 上使用 process ="@ this" ,以便不提交表单.这应该对您有用,因为您只想打开对话框并设置属性.

Use process="@this" on the p:commandButton so the form is not submitted. This should work for you as you just want to open the dialog and set the property.

这篇关于jsf required = true销毁setPropertyActionListener吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆