4 Replies Latest reply on Jun 21, 2007 6:51 AM by g00se24

    Loosing information right out of my entity bean....

    g00se24

      Hello,

      i've quite a nice little problem:

      I outject a entity bean out of a seam component with multiple relations (OneToOne, ManyToMany, ManyToOne).
      So far everything works fine. The first page is rendered correct using the data. But if I do something like calling an seam action the ManyToMany relations are resolving to null. The other relations are working fine.

      Have anybody something a solution?

        • 1. Re: Loosing information right out of my entity bean....
          pmuir

          Show some code. Are you in a conversation?

          • 2. Re: Loosing information right out of my entity bean....
            g00se24

            Here we go:

            PS: I'm using a4j extremly hard!!!

            /**
             *
             * @author Dennis Guse
             *
             */
            @Name("users")
            @Scope(ScopeType.SESSION)
            public class UserControl extends Selection implements Serializable {
            
             @Out(required=false)
             public User getSelectedUser() {
             User selected = ((User) super.getSelected());
             if (selected != null) {
             System.out.println(selected.toString());
             }
             return (User) super.getSelected();
             }
            
             @In(required=false)
             public void setSelectedUser(User user) {
             setSelected(user);
             }
            
             public void add() {
             setSelected(new User());
             }
            
             public List<User> getResult() {
             return entityManager.createQuery(getQuery()).getResultList();
             }
            }
            
            <table 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.ajax4jsf.org/rich"
             xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">
             <tr>
             <td>
             <h:outputLabel for="client">Client</h:outputLabel>
             </td>
             <td>
             <h:outputText id="client" value="#{selectedUser.client}" />
             </td>
             </tr>
             <tr>
             <td>
             <h:outputLabel for="status">Status</h:outputLabel>
             </td>
             <td>
             <h:outputText id="status" value="#{selectedUser.status}" />
             </td>
             </tr>
             <tr>
             <td>
             <h:outputLabel for="customerGroup">CustomerGroup</h:outputLabel>
             </td>
             <td>
             <h:outputText id="customerGroup" value="#{selectedUser.customerGroup}" />
             </td>
             </tr>
            
             <tr>
             <td>
             <h:outputLabel for="title">Titel</h:outputLabel>
             </td>
             <td>
             <h:outputText id="title" value="#{selectedUser.title}" />
             </td>
             </tr>
             <tr>
             <td>
             <h:outputLabel for="firstName">firstName</h:outputLabel>
             </td>
             <td>
             <h:outputText id="firstName" value="#{selectedUser.firstName}" />
             </td>
             </tr>
             <tr>
             <td>
             <h:outputLabel for="surName">surName</h:outputLabel>
             </td>
             <td>
             <h:outputText id="surName" value="#{selectedUser.surName}" />
             </td>
             </tr>
             <tr>
             <td>
             <h:outputLabel for="language">Language</h:outputLabel>
             </td>
             <td>
             <h:outputText id="language" value="#{selectedUser.language}" />
             </td>
             </tr>
             <tr>
             <td>
             <h:outputLabel for="username">userName</h:outputLabel>
             </td>
             <td>
             <h:outputText id="username" value="#{selectedUser.username}" />
             </td>
             </tr>
             <tr>
             <table>
             <tr>
             <td>
             <h:outputLabel for="street">Street</h:outputLabel>
             </td>
             <td>
             <h:outputText id="street" value="#{selectedUser.address.street}" />
             </td>
             </tr>
             <tr>
             <td>
             <h:outputLabel for="address">StreetNumber</h:outputLabel>
             </td>
             <td>
             <h:outputText id="address" value="#{selectedUser.address.streetNumber}" />
             </td>
             </tr>
             <tr>
             <td>
             <h:outputLabel for="zip">ZIP</h:outputLabel>
             </td>
             <td>
             <h:outputText id="zip" value="#{selectedUser.address.zip}" />
             </td>
            
             </tr>
             <tr>
             <td>
             <h:outputLabel for="town">Town</h:outputLabel>
             </td>
             <td>
             <h:outputText id="town" value="#{selectedUser.address.town}" />
             </td>
             </tr>
             <tr>
             <td>
             <h:outputLabel for="country">Country</h:outputLabel>
             </td>
             <td>
             <h:outputText id="country" value="#{selectedUser.address.country}" />
             </td>
             </tr>
             </table>
             </tr>
            </table>
            
            <!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.ajax4jsf.org/rich"
             xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
             template="/administration/template.xhtml">
            
             <ui:define name="control">
             <a4j:commandLink value="Add" action="#{users.add}" oncomplete="javascript:Richfaces.showModalPanel('user',{width:450, top:200})" reRender="selected, user" />
             <h:inputText id="input" value="#{users.search}">
             <a4j:support event="onkeyup" reRender="result" requestDelay="100" ajaxSingle="true" />
             </h:inputText>
             </ui:define>
            
             <ui:define name="result">
             <rich:dataTable id="table" value="#{users.result}" var="item">
             <h:column>
             <h:outputText value="#{item.title} #{item.firstName} #{item.surName}">
             <a4j:support event="onclick" action="#{users.select}" reRender="selected, user" />
             </h:outputText>
             </h:column>
             <h:column>
             <h:outputText value="#{item.status}" />
             </h:column>
             <h:column>
             <a4j:commandButton value="Delete" action="#{users.delete}" reRender="selected, result, user" />
             </h:column>
             </rich:dataTable>
             </ui:define>
            
             <ui:define name="selected">
             <rich:tabPanel switchType="ajax" rendered="#{selectedUser != null}">
            
             <rich:tab label="Data">
             <a href="javascript:Richfaces.showModalPanel('user',{width:450, top:200})">
             Edit
             </a>
             <ui:include src="/objects/user.xhtml" />
             </rich:tab>
            
             <rich:tab label="Subscription">
             <h:dataTable value="#{selectedUser.subscriptions}" var="item" rendered="#{selectedUser.subscriptions != null}">
             <rich:column>
             <h:outputText value="#{item}" />
             </rich:column>
             </h:dataTable>
             </rich:tab>
            
             <rich:tab label="SubChannels">
            
             <ui:include src="/objects/subchannels.xhtml"/>
            
             </rich:tab>
            
             </rich:tabPanel>
            
             </ui:define>
            
            </ui:composition>
            
            The template for this page is easy nothing special, only some panels...
            


            If i visit the /objects/user.xhtml direct, i can watch closely.
            If a user gets selected I can see all attributes, but If I do any action on the page I lose the data, but only the data for the manytoone relations...

            Thanks in advance!!!

            • 3. Re: Loosing information right out of my entity bean....
              g00se24

              Okay here is a try of a more specific description:

              After I outject a entity object, I loose every ManyToOne relation of the entity bean.

              • 4. Re: Loosing information right out of my entity bean....
                g00se24

                Bug found:

                Never try to to inject data out of non displayed h:selectOneMenu,
                they are going to set the property to null.