3 Replies Latest reply on Dec 22, 2006 1:44 PM by lle

    Question on using @DataModelSelection & open a page in a new

    lle

      hi all,

      In our application, there's this specific use case and I am trying to use @DataModelSelection and s:link. However, I might use them incorrectly, since it doesn't work.

      I have a datatable, backed by a @DataModel list. I would like something like a clickable list example. However, the user can click anywhere on the row to select the item (not localized to one <s:link> like in the example). After the user click on the row, he can decide to click on a "show details" button to see the details screen in a new window.
      Here are my questions:
      1. For the entire row to be clickable, do I have to put <s:link> to all columns? I am currently using t:dataTable and have a javascript onclick function to highlight the selected row. However, I am not sure how can I make a call to the server when a user clicks anywhere on the row instead of a link in a column. Do you know any good solution?

      2. When a user click on the row with no call yet made to the server, and then the user clicks on the "show details" link (which is an <s:link>), I would like to start a new conversation in a new window. How can I achieve the new page to be rendered in a new window?

      3. I also would like to start the conversation with explicit conversation id = selected_item.id. However, I got the following error:

      2006.12.21 10:34:33,974 WARN [Interpolator] exception interpolating string: #{selectedSession.id}
      javax.faces.el.EvaluationException: Cannot get value for expression '#{selectedSession.id}'
       at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:405)
       at org.jboss.seam.core.Expressions$1.getValue(Expressions.java:51)
       at org.jboss.seam.core.Interpolator.interpolateExpressions(Interpolator.java:83)
       at org.jboss.seam.core.Interpolator.interpolate(Interpolator.java:59)
       at org.jboss.seam.interceptors.ConversationInterceptor.redirectToExistingConversation(ConversationInterceptor.java:76)
       at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor.java:45)
       at sun.reflect.GeneratedMethodAccessor155.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.ExceptionInterceptor.handleExceptions(ExceptionInterceptor.java:38)
       at sun.reflect.GeneratedMethodAccessor153.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.intercept.RootInterceptor.createSeamInvocationContext(RootInterceptor.java:148)
       at org.jboss.seam.intercept.RootInterceptor.invokeInContexts(RootInterceptor.java:129)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:102)
       at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:144)
       at org.jboss.seam.intercept.JavaBeanInterceptor.intercept(JavaBeanInterceptor.java:79)
       at com.ga.riskapp.session.action.GAAccountDetailsAction$$EnhancerByCGLIB$$8b9fbc3e.findSessions(<generated>)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
       at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:59)
       at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:71)
       at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:98)
       at org.jboss.seam.core.Pages.callAction(Pages.java:398)
       at org.jboss.seam.jsf.AbstractSeamPhaseListener.callPageActions(AbstractSeamPhaseListener.java:253)
       at org.jboss.seam.jsf.AbstractSeamPhaseListener.beforeRender(AbstractSeamPhaseListener.java:201)
       at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:51)
       at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersBefore(PhaseListenerManager.java:73)
       at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:126)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:140)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invokeDoFilter(TrinidadFilterImpl.java:326)
       at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:290)
       at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:213)
       at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:90)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:46)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:32)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:75)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:213)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
       at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: selectedSession
       at org.jboss.seam.Component.newInstance(Component.java:1722)
       at org.jboss.seam.Component.getInstance(Component.java:1625)
       at org.jboss.seam.Component.getInstance(Component.java:1592)

      I think it is because the selected item was not yet outjected since I didn't make any call to the server when a row is clicked.
      Do you know any good approach for this use case?
      Thanks a lot.

        • 1. Re: Question on using @DataModelSelection & open a page in a
          lle

          Here are some relevant code snippet:
          main.xhtml (page with datatable and show details link):

          <ui:define name="secondNav">
          <div class="actionButtons clearfix">
          <div class="button separator"><s:link target="account" view="/account/details.xhtml" action="#{detailsearch.findSessions}" value="Account Detail" onclick="openDetailWindow();return false;" /></div
          </div>
          <div class="decorativeElement"/>
          </ui:define>
          <ui:define name="listing">
          <t:dataTable id="sessionTable" forceId="true" var="sess" value="#{alertsList}" border="0" cellpadding="0" cellspacing="0" styleClass="listView" width="100%" renderedIfEmpty="true" forceIdIndexFormula="#{sess.id}" org.apache.myfaces.dataTable.ROW_ID="#{sess.id}" rowIndexVar="rowIndex" rowOnClick="selectRow(this.id, #{rowIndex});" >
          <t:column width="20px">
          <f:facet name="header"></f:facet>
          <t:htmlTag value="span" styleClass="icon-viewed">V</t:htmlTag>
          </t:column>
          <t:column width="72px">
          <f:facet name="header">
          <a4j:commandLink action="#{alertssearch.sortRisk}" value="Risk"/>
          </f:facet>
          <t:div styleClass="#{sess.styleClass}">
          <t:htmlTag value="p">
          <h:outputText value="#{sess.risk}">
          <f:convertNumber maxFractionDigits="3"/>
          </h:outputText>
          </t:htmlTag>
          </t:div>
          </t:column>
          <t:column width="80px">
          <f:facet name="header">Account</f:facet>#{sess.account}</t:column>
          <t:column width="80px" styleClass="rightDoubleBorder">
          <f:facet name="header">Session</f:facet>#{sess.kvalue}</t:column>
          <t:columns value="#{alertssearch.sessionDisplayProperties}" var="prop" style="#{alertssearch.colStyle}">
          <f:facet name="header">#{prop.propDef.displayName}</f:facet>
          <h:outputText value="#{prop.firstParam.value}" styleClass="#{prop.styleClassForAlert}" rendered="#{not empty prop.firstParam}"/></t:columns>
          <t:column styleClass="doubleBorder">
          <f:facet name="header">Date</f:facet>
          <h:outputText value="#{sess.timestamp}">
          <f:convertDateTime pattern="MM/dd/yyyy"/>
          </h:outputText>
          </t:column>
          </t:dataTable>
          </ui:define>

          alertsearch action class:
          @Name("alertssearch")
          @Scope(ScopeType.SESSION)
          @GALoggedIn
          public class GASessionSearchAction {
          
           @In
           private Session gadb;
           @In(create=true) @Out
           private GAFilter sessionfilter;
           @In
           private GAHostAppInfo hostApp;
           @In
           private FacesMessages facesMessages;
           @Logger
           private Log log;
           @DataModel
           private List<GASession> alertsList;
           @DataModelSelection
           @Out(required=false)
           private GASession selectedSession;
          ...
          }

          detailsearch action class:
          @Name("detailsearch")
          @Scope(ScopeType.CONVERSATION)
          public class GAAccountDetailsAction {
          
           @In
           private Session gadb;
           @In
           private GAHostAppInfo hostApp;
           @In
           private FacesMessages facesMessages;
           @Logger
           private Log log;
           @DataModel
           private List<GASession> sessionList;
           @DataModelSelection
           @In @Out
           private GASession selectedSession;
          ...
          }


          Thanks a lot.

          • 2. Re: Question on using @DataModelSelection & open a page in a
            pmuir

            1) I think using h:dataTable you need to put a link in each column. In plain html you can (of course) put an onclick listener on the row. Perhaps an component set table (AFAICS trinidad can do this through a selection listener)

            2) You'll need to make a non-faces request to open a new window and start a conversation, again AFAICS s:link with a target should work, otherwise consider a page action or a @Create method

            3) There are very few use cases where an explicit id for a conversation makes sense

            • 3. Re: Question on using @DataModelSelection & open a page in a
              lle

              Thank you for your response.

              1. I think I got no other choice then put a link in each column. I'll look at Trinidad tr:table to see if there's any other way.

              2. s:link target doesn't work in my case since I need to control the look and feel of the new window. I used page action and it seems to work, but then lead to #3.

              3. A click on this link spawns a new window and starts a new conversation. When I use page action or @Create, it works fine except that if I refresh the new page, then another new conversation starts, which is bad, especially my page action depends on a row selection made from the main screen. So if I open two windows and then refresh the first one, then it is reloaded with the data of the second one since the selected row now is different. So, I think the only way to overcome this is to use explicit conversation id. However, it is broken in 1.1GA. I think Gavin fixed it in CVS. I'll download the new version. If you know any better solution then using explicit conversation Id, please let me know.

              Again, thanks a lot and happy holidays.