0 Replies Latest reply on May 1, 2012 8:04 PM by Akaine Harga

    Managed bean's attributes are not getting autoinitialized on submit

    Akaine Harga Novice

      Hi everyone,


      I recentely began RF3->RF4 migration of one of my apps and hit the wall with the folowing issue:

      Lets say I have the following bean model, one using the other. For ex:


      public class Brand{
        private Integer idbrand;
        private String name;


      public class Car{
        private Brand brand;
        private Integer year;
        private String description;


      Then in xhtml I try to submit something like this:


      <h:outputText value="Brand:"/>
      <rich:select value="#{mbean.car.brand.idbrand}" converter="converterSI" required="true">
        <f:selectItems value="#{mbean.brandsSI}"/>
      <h:outputText value="Year:"/>
      <rich:select value="#{mbean.car.year}" converter="converterSI" required="true">
        <f:selectItems value="#{mbean.yearsSI}"/>
      <h:outputText value="Description:"/>
      <h:inputText value="#{mbean.car.description}" size="50" maxlength="256" required="true"/>


      while in my backing bean having initialized only the Car object via its default constructor leaving all referenced beans like brand as null.


      The thing is that in RF3 when submitting a form the related objects were getting autoinitialized and injected properly (in this example: mbean.car.brand.idbrand). And as I could see in RF4 I have to recreate each and every one manually every time I have a field referencing another bean.


      Before I start extending update_model_values phase with my own lazy initialization mechanism, is there any solution to automatize this without declaring all bean dependencies with their fields initialized? Actuallty I'm more worried about memory consumption than keyboard work. Or maybe I'm missing the point here...