1 Reply Latest reply on Nov 20, 2007 11:23 AM by pmuir

    I have a problem with selectOneMenu

    bebon3

      this is my situation

      pubic Class A {
      private int id;
      private B b;

      @ManyToOne
      public B getB() {
      return b;
      }


      public void setB(B newB) {
      this.b = newB;
      }



      }

      public Class B {
      private String name;
      private int id;

      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      public int getId() {
      return id;
      }

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

      public String getName()
      {
      return name;
      }

      public void setName(String name)
      {
      this.name = name;
      }

      }


      I use JBoos4.2, seam, java 1.6, jsf1.2

      Now is my problem:

      when i try to persist class A with subobject B with my jsf page:

      <?xml version="1.0" encoding="utf-8"?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:s="http://jboss.com/products/seam/taglib"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">


      Register New Class A


      <f:view>

      <h:form>

      <s:validateAll>
      <h:panelGrid columns="2">

      Username: <h:inputText value="#{A.username}" required="true"/>
      Real Name: <h:inputText value="#{A.name}" required="true"/>
      Password: <h:inputSecret value="#{A.password}" required="true"/>
      country: <h:selectOneMenu value="#{A.b.id}">
      <f:selectItems value="#{register.BList}" />

      </h:selectOneMenu>

      </h:panelGrid>
      </s:validateAll>
      <h:messages/>
      <h:commandButton value="Register" action="#{register.register}"/>
      </h:form>
      </f:view>





      where "register" is my menagedBean (with seam annotation)


      when i submit my page result is terrible

      javax.servlet.ServletException: /register.xhtml @23,72 value="#{A.b.id}": Target Unreachable, 'b' returned null on 'org.jboss.seam.example.registration.A'
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


      why seam dont create object "b" in object "a" automaticaly? When I use new operator on class b everything is ok?

      please help me