1
votes

we need to fire ajax event on row selection on toggle of checkbox..i tried to find example but they are only doing row selection on click of p:command button.we are using primefaces 2.2

Code

<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>
1

1 Answers

1
votes

Instead of doing row selection event on toggle,we followed a diffrent approach using datatable attribute.This work magicaly

 <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>