6 Replies Latest reply on Feb 4, 2008 10:37 AM by mykey

    @DataModel vs. EL

    mykey

      I am displaying a list of entities (Student) with a @DataModel on a JSF Page with two links: one for editing and one for delting. For some reason the injection by DataModelSelection does not work correctly. My my status-EL messages for these two functions aren't shown correctly. Deletin entities works (except for the status message) whereas editing does not.

      This is my SFSB:

      @Stateful
      @Scope(ScopeType.SESSION)
      @Name("inscription")
      public class InscriptionAction implements InscriptionFacade {
      
       @Logger private Log log;
       @PersistenceContext(type=PersistenceContextType.EXTENDED) private EntityManager em;
       @DataModel private List<Student> studentList;
      
       @In(required=false)
       @Out(required=false)
       @DataModelSelection
       private StudentInsc inscribben; // StudentInsc inherits Student
      
       public String delete() {
      //
      // This log shows only "Deleting inscribben student"
      //
       log.info("Deleting inscribben student #{inscribben.givenName} #{inscribben.familyName}");
       studentList.remove(inscribben);
       StudentInsc stud = em.merge(inscribben);
       em.remove(stud);
      
       return "insc";
       }
      
       public String startEdit() {
      //
      // This log shows only "Start editing"
      //
       log.info("Start editing #{inscribben.givenName} #{inscribben.familyName}");
       em.merge(inscribben);
       return "editInsc";
       }
      
       public String finishEdit() {
      //
      // This log shows the correct values from the form "Finish editing Newname Newfamilyname"
      // but doesn't merge the inscribben student to the database
      //
       log.info("Finish editing #{inscribben.givenName} #{inscribben.familyName}");
      
       em.merge(inscribben);
       return "insc";
       }
      
      [....]
      


      This is my table:
      
      <rich:dataTable value="#{studentList}" var="stud" rendered="#{studentList.rowCount>0}" >
      [....]
      
       <rich:column><s:link action="#{inscription.startEdit}" value="#{stud.givenName} #{stud.familyName}" /></rich:column>
      <rich:column><s:link action="#{inscription.delete}" value="delete" /></rich:column>
      
      [....]
      </rich:dataTable>
      
      


      startEdit redirects to a form, where new values can be entered. On a button click finishEdit is invoked and the DataTable is shown again.

      I've already tried a lot, but nothing worked. Can somebody please help me?

        • 1. Re: @DataModel vs. EL
          dexjam

          Hi if it's just because of the EL-Expressions, maybe that somehow depends on having to have the logger static ... otherwise you possibly have to describe your problem further.

          • 2. Re: @DataModel vs. EL
            mykey

            After all that I have read, it makes no difference whether the logger is static or not. I didn't try that yet, but I will.
            But I don't think that this is the problem here, because the status messge from finishEditing is shown correctly (which does not solve the problem that the object isn't merged to the database.

            • 3. Re: @DataModel vs. EL
              pmuir

              Having @In and @DataModelSelection on inscribben is wrong - take away the @In.

              • 4. Re: @DataModel vs. EL
                mykey

                Naa. That didn't solve it (T_T) Still the same - wrong - status message. Furtheremore, the @In is needed, because the new state has to be entered to the database.

                This is the JSF that is shown after inscription.startEdit():

                
                <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                 xmlns:s="http://jboss.com/products/seam/taglib"
                 xmlns:ui="http://java.sun.com/jsf/facelets"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:h="http://java.sun.com/jsf/html"
                 xmlns:rich="http://richfaces.org/rich"
                 template="layout/template.xhtml">
                
                <ui:define name="body">
                
                 <h:messages />
                 <h:form>
                 <s:validateAll>
                 <fieldset>
                 <legend><h:outputText value="Persoenliche Daten"/></legend>
                 <h:panelGrid columns="2">
                 <h:outputText value="Vorname:"/><h:inputText value="#{inscribben.givenName}" required="true"/>
                 <h:outputText value="Nachname:"/><h:inputText value="#{inscribben.familyName}" required="true"/>
                 <h:outputText value="Geburtsdatum:"/><rich:calendar value="#{inscribben.dateOfBirth}" datePattern="MM-dd-yyyy"/>
                 <h:outputText value="Freiwillige Angaben" style="font-weight: bold" /><h:outputText value="" />
                 <h:outputText value="Name des Kindergartens:"/><h:inputText value="#{inscribben.kindergarten}" />
                 </h:panelGrid>
                 </fieldset>
                 <fieldset>
                 <legend><h:outputText value="Daten des Repraesentanten" /></legend>
                 <h:panelGrid columns="2">
                 <h:outputText value="Vorname:" /><h:inputText value="#{inscribben.representative.givenName}" required="true"/>
                 <h:outputText value="Nachname:" /><h:inputText value="#{inscribben.representative.familyName}" required="true"/>
                 <h:outputText value="Hauptstrasse:" /><h:inputText value="#{inscribben.representative.homeAdr.mainStreet}" required="true"/>
                 <h:outputText value="Querstrasse:" /><h:inputText value="#{inscribben.representative.homeAdr.transvStreet}" required="true"/>
                 <h:outputText value="Hausnummer:" /><h:inputText value="#{inscribben.representative.homeAdr.houseNo}" required="true"/>
                 <h:outputText value="Stadt:" /><h:inputText value="#{inscribben.representative.homeAdr.city}" required="true"/>
                 <h:outputText value="Freiwillige Angaben" style="font-weight: bold" /><h:outputText value="" />
                 <h:outputText value="Telefonnummer:" /><h:inputText value="#{inscribben.representative.telephone}" />
                 <h:outputText value="Mobiltelefonnummer:" /><h:inputText value="#{inscribben.representative.cellphone}" />
                 </h:panelGrid>
                 </fieldset>
                 <fieldset>
                 <legend><h:outputText value="Ueberwachen der Einschreibung" /></legend>
                 <h:panelGrid columns="2">
                 <h:outputText value="Benehmen" /><h:selectBooleanCheckbox value="#{inscribben.behavior}" required="true"/>
                 <h:outputText value="Auslastung" /><h:selectBooleanCheckbox value="#{inscribben.utilization}" required="true"/>
                 <h:outputText value="Sprache" /><h:selectBooleanCheckbox value="#{inscribben.language}" required="true"/>
                 <h:outputText value="Materialien" /><h:selectBooleanCheckbox value="#{inscribben.materials}" required="true"/>
                 </h:panelGrid>
                 </fieldset>
                 <fieldset>
                 <legend><h:outputText value="Evaluation" /></legend>
                 <h:panelGrid columns="6">
                 <h:outputText value="Prozent" style="font-weight: bold" />
                 <h:outputText value="Perzentil" style="font-weight: bold" />
                 <h:outputText value="Rang" style="font-weight: bold" />
                 <h:outputText value="Durchschnitt" style="font-weight: bold" />
                 <h:outputText value="Aequivalenz" style="font-weight: bold" />
                 <h:outputText value="Ergebnis" style="font-weight: bold" />
                
                 <h:inputText value="#{inscribben.percentage}" />
                 <h:inputText value="#{inscribben.percentil}" />
                 <h:inputText value="#{inscribben.rank}" />
                 <h:inputText value="#{inscribben.mean}" />
                
                 <h:selectOneListbox value="#{inscribben.equivalence}" size="1">
                 <f:selectItem itemLabel="" itemValue="" />
                 <f:selectItem itemLabel="buena" itemValue="buena" />
                 <f:selectItem itemLabel="regular" itemValue="regular" />
                 </h:selectOneListbox>
                 <h:outputText value="-" rendered="#{inscribben.percentage eq null or inscribben.percentil eq null or inscribben.rank eq null or inscribben.mean eq null or inscribben.equivalence eq null}" />
                 </h:panelGrid>
                 </fieldset>
                 </s:validateAll>
                 <h:commandButton action="#{inscription.finishEdit}" value="OK" />
                 <s:button action="home" value="back" />
                
                </ui:define>
                </ui:composition>
                
                


                It just displays input-boxes for all properties of the EntityBean. But, to me, it doesn't look like the problem lies in the JSF.

                • 5. Re: @DataModel vs. EL
                  mykey

                  Hooray!!!! (^_^) The problem is partially solved. The editing (from my last post) works now. Though, the status message is still not shown correctly.
                  I thought the whole time that these problems belong to each other; has anybody an explanation for this?

                  • 6. Re: @DataModel vs. EL
                    mykey

                    Sorry, I forgot:

                    I solved the problem by using the Conversation-Scope and @Begin for startEdit and @End for finishEdit - what I should probably have done in the first place.