2 Replies Latest reply on May 9, 2011 7:35 AM by topfan

    Inherit property from parent bean

    topfan

      I've got a parentbean with managed-property myProperty. This is the faces-config.xml:

       

          <managed-bean>

              <managed-bean-name>parentBean</managed-bean-name>

              <managed-bean-class>pagecode.ParentBean</managed-bean-class>

              <managed-bean-scope>request</managed-bean-scope>

              <managed-property>

                  <property-name>myProperty</property-name>

                  <property-class>com.myaddress.mypage.ParentPropertyBean</property-class>

                  <value>#{ParentPropertyBean}</value>

              </managed-property>

          </managed-bean>

       

      If childBean inherit from parentBean, how can i do to inherit "myProperty" without insert it into the childBean????

       

      Thanks to all :-)

       

      topfan

       


        • 1. Inherit property from parent bean
          lfryc

          Hello,

           

          when you want do the same injection of property as in case of parentBean managed bean, you will need to configure also childBean as managed bean and then inject property myProperty into it.

           

          In other words, you need to do the same for childBean as for parentBean.

           

           

          Another way is to use annotation configuration instead of faces-config.xml (JSF 2.0 feature). Then you should be able to configure @ManagedProperty without duplication of declarations.

          • 2. Inherit property from parent bean
            topfan

            thank you very much, Lukáš :-)