4 Replies Latest reply on Jun 2, 2009 6:18 PM by Nikolay Elenkov

    init process for HtmlSelectOneMenu

    Arbi Sookazian Master

      I have a requirement to pre-populate HtmlSelectOneMenu component when page first loads.  I tried using @Create on my public void init() method but it was firing too late in the JSF life cycle process to be useful (i.e. the drop-down was not displaying the actual pre-loaded value/description).


      So now I'm using the following...


      pages.xml:


      <page view-id="/ManageEquipment.xhtml">
               <description>Manage Equipment</description>
               <action execute="#{manageEquipment.init}"/>
      </page>



      The problem with this approach is that the init() method is executed for every postback (there is a form in the xhtml which posts back to same xhtml page on submit).


      Everything needs to be CONVERSATION scoped in terms of Seam components.


      I'm thinking about using @Startup with @Create in a separate Seam component now.  But it looks like those components are limited to SESSION and APPLICATION scopes, and I need CONVERSATION scope for this context variable.


      How can I add a <rule if="#{something interesting!}"> such that the action method will only fire when a LRC does not exist?  Or any other way to make it run only once per LRC?


      Now that I think of it, I could set a boolean variable to false after the first pass and use that boolean variable in the rule tag...


      Is that a good way to handle this???  thx.