Bhaskar Auddy
Bhaskar Auddy

Reputation: 23

Unable to send parameter from JSF to Bean through datatable value attribute

I have a expansion datatable which is being populated by an Arraylist from the backend which has an id as primary key. When row is expanded, that id specific rows has to be searched in an another table and all the rows has to be displayed. when I am trying to pass the id as parameter in the value attribute, it's giving class cast exception.

here's the XHTML Code

<h:form>
    <p:dataTable var="data"
        value="#{trackerList.trackerList}">
        <f:facet name="header">Summary</f:facet>
        <p:column style="width:16px">
            <p:rowToggler />
        </p:column>

        <p:column headerText="ID">
            <h:outputText value="#{data.id}" />
        </p:column>

        <p:column headerText="Status">
            <h:outputText value="#{data.status}" />
        </p:column>

        <p:column headerText="Created Time">
            <h:outputText value="#{data.createdTime}" />
        </p:column>

        <p:column headerText="Created By">
            <h:outputText value="#{data.createdby}" />
        </p:column>

        <p:column headerText="Updated By">
            <h:outputText value="#{data.updatedby}" />
        </p:column>
        
        <p:rowExpansion>
            <p:dataTable var="metadata" value="#{statusList.getScenarioStatusList(data.id)}">
                <p:column headerText="Requirements">
                    <h:outputText value="#{metadata.requirements}" />
                </p:column>

                <p:column headerText="Exam Name">
                    <h:outputText value="#{metadata.examName}" />
                </p:column>

                <p:column headerText="Status">
                    <h:outputText value="#{metadata.status}" />
                </p:column>
                
            </p:dataTable>
        </p:rowExpansion>
    </p:dataTable>
</h:form>

Please Help.

Upvotes: 0

Views: 1167

Answers (1)

userDT
userDT

Reputation: 76

i think you need to define below line inside the p:datatable tag with passing id as parameter and instead of #{statusList.getScenarioStatusList(data.id)} in sub datatable you just do value= "#{yourBean.scenarioStatusList}". populate scenarioStatusList in loadLists(data.id) method.

<p:ajax event="rowToggle" listener="#{yourBean.loadLists(data.id)}"  />

Upvotes: 0

Related Questions