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

    I have a problem with selectOneMenu

    tom bebak Newbie

      this is my situation

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

      public B getB() {
      return b;

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


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

      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"
      <html xmlns="http://www.w3.org/1999/xhtml"

      Register New Class A



      <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:commandButton value="Register" action="#{register.register}"/>

      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'

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

      please help me