3 Replies Latest reply on Nov 28, 2007 2:09 PM by birwin

    AJAX Calls give

    birwin Newbie

      I have two selectOneMenu controls on my Seam page. One uses an AJAX call to re-render the employees associated with the division. All works well the first time I change a division (Note... No matter what division I select the first time, the other control appears to re-render correctly).

      The second time I change the division I get this error... No matter what division I select.

      sourceId=j_id10:j_id25[severity=(ERROR 2), summary=(value is not valid), detail=(value is not valid)]

      The control is re-rendered, but with incorrect information.

      I was assuming that the selected item was not in the re-rendered list, so I created an Employee object with a "0" employeeID. I then made sure the employee was included in each rendered list and I made sure that employee was the one that was selected each time I changed division. That did not make a difference.

      Division :
      <h:selectOneMenu value="#{payrollExport.selectedClient}">
       <s:selectItems value="#{payrollExport.clients}" var="c" label="#{c.pluses}#{c.description}" />
       <f:converter converterId="clientConverter" />
       <a:support event="onchange" actionListener="#{payrollExport.refreshEmployees}" reRender="employees" />
      </h:selectOneMenu>
      
      Employee :
      <h:selectOneMenu id="employees" value="#{payrollExport.employee}">
       <s:selectItems value="#{payrollExport.employees}" var="e" label="#{e.lastName}, #{e.firstName}" noSelectionLabel="All Employees" />
       <f:converter converterId="employeeConverter" />
      </h:selectOneMenu>
      


      I have overriden the Employee "equals" and "hashCode" methods. The equals method compares the employeeID (A unique int from a database table) and the hashCode method simply returns the employeeID. Two objects with the same employeeID should be equal.

      JBoss 4.2.0.GA
      Seam 1.2

        • 1. Re: AJAX Calls give
          birwin Newbie

          OOPS! The title should have read:

          AJAX calls give value is not valid error.

          • 2. Re: AJAX Calls give
            Damian Harvey Master

            Try making payrollExport conversation scoped eg

            @Name("payrollExport")
            @Scope(ScopeType.CONVERSATION)
            and then ensuring that you start a conversation via pages.xml <begin-conversation> (or similar)

            Cheers,

            Damian.

            • 3. Re: AJAX Calls give
              birwin Newbie

              Thanks for the input. PayrollExport was scoped session.

              I did find the problem, however. It was a coding problem. In my "refreshEmployees" method I was changing the list of Clients based on a checkbox (Not displayed in this post - My Bad!).

              Because I was not refreshing the client drop-down in my AJAX call, I did not notice the list of clients had changed. Since the selected client now was no longer a member of the list of clients, this exception was thrown on the next AJAX call.