4 Replies Latest reply on Oct 31, 2012 6:05 AM by Luan Garcia

    @DataModelSelection always empty

    Luan Garcia Newbie



      I'm having some troubles trying to fill a @DataModelSelection.

      My @DataModel works, the h:dataTable iterates fine, but when I choose a row it just reloads the page, but my selection continues empty.

      I'll post my code above, please, any help will be very welcome.




      public class CollaborationHome 
          EntityManager entityManager;
                @Out(required = false, value="ontologies")
                List<Ontology> oL;
                public void getOntologies()
                          oL =  (List<Ontology>) entityManager.createQuery("from Ontology").getResultList();
                private Ontology ontology;
                public Ontology getOntology()
                          return ontology;
                public void setOntology(Ontology ontology)
                          this.ontology = ontology;
                private List<Universal> universals;
                private Universal selectedUniversal;
                public void getSelectedUniversal(Universal selectedUniversal)
                          this.selectedUniversal = selectedUniversal;
                public Universal getSelectedUniversal()
                          return selectedUniversal;
                public void selectUniversals()
                                    universals = (List<Universal>)entityManager.createQuery("from Universal where unty_id=1 and onto_id = :ontoid").
                                                                                                               setParameter("ontoid", ontology.getOntoId()).




      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:rich="http://richfaces.org/rich" template="layout/template.xhtml">
                <ui:define name="body">
                                              <rich:panel style="float:left; width:20%">
                                                        <f:facet name="header">Arvore de Conceitos:</f:facet>
                                                        <h:outputLabel value="Ontologia:" ></h:outputLabel>
                                                        <h:selectOneMenu id="cbOntology" value="#{collaboration.ontology}">
                                                                  <s:selectItems value="#{ontologies}" var="onto" label="#{onto.ontoName}" noSelectionLabel="Selecione uma ontologia"/>
                                                                  <s:convertEntity />
                                                        <h:commandButton id="btnLoadOntology" value="Carregar" action="submit()" />
                                                        <rich:panel rendered="#{not empty collaboration.ontology}" >
                                                                  <h:dataTable value="#{universals}" var="univ">
                                                                                      <h:commandLink value="#{univ.univLabelpt}" />
                                              <rich:panel rendered="#{not empty selectedUniversal}">
                                                        <h:outputLabel value="a a #{selectedUniversal}"  />


      As I said, the drop down menu is populated, the load button works fine, then the universal query work aswell, but when I select a universal using the commandLink nothing happens, the page reloads but selectedUniversal still empty.

      I've tried the s:link also, but when the page reloads ontologies becomes null and then I get an error.

      I have no idea what to do, followed every step of the book but still doesn't work =\

        • 1. Re: @DataModelSelection always empty
          Luan Garcia Newbie

          No progress yet.

          Now I tried:



          <s:link view="/Collaboration.xhtml" value="#{univ.univLabelpt}">
            <f:param name="selectedConc"         


          Now when page realods the selectedUniversal object is filled by the one I've selected from the table, but collaboration.ontology is null.


          Please, any advice will be very welcone

          • 2. Re: @DataModelSelection always empty
            Luan Garcia Newbie

            Still stuck at the same point after a week. Maybe isn't a good idea use DataModel, any tips the way I should do it?

            • 3. Re: @DataModelSelection always empty
              Martin Kouba Master

              Actually I've never used the @DataModel annotation though here are my observations. CollaborationHome component is bound to the event context so it's created for each Servlet/JSF request and destroyed after the request completes. That might cause the problems. I would try conversation scoped component or Seam extended EL (#{collaboration.selectUniversal(univ)} plus add corresponding selectUniversal() method).


              Also I'm not completely sure I understand the business logic but I suppose you want to filter out unviersals for selected ontology (commandButton) and show the detail of selected universal (link in dataTable). Correct me if I'm wrong...

              1 of 1 people found this helpful
              • 4. Re: @DataModelSelection always empty
                Luan Garcia Newbie

                You're corret, I want to show details of selected universal.


                Not sure if I understood the problem that you pointed. Also, if I try to change CollaborationHome to @Scope(ScopeType.Conversation) the selectOneMenu stops working. It just doesn't select an ontology, problem that doesn't happen when I use the default scope.


                How would you do to show that information if not using @DataModel Martin?


                Thanks for the answer!