0

below you see some part of my code, i just want to select the first value in a form and the rest should be updated via ajax, for example if you select PK than, MccName, MccVorname,MccDepartment should be shown via ajax after this selection. This should also be possible in other forms indepently,

<h:panelGrid columns="4">
    <h:form id="formmcc10">
        <h:outputText value="Pls select PK: " />
        <p:selectOneMenu value="#categorymcc.mcccatname}" id="mcccat"
            immediate="true" valueChangeListener="#categorymcc.processScat}">
            <f:selectItem itemLabel="#categorymcc.mcccatname}"itemValue="" />
            <f:selectItems value="#categorymcc.categoryName}" />
            <p:ajax update="formmcc10:mccscat1 formmcc10:mccscat2 formmcc10:mccscat3" event="change" />
        </p:selectOneMenu><h:outputText value="Mcc Name" />
        <p:selectOneMenu value="#{categorymcc.submcccatname}"id="mccscat1">
            <f:selectItemsvalue="#{categorymcc.subCategoryName}" />
        </p:selectOneMenu>
        <h:outputText value="Mcc Vorname" />
        <p:selectOneMenu value="#{categorymcc.subsubmcccatname}"id="mccscat2">
            <f:selectItems value="#{categorymcc.subSubCategoryName}" />
        </p:selectOneMenu>
        <h:outputText value="Mcc Department:" />
        <p:selectOneMenu value="#{categorymcc.abteilung}" id="mccscat3">
            <f:selectItems value="#{categorymcc.abteilungCategoryName}" />
        </p:selectOneMenu>
    </h:form>
</h:panelGrid>
Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
h.tol
  • 1
  • 1
  • The problem might be in your managed bean definition (and fixing the typos in the current code like `#categorymcc.categoryName}` which lacks the opening bracket `{`). Make sure your managed bean is `@ManagedBean @ViewScoped` or if you use CDI then `@Named @SessionScoped` – Luiggi Mendoza Apr 08 '13 at 21:38

1 Answers1

0

This could be anything, but I encountered one interesting problem like that recently. I tried to output a bean property like #{myBean.otherBean.name} and it worked when I loaded the page by normal request, but it didn't work with AJAX. When I tried #{myBean.otherBean.id}, it worked in both cases.

The problem was, that backend system didn't fill all data for otherBean on AJAX request, it filled only id (probably for better performance). I had to prepare a getOtherBeanById method and when I called that, AJAX started to work as expected.

I'm not an expert on this field, perhaps someone has a more precise explanation for that.

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
Richard
  • 279
  • 2
  • 9
  • missing brackets '{' is a transferring problem of me. In original code they are present. Changed all Bean to @ViewScoped except dateBean. After that the page is more strage like, you cannot select mccPk and there is no reaction after selection from first drop down, no ajax is possible. – h.tol Apr 09 '13 at 12:15