1 Reply Latest reply on Jul 4, 2006 5:31 AM by sws42

    Outjection Problem

    sws42

      Hi!

      I've an application similar to the booking-example.
      You can select an item from a list and go to a page to edit this item.

      I have a stateful bean, from which the list is populated via @DataModel. I get back a @DatamodelSelction, which is a simple Bean, no Seam Component. In my JSP, I call an action method in another bean, which requests an EntityBean from the Database. I want to outject this row, but always get an

      org.jboss.seam.RequiredException: Out attribute requires value for component: walzeedit.walze


      Here is my code:
      Entity Bean:
      @Entity
      @Name("walze")
      @Table(name="WALZEN"
      , uniqueConstraints = { }
      )
      
      public class Walzen implements java.io.Serializable {
      
      .
      .
      .
      


      List:
      @Name("walzenuebersicht")
      @Stateful
      @Scope(ScopeType.SESSION)
      @LoggedIn
      
      public class WalzenUebersichtBean
       implements WalzenUebersicht {
      
       private String hydronummer = null;
       private String gruppe = null;
      
       @In (create=true)
       private EntityManager walzenDatabase;
      
       @DataModel
       private List<WalzenElement> walzenliste;
      
       @DataModelSelection
       WalzenElement selectedWalze;
      
       @Out(scope=ScopeType.CONVERSATION,required=false)
       Map<WalzenElement, Boolean> walzenSelection;
      
       @Factory("walzenliste")
       public void zeigeWalzen() {
      
      .
      .
       public WalzenElement getSelectedWalze() {
       return selectedWalze;
       }
      .
      .
      
      


      EditBean:
      @Name("walzeedit")
      @Stateful
      @LoggedIn
      
      public class WalzeEditBean
       implements WalzeEdit{
      
       @In (create=true)
       private EntityManager walzenDatabase;
      
       @In
       private WalzenUebersicht walzenuebersicht;
      
       @Out
       private Walzen walze;
      
      .
      .
      .
      
      
       @Begin
       public String aendern(){
       WalzenElement selectedWalze = walzenuebersicht.getSelectedWalze();
       walze = (Walzen) walzenDatabase.createQuery("SELECT w FROM Walzen w WHERE id = :id")
       .setParameter("id", selectedWalze.getId())
       .getSingleResult();
       return "editWalze";
       }
      
      


      List JSP:
      .
      .
       <t:dataTable id="walzen" var="aktwalze" value="#{walzenliste}"
       styleClass="listtable" headerClass="listtablehead"
       rowClasses="oddrow,evenrow">
       <t:column styleClass="colCenter" style="width:5%;">
       <h:selectBooleanCheckbox value="#{walzenSelection[aktwalze]}" />
       </t:column>
       <t:column styleClass="colCenter" style="width:5%;">
       <h:commandLink id="aendern" value="#{aktwalze.id}"
       action="#{walzeedit.aendern}" />
       </t:column>
       <t:column styleClass="colLeft" style="width:10%;">
       <h:outputLabel value="#{aktwalze.hydronummer}" />
       </t:column>
      .
      .
      


      Edit JSP:
      .
      .
       <table>
       <tr>
       <td style="width: 23%;"><h:outputLabel value="Walze : " /></td>
       <td style="width: 23%;"><h:outputLabel value="#{editWalze.id}" />
       </td>
       <td style="width: 4%;"></td>
       <td style="width: 24%;"></td>
       <td style="width: 24%;"></td>
       </tr>
       <tr>
       <td style="width: 24%;"><h:outputLabel value="Hydronummer" /></td>
       <td style="width: 24%;"><h:inputText
       value="#{editWalze.hydronummer}" size="20" maxlength="20"
       id="hydroNummer" /></td>
      .
      .
      



      Can anybody help me?

      If I set the required-Attribute of the Out-Parameter, the error disappears, but I can see the Outjected walze on the debugpage in a conversation-Context.

      What am I doing wrong? Can anybody help me?

      Thanks in advance

      Stefan

        • 1. Re: Outjection Problem
          sws42

          I haven't got the "contextual components" right.

          If I read the documentation, it tells me that a SLSB (Seam Component, because annotated with @Name) is being put in the stateless context. A non-Seam Component is being put in the context which I annotated with @Out (scope=...), eg the EVENT-Context, or alternatively in the context to which the parent component belongs. The EVENT-Context should be flushed after the request. So all components in this context have to be deleted.
          So, I've created a SLSB, which outjects a LinkedList into the EVENT-Context. This LinkedList represents my menu, which is read from the database. So I would think, if I refresh my page the menu has to be assembled once again, since the old request has ended, and a new one has to look for my menu-component, using it's @Factory-method to create it once again. But my page shows the doubled menu. Where does this data come from?
          I could "null" my LinkedList before I fill it again, but then I'm far from understanding what the contexts are "doing".

          My Problem described in the entry above belongs to the same "unknowing".
          I populate a DataModel on a page, every entry has a link to a page for editing the entry. The actionmethod behind this link starts a long running conversation. So I think that I can simply outject the DataModelSelection into the started long running conversation and Inject it into the component responsible for editing, which is also conversation scoped. But there it won't be found. If I look onto the debugpage, I find it!

          After editing, the "Save"-actionmethod should end the conversation.

          Can anybody tell me what I have missed?