2 Replies Latest reply on Oct 23, 2009 4:47 PM by B Tomic

    Is application scoped model for s:convertEntity possible?

    B Tomic Newbie

      I have a conversation scoped list of tags (that can be assigned to items) and I am using s:convertEntity inside a h:selectManyListbox for this - nothing special.

      The trick is that I don't need the list of tags re-fetched for every conversation, so I tried promoting the tag list to session or even application scope (updated via events in this case), but then s:convertEntity stopped working correctly (returning value not valid every time).

      The tag list is obtained through a factory inside an event scoped component.
      Am I doing something wrong here or this simply impossible? I thought that as long as the model is retained, everything is ok, but I seem to be mislead.

      Here's the current (non working) code:

      public class Tagger {
           @In private EntityManager entityManager;
           @Factory(value="allTags", scope=ScopeType.SESSION)
           public List<Tag> getAvailabeTags()
                List<Tag> tags = entityManager.createQuery("select t from Tag t").getResultList();
                return tags;

      <s:decorate id="tagsField" template="layout/edit.xhtml">
                <ui:define name="label">Tags</ui:define>
                <h:selectManyListbox value="#{itemHome.instance.tags}">
                     <s:selectItems var="t" value="#{allTags}" label="#{t.name}" />
                     <s:convertEntity />

      If @Factory's scope is changed to conversation or page, it works fine.