0 Replies Latest reply on Jul 17, 2008 9:28 AM by nithy2mydream

    int search field

    nithy2mydream
      Hi
      im new 2 seam frame work.
      i faced one problem
      im using one integer field to search . but its not taking the values what all are i enterd in jsf page, its taking default null. empid,fname,lname are fields in jsf page and data fields in table.empid is int type, remaining are string.
      if i search wise fname and lname its giving the result.
      But if i search wise empid its taking null value default.

      This is the search page.
      <h:form id="employeeSearch" styleClass="edit">
        
              <rich:simpleTogglePanel label="Employee search parameters" switchType="ajax">
            
                     <s:decorate template="layout/display.xhtml">
                      <ui:define name="label">empid</ui:define>
                      <h:inputText id="fname" value="#{employeeList.employee.id.empid}"/>
                  </s:decorate>
                  <s:decorate template="layout/display.xhtml">
                      <ui:define name="label">fname</ui:define>
                      <h:inputText id="fname" value="#{employeeList.employee.id.fname}"/>
                  </s:decorate>

                  <s:decorate template="layout/display.xhtml">
                      <ui:define name="label">lname</ui:define>
                      <h:inputText id="lname" value="#{employeeList.employee.id.lname}"/>
                  </s:decorate>

            
              </rich:simpleTogglePanel>
            
              <div class="actionButtons">
                  <h:commandButton id="search" value="Search" action="/EmployeeList.xhtml"/>
              </div>
            
          </h:form>
        
      mport javax.persistence.Column;
      import javax.persistence.Embeddable;
      import org.hibernate.validator.Length;

      /**
      * EmployeeId generated by hbm2java
      */
      @Embeddable
      public class EmployeeId implements java.io.Serializable {

              private Integer empid;
              private String fname;
              private String lname;

              public EmployeeId() {
              }

              public EmployeeId(Integer empid, String fname, String lname) {
                      this.empid = empid;
                      this.fname = fname;
                      this.lname = lname;
              }

              @Column(name = "empid")
              public Integer getEmpid() {
                      return this.empid;
              }

              public void setEmpid(Integer empid) {
                      this.empid = empid;
              }

              @Column(name = "fname", length = 45)
              @Length(max = 45)
              public String getFname() {
                      return this.fname;
              }

              public void setFname(String fname) {
                      this.fname = fname;
              }

              @Column(name = "lname", length = 45)
              @Length(max = 45)
              public String getLname() {
                      return this.lname;
              }

              public void setLname(String lname) {
                      this.lname = lname;
              }

              public boolean equals(Object other) {
                      if ((this == other))
                              return true;
                      if ((other == null))
                              return false;
                      if (!(other instanceof EmployeeId))
                              return false;
                      EmployeeId castOther = (EmployeeId) other;

                      return ((this.getEmpid() == castOther.getEmpid()) || (this.getEmpid() != null
                                      && castOther.getEmpid() != null && this.getEmpid().equals(
                                      castOther.getEmpid())))
                                      && ((this.getFname() == castOther.getFname()) || (this
                                                      .getFname() != null
                                                      && castOther.getFname() != null && this.getFname()
                                                      .equals(castOther.getFname())))
                                      && ((this.getLname() == castOther.getLname()) || (this
                                                      .getLname() != null
                                                      && castOther.getLname() != null && this.getLname()
                                                      .equals(castOther.getLname())));
              }

              public int hashCode() {
                      int result = 17;

                      result = 37 * result
                                      + (getEmpid() == null ? 0 : this.getEmpid().hashCode());
                      result = 37 * result
                                      + (getFname() == null ? 0 : this.getFname().hashCode());
                      result = 37 * result
                                      + (getLname() == null ? 0 : this.getLname().hashCode());
                      return result;
              }

      }
      --
      entity class
      import javax.persistence.AttributeOverride;
      import javax.persistence.AttributeOverrides;
      import javax.persistence.Column;
      import javax.persistence.EmbeddedId;
      import javax.persistence.Entity;
      import javax.persistence.Table;

      /**
      * Employee generated by hbm2java
      */
      @Entity
      @Table(name = "employee", catalog = "emp")
      public class Employee implements java.io.Serializable {

              private EmployeeId id;

              public Employee() {
              }

              public Employee(EmployeeId id) {
                      this.id = id;
              }

              @EmbeddedId
              @AttributeOverrides( {
                              @AttributeOverride(name = "empid", column = @Column(name = "empid")),
                              @AttributeOverride(name = "fname", column = @Column(name = "fname", length = 45)),
                              @AttributeOverride(name = "lname", column = @Column(name = "lname", length = 45)) })
              public EmployeeId getId() {
                      return this.id;
              }

              public void setId(EmployeeId id) {
                      this.id = id;
              }

      }

      But in console : parameter empid value is null

      15:06:43,562 INFO  [STDOUT] Object[null, , ]

      any one help me how to give search option for int type field.
      Arun nithil S