0 Replies Latest reply on Dec 5, 2008 10:33 PM by deanhiller2000

    start conversation after selectOneListBox

    deanhiller2000

      This should be really easy in seam, but I just can't figure it out. 


      exact error message:


      j_id31:accDec:j_id41: Validation Error: Value is not valid 



      This is very common when you have a list of objects instance 1, 2, 3, 4 and you select the an EJB with the same database id, but the object instance is different, but in this case, I can't figure out what is wrong.  account value is null to begin with so value is not valid is very bizarre.


      AccountActions - scoped to Session as this is the main page of the app.
      SubaccountAction - scoped to conversation just like you do from a table but it is not setting the selected value from ListBean due to some "value is not valid"



      Is it weird that the list will call SubaccountAction.getAccount when that is a conversation scoped bean and the conversation has not started yet?  Seems bizarre to me which is why I love the dataTable #{subaccountAction.edit(bean)} method. but this method does not work here.
         I can't call AccountActions.setAccount because that is a Session based bean, or can I?  isn't there a race condition problem here if it is called twice from two tabs?  No matter, I tried that and still got an error.  What I don't get is getAccount always returns null and setAccount is never called..it fails during validation :(.


      This is a very very simple app where the user selects an Account, clicks the one edit button and it displays the subaccounts for that account on the next page.  (I can easily do this in a dataTable but it doesn't work with selectOneListBox)


      Here is my code.....


      @Name("accountActions")
      @Scope(ScopeType.SESSION)
      public class AccountAction {
      
          @In
          private EntityManager entityManager;
          
           @In
           private User user;
           
           private List<Account> accounts;
           
           /* (non-Javadoc)
            * @see net.voicelog.webrates.ejb.session.AccountActionLocal#initialize()
            */
           public void initialize() {
                List<UserAcct> userAccounts = UserAcct.getUsersAccounts(user, entityManager);
                //HACK HACK: We could fix this and put this in the 
                //query instead so the query returns the accounts but the
                //query is more complicated so KISS first...
                accounts = new ArrayList<Account>();
                for(UserAcct userAcc : userAccounts) {
                     accounts.add(userAcc.getAccount());
                }
           }
      
           /* (non-Javadoc)
            * @see net.voicelog.webrates.ejb.session.AccountActionLocal#getAccounts()
            */
           public List<Account> getAccounts() {
                return accounts;
           }
      
      }
      
      <s:decorate id="accDec" template="../../web/zlogin/errorTemplate.xhtml">
           <ui:define name="label">Select One Account:</ui:define>
           <br/><br/>
                 <h:selectOneListbox value="#{subaccountActions.account}"
                size="15">
                <s:selectItems value="#{accountActions.accounts}" var="acc"
                     label="#{acc.clientName} #{acc.clientName}" />
                <s:convertEntity />
                 </h:selectOneListbox>
      </s:decorate>
      
      <br/>
      
      <h:commandButton id="view" value="View SubAccounts" action="#{subaccountActions.view()}"/>



      I would like to start the conversation on the view method ideally, but for some reason, selecting an entity just does not work at all!!!



      first off, I love using the pattern of a dataTable and have every row have an s:link with #{action.edit(bean)} and then having that method start the conversation....



      @Begin(flushType=FlushModeType.MANUAL)
      public void edit(Bean bean) {
      }



      Now, I have run into the situation of really wanting to do this with a selectOneListBox.  the first thing I do is have a Session scoped bean like above to list out the contents into a selectOneListBox instead of a dataTable.  Unfortunately, I cannot use the above method when clicking the single Edit button below the list box.  The other problem I run into is selecting a value in the list box and clicking edit button ends up with a validation error saying Value is not valid(which is very bizarre...I have seen this before when getBean returns a value not in the list, but in this case, I am setting a value right from the displayed list).


      Is there any trick to use @DataModel and @DataModelSelection. 


      thanks for any help,
      Dean