我有一个由列表填充的 ah:selectonemenu。选择特定值时,应呈现 ah:datatable。当我选择该“特定”值时,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}" />
<a4j:support event="onchange" ajaxsingle = "true" reRender="customTable" ></a4j:support>
</h:selectOneMenu>
</td>
</tr>
<h:panelGroup id="customTable">
<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%" rendered="#{CRUDOperatorProgram.selectedNextGenWorkflow == 0}">
<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>
</h:panelGroup>
更新代码:
<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}" valueChangeListener="#{CRUDOperatorProgram.nextGenWorkflowChanged}">
<f:selectItems value="#{CRUDOperatorProgram.nextGenWorkflowList}" />
<a4j:support event="onchange" reRender="customTable"></a4j:support>
</h:selectOneMenu>
</td>
</tr>
<h:panelGroup id="customTable">
<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>
</h:panelGroup>
Back Bean(相关部分)...
private List<WorkflowConfig> workflowConfigList = new ArrayList<WorkflowConfig>();
private List<SelectItem> nextGenWorkflowList;
public void nextGenWorkflowChanged(ValueChangeEvent event) {
workflowConfigList.clear();
//the value is a long, so make it a string and check
if(event.getNewValue() != null && event.getNewValue().toString().equals("0")){
loadWorkFlowConfigs();
}else{
//Do not show the datatable
workflowConfigList.clear();
}
}
public List<WorkflowConfig> getWorkflowConfigList(){
return this.workflowConfigList;
}
private void loadWorkFlowConfigs() {
Query query = em.createNamedQuery("findAllWorkflowSteps");
List<WorkflowStep> step = (List<WorkflowStep>) query.getResultList();
for(WorkflowStep workflowStep : step){
WorkflowConfig workflowConfig = new WorkflowConfig();
workflowConfig.setWorkflowStep( workflowStep );
workflowConfigList.add(workflowConfig);
}
}
我实施了一个valueChangeListener
像你说的。我尝试了这个示例(使用h:panelGroup
)和h:panelGroup
文档中没有解释的示例。每个都需要刷新页面......你能看到我做错了什么吗?