0 Replies Latest reply on May 25, 2007 2:34 AM by nathan dennis

    Seam Component Property Error (Weirdness)

    nathan dennis Expert

      Jboss 4.0.5
      seam 1.2 patch1
      postgres
      blah, blah, blah

      i recently had what i believe to be a strange occurrence while writing a very simple app.

      pay attention to destaddress property of Formmail...

      @Entity
      @Table(name = "formmail")
      @Name("formmail")
      public class Formmail implements Serializable {
      
       /**
       *
       */
       private static final long serialVersionUID = 1L;
       /**
       *
       */
      
       private String form;
       private String destaddress;
      
      
       @Id
       @NotNull
       @Length(max = 10)
       @Column(name="form")
       public String getForm() {
       return this.form;
       }
      
       public void setForm(String form) {
       this.form = form;
       }
      
       @Length(max = 80)
       @Column(name="destaddress")
       public String getDestAddress() {
       return this.destaddress;
       }
      
       public void setDestAddress(String destaddress) {
       this.destaddress = destaddress;
       }
      
       @Override
       public String toString()
       {
       return "Formmail(" + form + "," + destaddress + ")";
       }
      }
      
      
      ****************
      
      import javax.ejb.Local;
      @Local
      public interface FormmailSearch {
      
       public int getPageSize();
       public void setPageSize(int pageSize);
      
       public String getSearchString();
       public void setSearchString(String searchString);
      
       public String getSearchPattern();
      
       public void find();
       public void nextPage();
       public boolean isNextPageAvailable();
      
       public void destroy();
      
       }
      
      
      
      
      
      
      
      *********************
      //
      @Stateful
      @Name("formmailSearch")
      @Scope(ScopeType.SESSION)
      @Restrict("#{identity.loggedIn}")
      public class FormmailSearchAction implements FormmailSearch
      {
      
       @PersistenceContext
       private EntityManager em;
      
      
       private String searchString;
       private int pageSize = 10;
       private int page;
      
       @DataModel
       private List<Formmail> formmails;
      
       public void find()
       {
       page = 0;
       queryFormmails();
       }
       public void nextPage()
       {
       page++;
       queryFormmails();
       }
      
       @SuppressWarnings("unchecked")
      private void queryFormmails()
       {
       formmails = em.createQuery("select f from Formmail f where lower(f.form) like #{pattern}")
       .setMaxResults(pageSize)
       .setFirstResult( page * pageSize )
       .getResultList();
       }
      
      
       public boolean isNextPageAvailable()
       {
       return formmails!=null && formmails.size()==pageSize;
       }
      
       public int getPageSize() {
       return pageSize;
       }
      
       public void setPageSize(int pageSize) {
       this.pageSize = pageSize;
       }
      
       @Factory(value="pattern", scope=ScopeType.EVENT)
       public String getSearchPattern()
       {
       return searchString==null ?
       "%" : '%' + searchString.toLowerCase().replace('*', '%') + '%';
       }
      
       public String getSearchString()
       {
       return searchString;
       }
      
       public void setSearchString(String searchString)
       {
       this.searchString = searchString;
       }
      
       @Destroy @Remove
       public void destroy() {}
      
      
      ****************
      <a:outputPanel id="searchResults">
       <div class="section">
       <h:outputText value="No Entrys Like That Found" rendered="#{formmails != null and formmails.rowCount==0}"/>
      
       <h:dataTable id="formmails" value="#{formmails}" var="mail" rendered="#{formmails.rowCount>0}">
      
       <h:column>
       <f:facet name="header">Form:</f:facet>
       #{mail.form}
       </h:column>
      
       <h:column>
       <f:facet name="header">Destination Address</f:facet>
       #{mail.destaddress}
       </h:column>
      
       <h:column>
       <s:link id="viewFormmail" value="View Record" action="#{formmailPersist.selectFormmail(mail)}"/>
       </h:column>
       </h:dataTable>
      
      
       <s:link value="More results" action="#{formmailSearch.nextPage}" rendered="#{formmailSearch.nextPageAvailable}"/>
       </div>
      </a:outputPanel>
      
      *******************
      



      this gave me a error
      Exception during request processing: javax.servlet.ServletException: /FormmailList.xhtml: Bean: com.foo.Formmail, property: destaddress
      ......
      after banging my head against the table for a while,, i figured out that Seam had changed the property name from destaddress to destAddress.

      WHY??

      I went back and change the name of the column in my db,, then alter my code a little... none of the weird junk,,, just with destaddress-->destAddress.

      explanation anyone???

      what don't i understand??
      i mean randomly mapping characters in a variable name string to upper case makes the mapping a little difficult if you catch my drift.