2 Replies Latest reply on May 18, 2009 5:47 PM by Francisco Jose Peredo Noguez

    s:convertEntity equivalent without JPA Entities?

    Todd Gould Newbie

      Hello,


      I know this may be somewhat of an unusual question.  As always, I welcome any insights and suggestions as I am still coming up the learning curve and may be missing something obvious.


      I am wondering if there is some sort of equivalent (or similar alternative) to

      <s:convertEntity>

      that can be used withOUT any JPA Entities?  I have one application that does not use any @Entity components (customer requirements force persistence architecture down a completely different path).  However, I would still like to make use something to convert
      <SelectItems>

      into their native object format.  I presently have this working with a
      <rich:pickList>

      containing a
      <s:selectItems>

      tag and using the pickList converter attribute to do the trick.  However, this seems less elegant and a bit distracting than the
      <s:convertEntity>

      approach.


      Is there an alternative to

      <s:convertEntity>

      that will provide similar functionality without requiring JPA Entities?  Is there a better way to approach this than what I have working with the pickList and converter?  Is there a way to use
      <s:convertEntity>

      without using Entities?


      TIA!

        • 1. Re: s:convertEntity equivalent without JPA Entities?
          Todd Gould Newbie

          Does anyone have any thoughts/ideas on this topic?

          • 2. Re: s:convertEntity equivalent without JPA Entities?
            Francisco Jose Peredo Noguez Master

            Guess you could create a class like this:


            @Name("anythingStore")
            @Install(precedence=BUILT_IN)
            @Scope(PAGE)
            public class AnythingStore {
            
                 private List store;
                 
                 @Create
                 public void create()
                 {
                      store = new ArrayList();
                 }
                 
                  public Object get(int index){
                       return store.get(index);
                  }
                  
                  public int add(Object object){
                       if(!store.contains(object)){
                            store.add(object);                
                       }           
                       return store.indexOf(object);
                  }
            }
            



            and use EL expressions to get the assigned index for the objects stored in AnyEntityStore and use that as the id for your objects in the UI, Since the object is of PAGE scope, the id will remain the same for an object as long as you stay in the same page (you can of course change to scope if you need it to last longer).