3 Replies Latest reply on Dec 22, 2007 12:35 PM by Pete Muir

    Parameters and @Factory

    Paweł Stawicki Newbie


      This is something I made based on "blog" example from seam 2.0.0GA (the one I use).

      I have such component in my app:

      public class SearchBean {
       private String province;
       private String category;
       public List<Article> search() throws InkaSearchException {
       //get articles based on province and category.
       public String getProvince() {
       return province;
       public void setProvince(String province) {
       this.province = province;
       public String getCategory() {
       return category;
       public void setCategory(String category) {
       this.category = category;

      search.jsp page looks like this:

       <h:selectOneMenu value="#{search.category}">
       <s:selectItems var="category" value="#{categories}"/>
       <h:selectOneMenu value="#{search.province}">
       <s:selectItems var="province" value="#{provinces}"/>
       <h:commandButton value="Szukaj" action="search"/>
      <h:dataTable var="art" value="#{searchResults}">
       <!-- display search results -->

      And this is pages.xml file fragment:

      <page view-id="/search.jsp">
       <param name="category" value="#{search.category}"/>
       <param name="province" value="#{search.province}"/>

      All this behaves strange. When I enter search.jsp page for the first time, searchResults are just initialized and it's ok. But then I set e.g. category to A, and province to B, and hit the button. In debug I can see _first_ factory method is called, and retrieves articles based on still null province and category, _after_this_ province is set to B and category to A. If I change category and province again, lets say to C and D, and hit the button again I can see such actions in debug:
      1. category and province set to A and B (old values)
      2. factory method called
      3. category and province set to C and D.

      Why it happens? Why parameters are not set before calling factory method?

      Best regards
      Pawel Stawicki