jsf-2datatabletomahawk

including selectOneMenu in datatable


i have created datatable with four selectOneMenu in it whenever i change the first selectOneMenu values of second selectOneMenu need to be populated on the same row and again on the selection of second selectOneMenu third needs to populate i had done this by passing row number value to each selectOneMenu (with intention which particular selectOneMenu user must has clicked on) but whenever i pass the value with f:param i am getting null value on the controller but same can be printed with outputText on datatable

please guide

<t:dataTable id="insertTaskDataTable" border="1"
                value="#{insertTask.taskList}" var="taskInfo" rowIndexVar="row"  
                iterationStatusVar="it">
                <t:column>
                <h:inputHidden  id="id" value="#{row}"/>
                </t:column>                 
            <t:column>
                <f:facet name="header">#{bundle['GROUP_HEADER']}</f:facet>
                <h:selectOneMenu id="taskGroup" value="#{taskInfo.groupList.comboValue}" onchange="document.getElementById('addTask:filterButton').click();">
                    <f:param  name="idTaskGroup" value="#{row}"/>
                    <t:outputText  name="id" value="#{row}"/>
                     <f:selectItems value="#{taskInfo.groupList.comboValues}" />
                </h:selectOneMenu>

            </t:column>
            <t:column>
                <f:facet  name="header">#{bundle['ACTIVITY_HEADER']}</f:facet>
                <h:selectOneMenu id="taskActivity" value="#{taskInfo.activityList.comboValue}">
                <f:ajax  render="taskSubActivity" listener="#{insertTask.handleActivityChange}"></f:ajax>   
                <f:selectItems value="#{taskInfo.activityList.comboValues}" />
                </h:selectOneMenu>

            </t:column>
            <t:column>
                <f:facet name="header">#{bundle['SUBACTIVITY_HEADER']}</f:facet>
                <h:selectOneMenu id="taskSubActivity" value="#{taskInfo.subActivityList.comboValue}">
                    <f:selectItems value="#{taskInfo.subActivityList.comboValues}" />
                </h:selectOneMenu>

            </t:column>
            <t:column>
                <f:facet name="header">#{bundle['COMPLEXTIY_HEADER']}</f:facet>
                <h:selectOneMenu id="taskComplexity" value="#{taskInfo.complexityList.comboValue}">
                    <f:selectItems value="#{taskInfo.complexityList.comboValues}" />
                </h:selectOneMenu>

            </t:column>

            <t:column>
                <f:facet name="header">#{bundle['BENCHMARK_EFFORT_HEADER']}</f:facet>
                <t:inputText  value="#{taskInfo.benchMarkHrs}" />
                <t:outputLabel value="hrs"/>
                <t:inputText  value="#{taskInfo.benchMarkMin}" />
                <t:outputLabel value="min"/>

            </t:column>

            <t:column>
                <f:facet name="header">#{bundle['DESCRIPTION_HEADER']}</f:facet>
                <t:inputText value="#{taskInfo.taskdescription}" />
            </t:column>


        </t:dataTable>
    </t:div>

            <a4j:commandButton id="filterButton" style="visibility:hidden;display:none" action="#{insertTask.handleGroupChange}" render="insertTaskDataTable" />

Solution

  • Hi Guys i got solution

    here it is,

        <t:dataTable id="insertTaskDataTable" border="1"
                    value="#{insertTask.taskList}" var="taskInfo" rowIndexVar="row"  
                    iterationStatusVar="it" rendered="#{insertTask.taskList[0] != null}" >
    
                <t:column>
                    <f:facet name="header">#{bundle['GROUP_HEADER']}</f:facet>
                    <h:selectOneMenu id="taskGroup" value="#{taskInfo.groupList.comboValue}"  onchange="document.getElementById('addTask:insertTaskDataTable:#{row}:groupButton').click();">
    
                         <f:selectItems value="#{taskInfo.groupList.comboValues}" />
                    </h:selectOneMenu>
    
                </t:column>
                <t:column>
                    <f:facet name="header">#{bundle['CATEGORY_HEADER']}</f:facet>
                    <h:selectOneMenu id="taskCategory" value="#{taskInfo.categoryList.comboValue}"  onchange="document.getElementById('addTask:insertTaskDataTable:#{row}:categoryButton').click();">
                         <f:selectItems value="#{taskInfo.categoryList.comboValues}" />
                    </h:selectOneMenu>
    
                </t:column>
                <t:column>
                    <f:facet  name="header">#{bundle['ACTIVITY_HEADER']}</f:facet>
                    <h:selectOneMenu id="taskActivity" value="#{taskInfo.activityList.comboValue}"  onchange="document.getElementById('addTask:insertTaskDataTable:#{row}:activityButton').click();">
    
                    <f:selectItems value="#{taskInfo.activityList.comboValues}" />
                    </h:selectOneMenu>
    
                </t:column>
                <t:column>
                    <f:facet name="header">#{bundle['SUBACTIVITY_HEADER']}</f:facet>
                    <h:selectOneMenu id="taskSubActivity" value="#{taskInfo.subActivityList.comboValue}" onchange="document.getElementById('addTask:insertTaskDataTable:#{row}:subActivityButton').click();">
                        <f:selectItems value="#{taskInfo.subActivityList.comboValues}" />
                    </h:selectOneMenu>
    
                </t:column>
                <t:column>
                    <f:facet name="header">#{bundle['COMPLEXTIY_HEADER']}</f:facet>
                    <h:selectOneMenu id="taskComplexity" value="#{taskInfo.complexityList.comboValue}">
                        <f:selectItems value="#{taskInfo.complexityList.comboValues}" />
                    </h:selectOneMenu>
    
                </t:column>
    
                <t:column>
                    <f:facet name="header">#{bundle['BENCHMARK_EFFORT_HEADER']}</f:facet>
                    <t:outputText  value="#{taskInfo.benchMarkHrs}" style="height: 10px; width: 50px;" />
                    <t:outputLabel value=" hrs"/>
                    <t:outputText value="#{taskInfo.benchMarkMin}" style="height: 10px; width: 50px;" />
                    <t:outputLabel value="min"/>
    
                </t:column>
    
                <t:column>
                    <f:facet name="header">#{bundle['DESCRIPTION_HEADER']}</f:facet>
                    <t:inputText value="#{taskInfo.taskdescription}" />
                    <h:commandButton id="groupButton" style="visibility:hidden;display:none" actionListener="#{insertTask.handleGroupChange}">
                        <f:attribute name="groupid" value="#{row}" />
                    </h:commandButton>
                    <h:commandButton id="categoryButton" style="visibility:hidden;display:none" actionListener="#{insertTask.handleCategoryChange}">
                        <f:attribute name="categoryid" value="#{row}" />
                    </h:commandButton>
                    <h:commandButton id="activityButton" style="visibility:hidden;display:none" actionListener="#{insertTask.handleActivityChange}">
                    <f:attribute name="activityid" value="#{row}" />
                    </h:commandButton>
                    <h:commandButton id="subActivityButton" style="visibility:hidden;display:none" actionListener="#{insertTask.handleSubActivityChange}">
                    <f:attribute name="subactivityid" value="#{row}" />
                    </h:commandButton>
                </t:column>
    
    
    
    
            </t:dataTable>