4 Replies Latest reply on Apr 4, 2007 1:47 PM by christian.bauer

    binding UIData and Seam

    karthikjboss

      Hi,

      From my h:dataTable in the view, I bind to the UIData declared in my Session bean using binding attribute.

      <h:dataTable var="listing" value="#{searchListing}" width="100%" rowClasses="lowerborderDashed" binding="#{listingSearchAction.listData}">

      I am getting the following exception:
      Caused by: java.lang.IllegalStateException: No conversation context active
      at org.jboss.seam.ScopeType.getContext(ScopeType.java:127)
      at org.jboss.seam.Component.setOutjectedValue(Component.java:1474)
      at org.jboss.seam.Component.outjectFields(Component.java:1410)
      at org.jboss.seam.Component.outject(Component.java:1210)
      at org.jboss.seam.interceptors.BijectionInterceptor.bijectNonreentrantComponent(BijectionInterceptor.java:87)
      at org.jboss.seam.interceptors.BijectionInterceptor.bijectComponent(BijectionInterceptor.java:58)
      at sun.reflect.GeneratedMethodAccessor5136.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
      at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
      at org.jboss.seam.interceptors.OutcomeInterceptor.interceptOutcome(OutcomeInterceptor.java:21)
      at sun.reflect.GeneratedMethodAccessor5137.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
      at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
      at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor.java:52)
      at sun.reflect.GeneratedMethodAccessor5135.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
      at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
      at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
      at sun.reflect.GeneratedMethodAccessor5134.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)


      I saw this in some other thread without a solution. Is this a bug or I m using the binding attribute wrongly.

      Any solutions / work-around for this?

        • 1. Re: binding UIData and Seam
          pmuir

          You can't use bind to conversation scoped Seam components. In fact, we would recommend not using JSF binding unless really really necessary

          • 2. Re: binding UIData and Seam
            karthikjboss

            okay, in such a case, all I need is to get the rowIndex of the DataModel in the view. If it is bound, I can use getRowIndex().

            Since I cannot use binding, is there any way I can get the RowIndex in the view?
            I do not need the DataModelSelectionIndex.
            I need the rowIndex of each row inside the dataTable.

            • 3. Re: binding UIData and Seam
              pmuir

              How about using @DataModel/@DataModelSelection, a page parameter, or even, if searchListing is an implementation of DataModel, @In(#{searchList.rowIndex}) in your backing bean

              • 4. Re: binding UIData and Seam
                christian.bauer

                You can bind it to an EVENT scoped component if you just need the index:

                 <h:dataTable value="#{wikiTextAttachments}" var="link" style="width:450px;"
                 binding="#{wikiUtil.datatable}"
                 styleClass="datatable rightBorder leftBorder topBorder bottomBorder"
                 headerClass="regularHeader alignLeft"
                 columnClasses="fivePercentColumn alignLeft, defaultColumn alignLeft"
                 rowClasses="rowOdd,rowEven"
                 cellpadding="0" cellspacing="0" border="0">
                 <h:column>
                 <f:facet name="header">Attachments:</f:facet>
                 <h:panelGrid columns="3" columnClasses="onePercentColumn alignRight, onePercentColumn alignLeft, onePercentColumn alignRight">
                 <s:span><a name="attachment#{wikiUtil.datatable.rowIndex + 1}"/></s:span>
                 <h:outputText value="# #{wikiUtil.datatable.rowIndex + 1}"/>
                 <h:graphicImage value="/themes/#{globalPrefs.themeName}/img/#{fileMetaMap[link.node.contentType].displayIcon}"
                 width="18" height="20"/>
                 </h:panelGrid>
                 </h:column>
                


                @Name("wikiUtil")
                public class WikiUtil {
                
                
                 /**
                 * Need to bind UI components to non-conversational backing beans.
                 * That this is even needed makes no sense. Why can't I call the UI components
                 * in the EL directly? Don't try #{components['id']}, it won't work.
                 */
                 private UIData datatable;
                 public UIData getDatatable() { return datatable; }
                 public void setDatatable(UIData datatable) { this.datatable = datatable; }
                
                }