1 Reply Latest reply on Jan 4, 2007 10:45 PM by John Blackmore

    Rerendering dataTable based on selectOneMenu selection

    John Blackmore Newbie

      I'm trying to reload and rerender a dataTable based on the value selected in a selectOneMenu, using Seam, JSF, Facelets, and Ajax4JSF. I also want to rejoin the conversation each time a new value is selected.

      I started out by creating something like this:

      <h:form id="projectForm">
       <h:selectOneMenu id="projects" value="#{selectedProjectId}">
       <f:selectItems value="#{projectSelectItems}"/>
       <a4j:support event="onchange"
       action="#{repository.findItems}" ajaxSingle="true"
       reRender="itemsPanel" />
       </h:selectOneMenu>
      </h:form>
      


      That worked, but the 'repository' SFSB is reinstantiated on every select, suggesting to me that I did not successfully rejoin the conversation, even though I annotated the findItems() function with @Begin(join=true). Should I use Seam Remoting? I found a thread that suggested how to do this:
      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=87016

      But, I'm having problems there too:
       <script type="text/javascript" src="seam/remoting/resource/remote.js"></script>
       <script type="text/javascript" src="seam/remoting/interface.js?repository"></script>
      
       <script type="text/javascript">
       //<![CDATA[
       function refreshItemTable(conversationId)
       {
       Seam.Remoting.getContext().setConversationId(conversationId);
       var myComponent = Seam.Component.getInstance('repository');
       myComponent.findItems();
       }
      
       // ]]>
       </script>
      ....
      <h:form id="projectForm">
       <h:selectOneMenu id="projects" value="#{selectedProjectId}">
       <f:selectItems value="#{projectSelectItems}"/>
       <a4j:support event="onchange"
       action="javascript:refreshItemTable(#{conversation.id})"
       ajaxSingle="true" reRender="itemsPanel" />
       </h:selectOneMenu>
      </h:form>
      


      This results in a EL exception:
      Caused by: javax.el.ELException: Not a Valid Method Expression: javascript:refreshItemTable(#{conversation.id})
       at com.sun.el.lang.ExpressionBuilder.createMethodExpression(ExpressionBuilder.java:217)
       at com.sun.el.ExpressionFactoryImpl.createMethodExpression(ExpressionFactoryImpl.java:63)
       at org.jboss.seam.ui.facelet.SeamExpressionFactory.createMethodExpression(SeamExpressionFactory.java:91)
       at com.sun.facelets.tag.TagAttribute.getMethodExpression(TagAttribute.java:141)
       ... 65 more
      


      The projectSelectItems component is being outjected as expected, and selectedProjectId seems to be injected as needed. The only outstanding issue seems to be rejoining the conversation.

      In an older thread, Gavin suggests using PAGE scope for a similar issue:
      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=74987&postdays=0&postorder=asc&start=0

      I tried that, then got this error:
      java.lang.IllegalArgumentException: Stateful session beans may not be bound to the PAGE context: repository
       at org.jboss.seam.Component.checkScopeForComponentType(Component.java:299)
       at org.jboss.seam.Component.<init>(Component.java:217)
       at org.jboss.seam.Component.<init>(Component.java:204)
       at org.jboss.seam.init.Initialization.addComponent(Initialization.java:742)
       at org.jboss.seam.init.Initialization.addComponents(Initialization.java:674)
       at org.jboss.seam.init.Initialization.init(Initialization.java:429)
       at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:33)
      


      What am I doing wrong? Is there a better way to do this?

      Thanks,