2 Replies Latest reply on Jun 19, 2008 12:40 PM by ziphyre

    Problem in JavaBeans as a backing bean?

    ziphyre

      Hi,


      The following code give me an empty table, while removing the @Name annotation and placing managed-bean lines in faces-config.xml does the work. From what I have read in the Seam doc, JavaBeans can be used as backing beans. So I obviously getting something wrong.


      .xhtml:


      <h:dataTable value="#{plannerEvents.eventList}" var="event">
              <h:column>
                      <h:outputText value="#{event.name}"/>
              </h:column>
      </h:dataTable>



      JavaBean:


      import java.util.List;
      
      @Name("plannerEvents")
      public class PlannerEventsBean {
         private List<Integer> eventList;
      
         public PlannerEventsBean() {
            eventList = new ArrayList<Integer>();
            eventList.add(3);
            eventList.add(6);
            eventList.add(2);
         }
      
         public List<Event> getEventList() {
            return eventList;
         }
         public void setEventList(List<Event> eventList) {
            this.eventList = eventList;
         }
      }



      If I remove the @Name annotation and add managed-bean definition to faces-config.xml, it works...

        • 1. Re: Problem in JavaBeans as a backing bean?
          wrzep

          I guess plannerEvents component is never created, probably because it is never scanned by Seam. You can check it on /debug.seam page. Do you have seam.properties file in your archive?


          Cheers,
          -Pawel

          • 2. Re: Problem in JavaBeans as a backing bean?
            ziphyre

            Thank you Pawel,


            There is no error on the page, so I cannot see the debug page


            But you are right anyway. I'm using a jboss tools generated ear project. The above code is from the main project, not from ejb project. I have moved the whole package from there to the ejb project and now It's OK.