我有一个包含三列的数据表,每个列的标题中都有一个复选框。当我选中一个复选框时,我必须更新其他2个复选框。这些列下的每一行都是带有验证器的输入框。当我提交表单时,我可以看到验证器正在执行,但我的actionListener没有被调用。也没有堆栈跟踪。请建议。
<p:dataTable id="segmentRangeTable" var="rank"
value="#{segmentSetup.ranks}">
<p:column headerText="Segment Names">
<p:outputPanel layout="block">
<p:inputText id="segmentName" style="text-transform:uppercase"
value="#{segmentSetup.userSegment.segmentNames[rank].name}"
validator="#{segmentSetup.validateNames}" immediate="true" />
<p:message for="segmentName" />
</p:outputPanel>
</p:column>
<p:column>
<f:facet name="header">
<p:outputPanel layout="block">
<p:outputLabel value="AUM" />
<br />
<p:outputPanel id="AUMcheckBox">
<p:selectBooleanCheckbox itemLabel="Default Rating"
styleClass="defaultRating"
value="#{segmentSetup.defaultRating eq 'AUM' ? true : false}"
disabled="#{!segmentSetup.userSegmentTypesMap['AUM'].selected}" >
<p:ajax update=":tabView:clientSegmentationTabForm:segmentRangeTable:REREVcheckBox :tabView:clientSegmentationTabForm:segmentRangeTable:REVcheckBox :tabView:clientSegmentationTabForm:segmentRangeTable:AUMcheckBox" process="@this" immediate="true"
listener="#{segmentSetup.changeDefaultRating('AUM')}" />
</p:selectBooleanCheckbox>
</p:outputPanel>
</p:outputPanel>
</f:facet>
<p:inputText id="AUM" styleClass="AUM"
value="#{segmentSetup.userSegmentTypesMap['AUM'].segmentValues[rank].rangeMinValue}"
disabled="#{!segmentSetup.userSegmentTypesMap['AUM'].selected || (rank==fn:length(segmentSetup.ranks))}"
validator="#{segmentSetup.validateRanges}" immediate="true" >
<f:convertNumber maxFractionDigits="2" currencySymbol="$"
type="currency" minFractionDigits="0" />
</p:inputText>
<p:message for="AUM" />
</p:column>
<p:column>
<f:facet name="header">
<p:outputPanel>
<p:outputLabel value="GROSS REVENUE" />
<br />
<p:outputPanel id="REVcheckBox">
<p:selectBooleanCheckbox itemLabel="Default Rating"
styleClass="defaultRating"
value="#{segmentSetup.defaultRating eq 'GRRVN' ? true : false}"
disabled="#{!segmentSetup.userSegmentTypesMap['GRRVN'].selected}">
<p:ajax update=":tabView:clientSegmentationTabForm:segmentRangeTable:REREVcheckBox :tabView:clientSegmentationTabForm:segmentRangeTable:REVcheckBox :tabView:clientSegmentationTabForm:segmentRangeTable:AUMcheckBox" immediate="true"
listener="#{segmentSetup.changeDefaultRating('GRRVN')}">
</p:ajax>
</p:selectBooleanCheckbox>
</p:outputPanel>
</p:outputPanel>
</f:facet>
<p:outputPanel>
<p:inputText id="GRRVN" styleClass="GRRVN"
value="#{segmentSetup.userSegmentTypesMap['GRRVN'].segmentValues[rank].rangeMinValue}"
disabled="#{!segmentSetup.userSegmentTypesMap['GRRVN'].selected || (rank==fn:length(segmentSetup.ranks)) }"
validator="#{segmentSetup.validateRanges}" immediate="true" >
<f:convertNumber maxFractionDigits="2" currencySymbol="$"
type="currency" />
</p:inputText>
<p:message for="GRRVN" />
</p:outputPanel>
</p:column>
<p:column>
<f:facet name="header">
<p:outputPanel>
<p:outputLabel value="REC REVENUE" />
<br />
<p:outputPanel id="REREVcheckBox">
<p:selectBooleanCheckbox itemLabel="Default Rating"
styleClass="defaultRating"
value="#{segmentSetup.defaultRating eq 'RERVN' ? true : false}"
disabled="#{!segmentSetup.userSegmentTypesMap['RERVN'].selected}">
<p:ajax update=":tabView:clientSegmentationTabForm:segmentRangeTable:REREVcheckBox :tabView:clientSegmentationTabForm:segmentRangeTable:REVcheckBox :tabView:clientSegmentationTabForm:segmentRangeTable:AUMcheckBox" immediate="true"
listener="#{segmentSetup.changeDefaultRating('RERVN')}">
</p:ajax>
</p:selectBooleanCheckbox>
</p:outputPanel>
</p:outputPanel>
</f:facet>
<p:inputText id="RERVN" styleClass="RERVN"
value="#{segmentSetup.userSegmentTypesMap['RERVN'].segmentValues[rank].rangeMinValue}"
disabled="#{!segmentSetup.userSegmentTypesMap['RERVN'].selected || (rank==fn:length(segmentSetup.ranks)) }"
validator="#{segmentSetup.validateRanges}" >
<f:convertNumber maxFractionDigits="2" minFractionDigits="0"
currencySymbol="$" type="currency" />
</p:inputText>
<p:message for="RERVN" />
</p:column>
</p:dataTable>
<p:outputPanel layout="block" styleClass="blx-align-rl">
<p:commandButton id="saveButton" value="Save" process="@form"
update="@form" actionListener="#{segmentSetup.save}" >
<f:param name="VALIDATE" value="true" />
</p:commandButton>
<p:commandButton id="cancelButton" value="Cancel" update="@form"
actionListener="#{segmentSetup.reset}" immediate="true" />
</p:outputPanel>
答案 0 :(得分:0)
我在尝试使用select状态渲染或不渲染另一个面板时遇到了类似的问题。我基本上使用的是JSF 2和Richfaces。 最后对我有用的是使用&#34; onchange&#34;从组件中调用一个小js,改变了我的面板属性为&#34; none&#34;和&#34;重要&#34;。
看起来几乎像这样:
<h:selectBooleanCheckbox
id="idCheck"
value="#{bean.hidePanel}"
onchange="changePanelView()">
</h:selectBooleanCheckbox>
和js:
<script>
function changePanelView() {
if (document.getElementById('idForm:idCheck').checked) {
document.getElementById('idPanel').style.setProperty('display', '', 'important');
} else {
document.getElementById('idPanel').style.setProperty(
'display','none', 'important');
}
}
</script>
这个页面已经使用了一些ajax技巧但是我已经从这种情况中删除了,因为它重新渲染了面板,覆盖了属性&#34;显示&#34;