1 Reply Latest reply on Mar 10, 2009 10:16 AM by Ilya Shaikovsky

    Linked comboboxes

    Jim Bean Newbie

      Hi everybody!

      I need to use linked comboboxes in JSF via RichFaces, and I'm facing some problems.

      First combobox is a list of clients.

      Second combobox is a list of projects.

      When user selects client, list of projects, for that client should be available.

      Here is the code:

      <h:selectOneMenu id="clieId" value="#{task.task.clieId}" title="ClieId" required="true" requiredMessage="The clieId field is required." >
       <f:selectItems value="#{client.clientItemsSelectOneByName}"/>
       <a4j:support event="onchange" actionListener="#{project.clientSelected}" reRender="projId" />
       <h:outputText value="Project:"/>
       <h:selectOneMenu id="projId" value="#{task.task.projId}" title="ProjId" >
       <f:selectItems id="projIdElems" value="#{project.projectItemsAvailableByNameForClient}"/>

      My problem is:

      When I go to edit form which contains this code, method clientSelected() is called several times and projects load for some other client, and not for the one that is selected.

      How to avoid this excessive calling?
      If my logic is wrong, can someone, please, tell me how to do it properly?

      Thank you very much