【发布时间】:2012-11-05 11:24:30
【问题描述】:
我有一个带有 h:selectOneMenu 和数据表的页面。我想根据我在 h:selectOneMenu 中选择的内容来加载/渲染/启用我的 h:datatable。这可能吗?
这里有一些代码
<tr class="portlet-table-body" >
<td width="20%" class="porlet-padding-left"><h:outputText value="${operatorProgramBundle.NextGenerationWorkflow}" /></td>
<td width="450px">
<h:selectOneMenu id="ngw" styleClass="portlet-dropdown" value="${CRUDOperatorProgram.selectedNextGenWorkflow}">
<f:selectItems value="${CRUDOperatorProgram.nextGenWorkflowList}" />
</h:selectOneMenu>
</td>
<h:dataTable id="DispatchConfigurationCustom" columnClasses="portlet-table-same portlet-table-cell"
headerClass="portlet-table-same portlet-table-cell" value="#{CRUDOperatorProgram.workflowConfigList}" var="workflowConfig" width="100%" >
<h:column>
<f:facet name="header">
<h:outputText value="Include" />
</f:facet>
<h:selectBooleanCheckbox id="includeInd" value="#{workflowConfig.isIncludedInd}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Automate" />
</f:facet>
<h:selectOneRadio id="onOff" value="#{workflowConfig.isAutomatedInd}">
<f:selectItem id="onButton" itemLabel="On" itemValue="0" />
<f:selectItem id="offButton" itemLabel="Off" itemValue="0" />
</h:selectOneRadio>
</h:column>
</h:dataTable>
【问题讨论】:
-
是的,在 JSF 2 中可以在
<h:selectOneMenu>中使用<f:ajax update="DispatchConfigurationCustom">标记。如果您使用的是 JSF 1.2,则需要像 RichFaces 3 一样处理 ajax 交互的第三方库。 -
@ luiggimendoza是可以拥有未禁用的DataTable,然后选择从H:Selectonemenu的某些特定的东西时,可将DataTable启用?你介意给我举个例子吗?
-
“启用/禁用”在 HTML
<table>元素(由<h:dataTable>组件生成)的上下文中是一个奇怪的术语。你不是说“显示/隐藏”吗?此外,您使用的是 JSF 1.x 还是 2.x?您放置代码的方式(这在语法上对 JSP 上的 JSF 1.x 有效)和“portlet”这个词闻起来很像旧版 JSF 1.x portlet。 -
好的。您使用的是 JSF 1.x 还是 2.x?在任何人发布答案之前知道这一点非常重要。由于新的内置 ajaxical 功能,许多事情在 JSF 2.x 中以不同方式和更优雅的方式完成。