3 Replies Latest reply on Oct 7, 2010 7:13 AM by lvdberg

    How to create subentity?

    bemar

      Hello,


      I'm trying several things with my seam-gen (2.2) project. In my model the entity company can have N entitys of address.
      Seam-gen generated for me a separate edit gui for the company and a separate edit gui for the address.
      Now I want to built a gui form in which the user can enter the company data and the first(main) address in one step. Further address can be edited with the standard address gui.


      Every try to access the address directly through the company fails


      In example the rich face code for zip


      <s:decorate id="nameBuildingField" template="layout/edit.xhtml">
                          <ui:define name="label">ZIP</ui:define>
                          <h:inputText id="nameBuilding" size="45" maxlength="45"
                              value="#{companyHome.instance.address.zip}">
                          </h:inputText>
                      </s:decorate>


      resultet in


      javax.el.PropertyNotFoundException: /CompanyEdit.xhtml @63,60 value="#{companyHome.instance.address.nameBuilding}": Target Unreachable, 'address' returned null on 'ch.bemar.creditfriend.model.Company'
      



      when I try to save the form.


      How can I solve this problem to create a company and the first subrecord for address?


      Thank you for your help


      Regards
      Ben


        • 1. Re: How to create subentity?
          lvdberg

          Hi,


          do a check first in your bean and create an address when the vaklue is null. Another approach is to adapt the entity and create the address there directly;


          Leo

          • 2. Re: How to create subentity?
            bemar

            Thx I made both and both helped ...


            I also removed some NotNull properties from the entities in the database and beans(anotations). But seam wants furthermore that this fields are filled. Do I have to do some other adjustements in other files?


            Thx for your help


            Ben

            • 3. Re: How to create subentity?
              lvdberg

              Hi,


              Check the validator annotations in the entities, because these take care of checking content.


              Leo