2 Replies Latest reply on Feb 8, 2011 3:23 PM by Kaye Ramar

    several dropdowns on one page

    Kaye Ramar Newbie

      I have an facelet containing several dropdown boxes. The issue is, these dropdown boxes are all getting tied to the same backing bean, and the result is when one dropdown changes they all change.

      Here is an example of the facelet:

      <div id="bookTitles">
       <a:repeat value="#{dataBean.getTitles}" var="title">
        <a:repeat value="#{dataBean.getResults(title)}" var="result">
          <a:commandLink value="#{result.name}" onclick="popupBookSummary(result.url, result.id)"/>
          <f:subview rendered="#{result.hasLanguageOptions}">
           <h:selectOneMenu value="#{????????}"> <!--your suggestions needed here-->
             <f:selectItems value="#{languageBean.getLanguageList()}" />
             <a:support event="onchange" reRender="bookTitles"
                  actionListener="#{displayBean.updateURL(result)}" />

      There are certain things that I cannot change (per a requirements document)

      1. The popupSummary(url, id) method is a black box of javascript. I cannot change the method signature.

      2. Each title MUST have its own dropdown next to its link (Meaning one dropdown cannot be placed at the top of the facelet. Unfortunately.)

      3. For any given dataBean, we do not know in advance how many titles will require a language dropdown.

      Any help would be greatly appreciated!!!

        • 1. Re: several dropdowns on one page
          Monkey Den Master

          What kind of objects are title and result?  First guess, without knowledge of the object model: If the value is not persistent, add a transient field to title or result (whichever makes the most sense) to allow binding to each object in the view.  Fields are bound to values in JSF so one global value gives you one global result in the view.

          <h:selectOneMenu value="#{title.language}">


          <h:selectOneMenu value="#{result.language}">

          • 2. Re: several dropdowns on one page
            Kaye Ramar Newbie


            Thank you for your suggestion. Without any knowledge of the object model you were spot-on with a working solution, and it actually enabled me to follow better practices. I ended up changing the a:support tag and moving the updateURL() method out of the displayBean (which never felt right as I was coding it) and into the result object which turned out to be a better place for it. By the way title is a String used to get a  list of result EJBs from the dataBean.

            Thanks again! Kaye