3 Replies Latest reply on Nov 7, 2007 1:12 PM by jacob.orshalick

    best practice for populating combos

    lsabin

      Hi.

      Which is the best practice for populating a selectOneListBox component?

      I have a list of static values and I want to load then just once.
      I tried using a @Factory annotation in the method which retrieves those values in a Seam component with SESSION scope. But I am using a long-running conversation in my application and when I end this conversation the data seems to be removed.

      If I put the list of values in the CONVERSATION scope the values get corrupted when I change the tab (I have a richfaces tabpanel).

      I hope someone could help me to clarify this.

      Thanks.

        • 1. Re: best practice for populating combos

          Depends on what you mean by loading once. If you mean loading once for the entire application (which I have used in several instances) the following will work:

          @Factory(value="myListBox", scope=ScopeType.APPLICATION)
          public Map<String, BigDecimal> getMyListBox()
          {
           // the following log will only occur once since application scoped
           log.info("Loading myListBox...");
          
           // perform loading of Map into myMap
          
           return myMap;
          }


          Otherwise simply change the ScopeType accordingly.

          • 2. Re: best practice for populating combos
            lsabin

            Thanks for your reply.

            I tried your solution but when I end my conversation and I begin a new one my dropdown is not empty but when the action (associated with the onchange event) is triggered I get the error : (value is not valid).

            The onchange event is included in a <a4j:support>.


            • 3. Re: best practice for populating combos

              If you include your stacktrace and the snippet of the page where you use the variable, it will be easier to identify the issue.