我创建了带有四个selectOneMenu的数据表 每当我更改第二个selectOneMenu的第一个selectOneMenu值需要在同一行上填充时再次选择第二个selectOneMenu第三个需要填充 我通过将行号值传递给每个selectOneMenu(具有特定selectOneMenu用户必须单击的意图)来完成此操作但是每当我使用f:param传递值时,我在控制器上获取空值但是同样可以使用outputText打印数据表
请指导
<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" />
答案 0 :(得分:0)
嗨,大家好我有解决方案
在这里,
<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>
答案 1 :(得分:0)
最佳解决方案是 tomahawk library
t:selectOneRowJava Side
private Long selectedRowIndex = -1L; //Along with it's getters and setters
JSP方
<t:dataTable var="var" value="#{bean.beanList}"
style="border: 1px solid black;">
<t:column>
<t:selectOneRow value="#{bean.selectedRowIndex}" groupName="selection"
id="selectBtn">
</t:selectOneRow>
</t:column>
<t:column>
<f:facet name="header">
<h:outputLabel value="Names" />
</f:facet>
<t:outputText value="#{var.names}" />
</t:column>
<t:column>
<f:facet name="header">
<h:outputLabel value="Address" />
</f:facet>
<t:outputText value="#{var.address}" />
</t:column>
当“ selectedRowIndex ”为-1L时,表示行中没有任何内容被选中。 每当您需要将页面设置为未选择无线电时,请将此值设置为-1L。
结果应该是这样的......