0

下拉列表:

<h:outputLabel value="#{build.approvedRecons}" for="reconSearchFunctionalAreaID"></h:outputLabel>
    <p:selectOneMenu style="width:200px;" id="reconSearchFunctionalAreaID" >
        <f:selectItem itemValue="-Select One-" itemLabel="-Select One-" />
         <f:selectItems value="#{approvedReconDetailsBean.reconItemList}"/>
          <p:ajax update="@form" listener="#{approvedReconDetailsBean.reconDetailsDisplay}" event="onChange"></p:ajax>
    </p:selectOneMenu>............<h:outputLabel for="reconNameID" value="#{build.appvReconName}" />
                 <h:outputText value="#{build.colon}" />
                 <h:outputText value="#{approvedReconDetailsBean.reconCtxVO.reconID}" id="reconNameID" />

听者:

public void reconDetailsDisplay(SelectEvent event){

    ReconContextVO tempReconContextVO = ((ReconContextVO) event.getObject());
    ReconContextVO reconCtxVO1 = new ReconContextVO(); 
    reconCtxVO1.setReconID(tempReconContextVO.getReconID());
    reconCtxVO1.setReconName(tempReconContextVO.getReconName());
    reconCtxVO1.setTxnProcessingType(tempReconContextVO.getTxnProcessingType());
    reconCtxVO1.setTxnProcessingType(tempReconContextVO.getTxnProcessingType());
    this.setReconCtxVO(reconCtxVO1);
}

reconItemList是类型 List<ReconContextVO>。在我的 bean 中,我转换reconsListreconItemList. ReconContextVO包含

private String reconName; 
private String txnProcessingType; 
private String txnProcessingLevel; 
// and their setter & getters

现在我想在下拉列表更改的文本字段中显示, reconName。我像上面的代码一样编写了 ajax listner 方法。我不明白。txnProcessingTypetxnProcessingLevel

4

1 回答 1

1

您的具体问题是由<p:ajax>. event="onChange"无效。它应该是event="change"(这已经是默认设置,因此可以安全地省略)。监听器方法参数也是无效的,应该是AjaxBehaviorEvent.

但是,毕竟,您不需要为此使用侦听器方法。您可以<p:selectOneMenu value>直接将 绑定到 bean 属性。

<p:selectOneMenu value="#{approvedReconDetailsBean.reconCtxVO}">
    <f:selectItem itemValue="-Select One-" itemLabel="-Select One-" noSelectionOption="true" />
    <f:selectItems value="#{approvedReconDetailsBean.reconItemList}" />
    <p:ajax update="reconDetails" />
</p:selectOneMenu>

<h:panelGroup id="reconDetails">
    <h:outputText value="#{approvedReconDetailsBean.reconCtxVO.reconID}" />
    <h:outputText value="#{approvedReconDetailsBean.reconCtxVO.reconName}" />
    <h:outputText value="#{approvedReconDetailsBean.reconCtxVO.txtProcessingType}" />
    <h:outputText value="#{approvedReconDetailsBean.reconCtxVO.txnProcessingLevel}" />
</h:panelGroup>

请注意,我假设您已经Converter为该对象设置了 a 并且它equals()已正确实现。如果没有正确完成,您应该会收到转换/验证错误。

于 2012-12-24T11:38:07.393 回答