0 Replies Latest reply on Jan 18, 2006 3:02 PM by Tob Fel

    Problems with getting an Object from a table via the DataMod

    Tob Fel Newbie

      Hello I want to select an object from a Datatable via the DataModel and the DataModelSelectionIndex like in the booking example.
      I always get an Exception :
      ....attempted to bind an Out attribute of the wrong type to: contributable...
      My Class looks like this

      @Stateful
      @Name("findContributables")
      @Interceptor(SeamInterceptor.class)
      public class FindContributablesAction implements FindContributables, Serializable
      {
      
      
       private static final long serialVersionUID = -6803933802941651662L;
      
      
      
       @PersistenceContext(type=EXTENDED)
       private EntityManager em;
      
       @DataModel
       private List<Object> contributables;
       @DataModelSelectionIndex
       private int contributableIndex;
      
       @Out
       private Object contributable;
       ....
      
      


      and the method invoked in the Datatable is selectContributable()

       public String selectContributable()
       {
       if (contributables==null) return "contributableList";
       try{
       setContributable();
       }catch(Exception e){System.out.println(e+"@selectContributable");}
       System.out.println("Contributable was selected @setContributable");
       return "contributableSelected";
       }
      
       private void setContributable(){
       try{
       contributable = contributables.get(contributableIndex);
       }catch(Exception e){System.out.println(e.toString()+"@setContributable");}
       System.out.println("Contributable #"+contributableIndex+" was set @setContributable" +contributable.toString());
       }
      


      The DataTable is generated by this method in the same class
      The EntityManger return here a List of several Object form the type Journal ect.
       public List<Object> getAllContributables() {
       String[] types = {"Journal", "Book", "Workshop", "Conference"};
       List<Object> list = null;
       try {
       ContributableManager cm = new ContributableManagerBean(em);
       for (int i=0; i<types.length; i++) {
       List<Object> templist = cm.findContributable(types, null);
       if (list == null) {
       list = templist;
       }
       else {
       list.addAll(templist);
       }
       }
       }
       catch (Exception e) {
       }
       contributables = list;
       return list;
       }