8 Replies Latest reply on Oct 16, 2007 11:34 AM by igx89

    @DataModelSelection doesn't work in Restful

    dhinojosa

      I found out that when you RestFully set up a @DataModel, the @DataModelSelection returns the 1st element of the list, always, but when you attach a @Factory to the action method, then it works fine.

      It seems that the @Factory annotation has become more of a data table component extension and not just a method that executes when the component is invoked.

      Now, I am not sure if something needs to be fixed, or just placed into the documentation.




        • 1. Re: @DataModelSelection doesn't work in Restful
          dhinojosa

          Actually, let me look more into this and recreate this issue. hmmm.

          • 2. Re: @DataModelSelection doesn't work in Restful
            dhinojosa

            Nevermind, I was just being an idiot. ;)

            • 3. Re: @DataModelSelection doesn't work in Restful

              Care to elaborate? :)

              I just ran across the same issue: using DataModel without a Factory worked fine, but when I added DataModelSelection into the mix it always was just the first element until I put the Factory annotation on the getter for my DataModel.

              If this is expected behavior, then putting a warning about this into the document would undoubtedly save many people from frustration.

              • 4. Re: @DataModelSelection doesn't work in Restful

                Admin: change "document" to "documentation"

                • 5. Re: @DataModelSelection doesn't work in Restful
                  dhinojosa

                  Sweet! No ever asked to elaborate my idiocy;) Just kidding

                  What I had done (with simple but not the same example) was I created a bean just to try things out

                  @Stateful
                  @Name("searchEmployeesByState")
                  @Scope(ScopeType.SESSION)
                  public void SearchEmployeesByState ... {
                  
                   private List<Employee> employees;
                  
                   /**
                   * Getters and setters, em finders, etc here
                   */
                  }
                  


                  I then produced a page to view just to try things out

                   <h:dataTable value="#{searchEmployeesByState.employees}" var="employee">
                   ....
                   </h:dataTable>
                  


                  Note, the value in my data table....Because that's where my problem occured.

                  I then decided that I wanted to select the model....so like a good citizen I changed my bean...

                  @Stateful
                  @Name("searchEmployeesByState")
                  @Scope(ScopeType.SESSION)
                  public void SearchEmployeesByState ... {
                  
                   @DataModel
                   private List<Employee> employees;
                  
                   @DataModelSelection
                   private Employee employee;
                  
                   /**
                   * Getters and setters, em finders, etc here
                   */
                  }
                  


                  Now that I did that, I didn't change my web page like I should've. That's when an angry mind and a keyboard can go a long way to ruin your day. I was trying different combos with factory, etc, and I couldn't figure out why my one item wasn't being selected. Finally, after a while and came back and realized I had to make my web page into the following. Basic seam stuff, but I just missed it. :(


                   <h:dataTable value="#{employees}" var="employee">
                   ....
                   </h:dataTable>
                  


                  • 6. Re: @DataModelSelection doesn't work in Restful

                    Thanks :).

                    However, that unfortunately doesn't help with the problem I found; could someone from the Seam team explain the behavior I'm encountering?

                    • 7. Re: @DataModelSelection doesn't work in Restful
                      pmuir

                      @DataModel & @DataModelSelection aren't restful as they rely on the viewstate being restored. This is why we have page parameters.

                      • 8. Re: @DataModelSelection doesn't work in Restful

                        My problem has nothing to do with "restful"-ness; I'll create a new thread to properly separate things...