12 Replies Latest reply on Nov 4, 2006 2:04 PM by gavin.king

    jboss seam @Datamodel

    ypasmk

      I want to outject an ArryList so I have this in my ejb

      @DataModel
      private List<myEntity> ents=new ArrayList<myEntity>();
      


      and this code in my jsf page

      
      
      <h:dataTable value="#{listAgents}" var="report">
      ....#{report.id}
      </h:dataTable>
      
      


      and it's working..But myEntity has an ArrayList component inside it which is mapped as OneToMany like this


      @Entity
      public class myEntity{
      
      ....
      private List<otherEntity> other;
      
      
      @OneToMany
      public List<otherEntity getOther() {
      ....
      }
      
      }
      
      


      so my question is how can I outject like myObject.getOther().get(0).getName(); in my jsf pages?

        • 1. Re: jboss seam @Datamodel
          pmuir

          You can use a datatable/ui:repeat etc. on a plain list. You just don't get @DataModelSelection.

          • 2. Re: jboss seam @Datamodel

            Hello Peter,
            Is there a way of getting DataModelSelection working with this i.e a DataTable within another DataTable ??

            Regards,
            Jankee Yogesh
            http://www.m-itc.net

            • 3. Re: jboss seam @Datamodel
              pmuir

              AFAIK no. To use @DataModelSelection you must outject a JSF DataModel (@DataModel wraps your List in a DataModel automagically). I suspect you could do it manually but it would take some playing with Seam/JSF.

              • 4. Re: jboss seam @Datamodel
                bpatters

                I got rid of all my code that used @datamodelselection in favor
                of using the parameter seam 1.1 supports.

                Now I use:

                <h:dataTable var="i" value="#{datalist}">
                 <h:column>
                 <h:commandButton action="#{dataManager.selectItem(i)}" value="select #{i.name}"/>
                 </h:column
                </h:dataTable>


                This works really well, especially if you have nested tables, you can pass
                the current table row selection into the function as multiple parameters
                using:
                <h:dataTable var="i" value="#{datalist}">
                 <h:column>
                 <h:dataTable var="j" value="#{i.subdatalist}">
                 <h:column>
                 <h:commandButton action="#{dataManager.select
                SubItem(i,j)}" value="select #{j.name}"/>
                 </h:column
                 </h:dataTable>
                 </h:column
                </h:dataTable>


                Of course this requires you to use Facelets and seam 1.1 with the seam FaceletViewHandler, but it REALLY simplifies things alot.

                • 5. Re: jboss seam @Datamodel
                  pmuir

                  Nice. You should put that on the wiki as a tip :)

                  • 6. Re: jboss seam @Datamodel

                    That rocks. Now I will have to switch to seam 1.1 I have been dying to nest tables and it was unclear to me how to do so with datamodel selection. A wiki tip would be most helpful.

                    • 7. Re: jboss seam @Datamodel
                      bpatters

                       

                      "supernovasoftware.com" wrote:
                      That rocks. Now I will have to switch to seam 1.1 I have been dying to nest tables and it was unclear to me how to do so with datamodel selection. A wiki tip would be most helpful.


                      I'll write something up once I get home and have access to my code etc. The above is how I did it last night from memory. I too was having problem figuring out how to @DataModelSelection with nested tables, when I figured I'd just use this technique. The whole selected item being injected from a model thing is hard for me to get my mind around in complex scenarios, but the pass this occurrence of the iteration as a parameter is very easy for me to fit into my way of thinking :)



                      • 8. Re: jboss seam @Datamodel
                        iradix

                        That really is cool. It makes you wonder what the JSF spec leads were thinking to not allow action parameters in the first place.

                        • 9. Re: jboss seam @Datamodel
                          gavin.king

                          In this case it is the fault of the JSP spec group. (JSTL-EL)

                          • 10. Re: jboss seam @Datamodel

                            I've been using the selectionIs there any additional benefits if you use @DataModel vs. "direct" selection through parameter?
                            Simply put, is @DataModel deprecated?

                            • 11. Re: jboss seam @Datamodel

                              Eh, maybe i meant to ask that is @DataModelSelection deprecated/unneeded.

                              • 12. Re: jboss seam @Datamodel
                                gavin.king

                                No it is not deprecated.