使用primefaces 4.0和jsf 2.2.5
stmt.xhtml有2个包含。 IncludeDetail.xhtml和IncludeDuo.xhtml。 IncludeDuo还包括IncludeDetail。
在 IncludeDetail.xhtml 中,<ui:composition>
元素不拥有<form>
,id
- 属性或任何其他特殊元素。仅限<h:panelGrid>
,<h:selectOneMenu>
和<h:selectOneMenu>
。没什么特别的。
IncludeDuo.xhtml 拥有<p:layout>
和<p:message>
作为<ui:composition>
的子元素。在<p:layout>
内更深入,我们找到了这段代码:
<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将不再执行它的工作:
<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>
[ ... ]
这是一个错误还是我误用了?
答案 0 :(得分:1)
这是预期的行为:当您在提交表单时设置属性时,仅在表单成功提交时设置属性,而在验证失败时则不是这样,即必填字段为空。
在process="@this"
上使用p:commandButton
,因此表单未提交。这应该对你有用,因为你只想打开对话框并设置属性。