2 Replies Latest reply on Oct 10, 2008 6:31 PM by Val Sw

    Seam generate-ui question

    Val Sw Expert

      I need help on proceeding with seam generate-ui, it looks great command but I have an issue and need suggestion....

      If we use generate-ui we get all links for each entity where we can create, edit or view(list).
      We can do insert, update and delete separately for each entity.

      Is it possible to summarize all entity fields in single xhtml so that persisting the root entity will persist all relational entities (I have 5 entities with proper relation ships).

      I think we can somehow handle this in homes or so but not sure how to handle it... please suggest...


        • 1. Re: Seam generate-ui question
          Jaime Martin Apprentice

          Hi Val,
          Yes, it´s is possible to have it all in a single xhtml file.
          I advise you to use some RichFaces (or other jsf) components to accomplish that.
          If the properties of main pojos that are pojos themselves are known I advise you to use suggestions box, h:selectOneMenu, f:selectItem and so on to ease that.
          For instance, a person works in a company, instead of filling all the fields of the company show all possible companies of the database with a selectOneMenu. If they´re too many use a suggestion box. That way you avoid filling that fields.
          If you do have to fill everything, because yoy have a new company for a new person, I advise you to have a form to save new companies, and then a form for persosn when you display companies as stated before. If you do want to have all that in a xhtml file, you could override persist method in the pojo home to handle all needed compulsory properties persistance before saving main pojo.
          Hope it helps.

          • 2. Re: Seam generate-ui question
            Val Sw Expert
            First of all thanks a lot for the replying...

            I am new to seam, so need suggestions... taking only 2 entities (though there are 5).

            Main root entity is Study.java, which is related to QuantExperiment.java(though QuantExperiment is list but it will be always One for Study).

            When I click "Create Study" it takes me to StudyEdit.xhtml form, where I have added quantExperiment fields.

            study fields
            <s:decorate id="studyNameDecoration" template="layout/edit.xhtml">
                 <ui:define name="label">Study Name</ui:define>
                 <h:inputText id="studyName"  value="#{studyHome.instance.studyName}"/>

            quantExperiment fields
            <s:decorate id="entryPointDecoration" template="layout/edit.xhtml">
                 <ui:define name="label">Entry Point</ui:define>
                 <h:inputText id="entryPoint" value="#{quantExperimentHome.instance.entryPoint}"/>
            .... so on
            <h:commandButton id="save" value="Save"
                                action="#{studyHome.persist}" disabled="#{!studyHome.wired}"

            As of now I have not changed anything in studyHome, to make sure that I follow good process.... please let me know if understanding is correct.
            On Save "studyHome.persist" is called which persits study fields but quantExperiment fields are persisted as null, this is because we need to somehow getQuantExperiment in studyHome and set in study before invoking studyHome.persist.

            What should be proper code in studyHome, like first I should inject QuantExperimentHome... then override persist in studyHome.

            public class StudyHome extends EntityHome<Study> {

                 public void setStudyHjid(Long id) {

                 public Long getStudyHjid() {
                      return (Long) getId();

                 protected Study createInstance() {
                      Study study = new Study();
                      return study;
                 public String persist(){
                     //GET QUANTEXPERIMENT FILEDS THEN ADD IT TO STUDY>>> somewhat like initStudy().setQuantExperiment(quantList); 
                      return super.persist();

                 public void wire() {

                 public boolean isWired() {
                      return true;

                 public Study getDefinedInstance() {
                      return isIdDefined() ? getInstance() : null;