我们需要在checkbox..i切换时在行选择上触发ajax事件 试图找到示例,但他们只是在点击时进行行选择 p:command button.we正在使用primefaces 2.2
代码
<p:dataTable id="insList" var="insured"
value="#{policyHandler.insuredList}" paginator="true"
rows="#{label.insuredList_defaultNumberOfRows}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="#{label.insuredList_numberOfRows}"
style="width: 98%;" selection="#{policyHandler.inquiryInsureds}"> <!--<p:column>
<f:facet name="header">
<h:outputLabel value="Select" />
</f:facet>
<h:selectBooleanCheckbox id="selection"
value="#{insured.status}">
<p:ajax event="click" update="insuredOrder, selection" />
</h:selectBooleanCheckbox>
</p:column>
-->
<p:column selectionMode="multiple" />
<p:column>
<f:facet name="header">
<h:outputLabel value="Sequence" />
</f:facet>
<p:cellEditor id="insuredOrder" disabled="#{!insured.status}">
<f:facet name="output">
<h:outputText value="#{insured.sequence}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{insured.sequence}" />
</f:facet>
</p:cellEditor>
<p:rowEditor />
</p:column>
<p:column headerText="Name"
sortBy="#{insured.generalPartyInfo.nameInfo.commlName.commercialName}"
filterMatchMode="contains" style="text-align:center;">
<h:outputText
value="#{insured.generalPartyInfo.nameInfo.commlName.commercialName}" />
</p:column>
<p:column sortBy="#{insured.generalPartyInfo.addr.city}"
style="text-align:center;">
<f:facet name="header">
<h:outputLabel value="Street Address" />
</f:facet>
<h:outputText value="#{insured.generalPartyInfo.addr.city}" />
</p:column>
<p:column sortBy="#{insured.generalPartyInfo.addr.city}"
style="text-align:center;" width="10%">
<f:facet name="header">
<h:outputLabel value="#{label.city}, #{label.state} " />
<h:outputLabel value=" #{label.postalcode}" />
</f:facet>
<h:outputText
value="#{insured.generalPartyInfo.addr.city}, #{insured.generalPartyInfo.addr.stateProv} #{insured.generalPartyInfo.addr.postalCode}" />
</p:column>
<p:column headerText="Policy Type">
<h:outputText value="#{insured.policyType}" />
</p:column>
<p:column headerText="Action" style="text-align:center;">
<p:commandLink>
<h:outputText value="Change" />
</p:commandLink>
</p:column>
</p:dataTable>
答案 0 :(得分:1)
我们没有在切换时执行行选择事件,而是使用了数据表属性的不同方法。这项工作神奇地
<p:dataTable id="insList" var="insured"
value="#{policyHandler.insuredList}" paginator="true"
rows="#{label.insuredList_defaultNumberOfRows}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="#{label.insuredList_numberOfRows}"
style="width: 98%;">
<p:column>
<f:facet name="header">
<h:outputLabel value="Select" />
</f:facet>
<h:selectBooleanCheckbox id="selection"
value="#{insured.status}">
<f:ajax execute="@this"
listener="#{policyHandler.DoPathProcessing2}" render="insList"/>
<f:attribute name="insured" value="#{insured}" />
</h:selectBooleanCheckbox>
</p:column>
<p:column>
<f:facet name="header">
<h:outputLabel value="Sequence" />
</f:facet>
<p:cellEditor id="insuredOrder" disabled="#{!insured.status}">
<f:facet name="output">
<h:outputText value="#{insured.sequence}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{insured.sequence}" />
</f:facet>
</p:cellEditor>
<p:rowEditor />
</p:column>
<p:column headerText="Name"
sortBy="#{insured.generalPartyInfo.nameInfo.commlName.commercialName}"
filterMatchMode="contains" style="text-align:center;">
<h:outputText
value="#{insured.generalPartyInfo.nameInfo.commlName.commercialName}" />
</p:column>
<p:column sortBy="#{insured.generalPartyInfo.addr.city}"
style="text-align:center;">
<f:facet name="header">
<h:outputLabel value="Street Address" />
</f:facet>
<h:outputText value="#{insured.generalPartyInfo.addr.city}" />
</p:column>
<p:column sortBy="#{insured.generalPartyInfo.addr.city}"
style="text-align:center;" width="10%">
<f:facet name="header">
<h:outputLabel value="#{label.city}, #{label.state} " />
<h:outputLabel value=" #{label.postalcode}" />
</f:facet>
<h:outputText
value="#{insured.generalPartyInfo.addr.city}, #{insured.generalPartyInfo.addr.stateProv} #{insured.generalPartyInfo.addr.postalCode}" />
</p:column>
<p:column headerText="Policy Type">
<h:outputText value="#{insured.policyType}" />
</p:column>
<p:column headerText="Action" style="text-align:center;">
<p:commandLink>
<h:outputText value="Change" />
</p:commandLink>
</p:column>
</p:dataTable>