0 Replies Latest reply on May 22, 2006 10:26 PM by supernovasoftware.com

    @DataModelSelection and @Factory in same bean problem

      I have a SFSB that contains the following:

      
      @Stateful
      @Scope(EVENT)
      @Name("listItemDetail")
      @Interceptors(SeamInterceptor.class)
      public class ItemDetailListBean implements Serializable, ItemDetailList {
       private static final long serialVersionUID = -6647258400364301089L;
      
       @Out(scope = ScopeType.PAGE, required = false)
       private Long itemDetailBalance;
      
       @SuppressWarnings("unused")
       @DataModel(scope = ScopeType.PAGE)
       private List<Item> itemDetailList;
      
       @In(required = false)
       @Out(scope = ScopeType.PAGE, required = false)
       @DataModelSelection
       private Item item;
      
       public String select() {
       System.out.println("selected" + item.getId());
       return "selected";
       }
      
      
       @Factory("itemDetailBalance")
       public void balance() {
       itemDetailBalance = (Long) em.createNamedQuery("pipetracker.model.state.Inventory.details.balance")
       .getSingleResult();
       }
      
      }
      


      My funtionality is a follows.
      1. User selects item and the select() method is called. This is outjected and the previous page is displayed. I know this is working due to the System.out.printlin of the id.

      2. On the page the dataTable is displayed and if the id in the list is the same as the item that was outjected this row renders as input fields so this row can be updated.

      The balance is calculated by @Factory("itemDetailBalance") called from the JSF page.

      When this method is called it appears that Seam then outjects the first, and always the first item in my DataModel list and therefore only this row is updateable.

      I solved this by moving the factory to a totally separte SFSB so that there is no way for the item that I am interested in is reoutjected.

      This caused me to duplicate some functionality and I am confused as to the cause of my problem.

      If I am calling a method that only outjects one variable then why would others be affected if I am not changing them?

      I also tried switching to a straight method call as follows:

       public Long getBalance() {
       return (Long) em.createNamedQuery("pipetracker.model.state.Inventory.details.balance")
       .getSingleResult();
       }
      


      I assumed this would not outject anything, but is has the same effect. The only solution I have found was to separate the SFSB.

      Any insight would be greatly appreciated.