0

The dropdown:

<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" />

The listener:

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 is of type List<ReconContextVO>. In my bean I converted reconsList to reconItemList. ReconContextVO contains

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

Now I would like to display reconName, txnProcessingType, txnProcessingLevel in text fields on change of the dropdown. I wrote the ajax listner method like above code. I din't get any idea.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
jabiaxn
  • 1
  • 4

1 Answers1

1

Your concrete problem is caused by incorrect usage of <p:ajax>. The event="onChange" is invalid. It should be event="change" (which is the default already and thus can safely be omitted). The listener method argument is also invalid, it should be AjaxBehaviorEvent.

But, after all, you don't need a listener method for this. You can just bind the <p:selectOneMenu value> directly to a bean property.

<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>

Note that I assume that you've already a Converter for the object and that its equals() is properly implemented. You should get conversion/validation error on that if not properly done.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555