8 Replies Latest reply on Mar 10, 2008 7:02 AM by ranjithk

    Seam Conversational components and JSF component bindings

    ranjithk

      Hi,


      I am stuck with using a JSF component binding with a Seam component. I came across the section Conversational components and JSF component bindings in the seam reference document.


      Even though it mentions the work around I am not quite what to bind in the JSF page


      If you have suggestions please let me know. Thanks in advance.


      Regards,
      Ranjith

        • 1. Re: Seam Conversational components and JSF component bindings
          ranjithk

          I want to add onto my post. I tried the way seam document suggests i.e having a EVENT scoped Seam Grid component and a Conversation scoped seam gridEditor component but then seam throws the following error. Here sdmManager is equivalent gridEditor, sdmGrid is equivalent grid and grid refers to the actual HtmlPanelGrid
          
          javax.el.PropertyNotFoundException: 
          /html/add.xhtml @31,64 binding="#{sdmManager.sdmGrid.grid}" Target Unreachable, identifier 'sdmManager' resolved to null


          • 2. Re: Seam Conversational components and JSF component bindings
            rmcdonough

            You sound like you're having a similar problem as I was. Christian followed up with a post that explains the problem here:



            http://seamframework.org/Community/ConversationalScopeWithJavaBeans


            Ryan-

            • 3. Re: Seam Conversational components and JSF component bindings
              mail.micke

              Hi,
              I went through the same a while ago.


              For me it worked to @Out:ject the object I did the bindnig to.


              - Micke

              • 4. Re: Seam Conversational components and JSF component bindings
                ranjithk

                Thanks for your responses. I will try out the suggestions.


                Ranjith

                • 5. Re: Seam Conversational components and JSF component bindings
                  ranjithk

                  I am still not able to get it working. I am posting the code here so it might help in understanding how I am trying to use the workaround mentioned in the document. I tried to outject thesdmGrid as suggested by Micke but it did not help either



                  Binding in JSP page:
                  --------------------
                  <h:panelGrid columns="2" binding="#{sdmManager.sdmGrid.grid}">
                  </h:panelGrid>           
                  


                  SDMManager - Conversation scope component:
                  -------------------------------------------
                  @Name("sdmManager")
                  @Scope(ScopeType.CONVERSATION)
                  public class SDMManager {
                  
                       @In(required=false) 
                       private SDMGrid sdmGrid;
                  
                       public SDMGrid getSdmGrid(){
                            sdmGrid = new SDMGrid();
                           HtmlPanelGrid grid = new HtmlPanelGrid();
                           sdmGrid.setGrid(grid);
                           List<UIComponent> children = grid.getChildren();
                           
                           Collection<FieldFormatData> formats = dataManager.getFieldFormatData();
                           for(FieldFormatData format:formats){
                                HtmlOutputLabel outputLabel = new HtmlOutputLabel();
                                outputLabel.setValue(format.getShortDesr());
                  
                                children.add(outputLabel);
                           
                                HtmlInputText inputText = new HtmlInputText();
                                inputText.setSize(10);
                                inputText.setMaxlength(10);
                                System.out.println("Binding ................................... " + format.getEntityField());
                                inputText.setValueBinding("value", FacesContext.getCurrentInstance().getApplication().createValueBinding("#{entity."+format.getEntityField()+"}"));
                  
                                children.add(inputText);
                                
                           }
                  
                  }
                  


                  SDMGrid - Event Scope component
                  ----------------------------
                  @Name("sdmGrid")
                  @Scope(ScopeType.EVENT)
                  public class SDMGrid {
                       private HtmlPanelGrid grid;
                  
                       public HtmlPanelGrid getGrid() {
                            return grid;
                       }
                  
                       public void setGrid(HtmlPanelGrid grid) {
                            this.grid = grid;
                       }     
                       
                  }
                      



                  Ranjith

                  • 6. Re: Seam Conversational components and JSF component bindings
                    ranjithk

                    Hi,


                    I am still looking for a solution for this problem. Would really appreciate any help on this. Thanks


                    Ranjith

                    • 7. Re: Seam Conversational components and JSF component bindings
                      matt.drees

                      Ranjith:




                      Binding in JSP page:
                      --------------------
                      <h:panelGrid columns="2" binding="#{sdmManager.sdmGrid.grid}">
                      </h:panelGrid>           
                      



                      You're not really following what the Seam documentation is suggesting.  Your view should look more like this:


                      <h:panelGrid columns="2" binding="#{sdmGrid.grid}">
                      </h:panelGrid>           
                      


                      And your manager should look more like this:


                      @Name("sdmManager")
                      @Scope(ScopeType.CONVERSATION)
                      public class SDMManager {
                      
                           @In(create=true) 
                           private SDMGrid sdmGrid;
                      
                           public void populateGrid(){
                                // do stuff to sdmGrid.getGrid, if empty
                           }
                      
                      }
                      


                      You'd probably want to call populateGrid() in a page action.

                      • 8. Re: Seam Conversational components and JSF component bindings
                        ranjithk

                        I could get it working now. Thanks a lot Matt


                        Ranjith