Announcement Announcement Module
Collapse
No announcement yet.
Webflow + Primefaces + Lazy Load - Issue?? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Webflow + Primefaces + Lazy Load - Issue??

    SPRING 3.0.5 - WEBFLOW 2.3.0 - PRIMEFACES 2.2.1 - (Running on GAE 1.4.2)

    Hi,

    I am pretty new to both Spring & Primefaces, and at the moment, can't work out where the issue I'm having lies - so apologies in advance if this is a PF issue!

    The scenario, a basic example to illustrate the issue, is that I have a form, where I have a button to trigger a transition, and then lazy load another button, to trigger another transition:

    Code:
    <ui:define name="content">
    		
    		<h:form>
    		
    			<p:outputPanel id="panel">
    			
    				<p:commandButton value="Standard" action="testnormal" />
    	
    				<p:commandButton value="LazyLoaded" action="testlazyload" 
    					rendered="#{requestScope.renderLazy}" />
    				
    				<p:commandButton value="LazyLoad" update="panel">
    					<f:setPropertyActionListener 
    						target="#{requestScope.renderLazy}" value="#{true}" />
    				</p:commandButton>
    					
    			</p:outputPanel>
    		
    		</h:form>
    		
    	</ui:define>

    The 'Standard' button triggers the transition as expected, the 'LazyLoad' button, does the lazy load, but the lazy loaded 'LazyLoaded' button does not trigger the transition?

    The flow is:
    Code:
    	<view-state id="start">
    
    		<transition on="testnormal" to="continue" />
    		<transition on="testlazyload" to="continue" />
    
    	</view-state>
    
    	<view-state id="continue">
    		<transition on="done" to="finish" />
    	</view-state>
    	
    	<end-state id="finish" view="externalRedirect:contextRelative:/a/process/test"/>
    When the 'Standard' button is pressed, the (important part of the) log shows:
    Code:
    12:08:42,723 DEBUG  -  Entering JSF Phase: INVOKE_APPLICATION 5
    12:08:42,723 DEBUG  -  Processing application
    12:08:42,725 DEBUG  -  Invoking action [email protected]f9
    12:08:42,725 DEBUG  -  Event 'testnormal' detected
    12:08:42,725 DEBUG  -  Event 'testnormal' returned from view [JSFView = '/WEB-INF/classes/web/process/test/start.xhtml']
    12:08:42,725 DEBUG  -  Executing [Transition@1a6e654 on = testnormal, to = continue]
    12:08:42,725 DEBUG  -  Exiting state 'start'
    12:08:42,725 DEBUG  -  Saving view root '/WEB-INF/classes/web/process/test/start.xhtml' in view scope
    12:08:42,726 DEBUG  -  Entering state 'continue' of flow 'process/test'
    12:08:42,726 DEBUG  -  Assigned key e1s2
    12:08:42,726 DEBUG  -  Completed transition execution.  As a result, the new state is 'continue' in flow 'process/test'
    12:08:42,726 DEBUG  -  Putting flow execution '[FlowExecutionImpl@1f08e8b flow = 'process/test', flowSessions = list[[FlowSessionImpl@7858ab flow = 'process/test', state = 'continue', scope = map['viewScope' -> map[[empty]]]]]]' into repository
    12:08:42,726 DEBUG  -  Adding snapshot to group with id 2
    12:08:42,726 DEBUG  -  Putting conversation attribute 'scope' with value map['flashScope' -> map['messagesMemento' -> map[[null] -> list[[empty]]], 'flowRenderResponse' -> true]]
    12:08:42,727 DEBUG  -  Unlocking conversation 1
    12:08:42,727 DEBUG  -  Sending flow execution redirect to '/a/process/test?execution=e1s2'
    12:08:42,728 DEBUG  -  Null ModelAndView returned to DispatcherServlet with name 'MVC_Dispatcher': assuming HandlerAdapter completed request handling
    12:08:42,728 DEBUG  -  Successfully completed request
    12:08:42,728 DEBUG  -  Chain processed normally
    But when the 'LazyLoaded' button is pressed, it shows:
    Code:
    12:12:19,626 DEBUG  -  Entering JSF Phase: INVOKE_APPLICATION 5
    12:12:19,626 DEBUG  -  Processing application
    12:12:19,626 DEBUG  -  Rendering + [JSFView = '/WEB-INF/classes/web/process/test/start.xhtml']
    12:12:19,626 DEBUG  -    Flash scope = map[[empty]]
    12:12:19,626 DEBUG  -    Messages = [DefaultMessageContext@1f62688 sourceMessages = map[[null] -> list[[empty]]]]
    12:12:19,626 DEBUG  -  Asking faces lifecycle to render
    12:12:19,627 DEBUG  -  Entering JSF Phase: RENDER_RESPONSE 6
    12:12:19,627 DEBUG  -  Saving view root '/WEB-INF/classes/web/process/test/start.xhtml' in view scope
    12:12:19,627 DEBUG  -  Saving view root '/WEB-INF/classes/web/process/test/start.xhtml' in view scope
    12:12:19,627 DEBUG  -  View rendering complete
    12:12:19,628 DEBUG  -  Putting flow execution '[FlowExecutionImpl@15bc55e flow = 'process/test', flowSessions = list[[FlowSessionImpl@1fad24e flow = 'process/test', state = 'start', scope = map['viewScope' -> map['flowSerializedViewState' -> [FlowSerializedView@53644 viewId = '/WEB-INF/classes/web/process/test/start.xhtml']]]]]]' into repository
    12:12:19,628 DEBUG  -  Adding snapshot to group with id 1
    12:12:19,628 DEBUG  -  Putting conversation attribute 'scope' with value map['flashScope' -> map['messagesMemento' -> map[[empty]]]]
    12:12:19,628 DEBUG  -  Unlocking conversation 2
    12:12:19,628 DEBUG  -  Null ModelAndView returned to DispatcherServlet with name 'MVC_Dispatcher': assuming HandlerAdapter completed request handling
    12:12:19,628 DEBUG  -  Successfully completed request
    12:12:19,628 DEBUG  -  Chain processed normally
    Apparently NOT detecting the EVENT ?????

    Looking at the produced HTML, there appears to be NO difference between the code generated for each button:
    Code:
    <span id="j_idt11:panel">
    
    <button id="j_idt11:j_idt12" name="j_idt11:j_idt12" onclick="PrimeFaces.ajax.AjaxRequest('/a/process/test?execution=e2s1',
    {formId:'j_idt11',async:false,global:true,source:'j_idt11:j_idt12',process:'@all'});return false;" type="submit" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">Standard</span></button>
    
    <button id="j_idt11:j_idt13" name="j_idt11:j_idt13" onclick="PrimeFaces.ajax.AjaxRequest('/a/process/test?execution=e2s1',
    {formId:'j_idt11',async:false,global:true,source:'j_idt11:j_idt13',process:'@all'});return false;" type="submit" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">LazyLoaded</span></button>
    
    <button id="j_idt11:j_idt14" name="j_idt11:j_idt14" onclick="PrimeFaces.ajax.AjaxRequest('/a/process/test?execution=e2s1',
    {formId:'j_idt11',async:false,global:true,source:'j_idt11:j_idt14',process:'@all',update:'j_idt11:panel'});return false;" type="submit" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">LazyLoad</span></button>
    
    </span>
    As you can see from the "id's" above, this isn't a nested form issue!

    Checking the browser side network traffic, the 'Lazy Loaded' button produces the following:
    Code:
    POST HEADER
    Request URL:http://127.0.0.1:8888/a/process/test?execution=e3s1
    Request Method:POST
    Status Code:200 OK
    Request Headers
    Accept:application/xml, text/xml, */*; q=0.01
    Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
    Accept-Encoding:gzip,deflate,sdch
    Accept-Language:en-GB,en-US;q=0.8,en;q=0.6
    Connection:keep-alive
    Content-Length:213
    Content-Type:application/x-www-form-urlencoded
    Cookie:JSESSIONID=kf4u18ge29aj
    Faces-Request:partial/ajax
    Host:127.0.0.1:8888
    Origin:http://127.0.0.1:8888
    Referer:http://127.0.0.1:8888/a/process/test?execution=e3s1
    User-Agent:Mozilla/5.0 (Windows NT 6.0) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.14 Safari/534.24
    X-Requested-With:XMLHttpRequest
    Query String Parameters
    execution:e3s1
    Form Data
    j_idt11:j_idt11
    javax.faces.ViewState:e3s1
    javax.faces.partial.ajax:true
    javax.faces.source:j_idt11:j_idt14
    javax.faces.partial.execute:@all
    javax.faces.partial.render:j_idt11:panel
    j_idt11:j_idt14:j_idt11:j_idt14
    Response Headers
    Cache-Control:no-cache
    no-store
    no-cache
    Content-Length:1388
    Content-Type:text/xml; charset=utf-8
    Expires:Thu, 01 Jan 1970 00:00:00 GMT
    Pragma:no-cache
    Server:Jetty(6.1.x)
    X-Powered-By:JSF/2.0
    
    RETURNED CONTENT
    <?xml version='1.0' encoding='UTF-8'?>
    <partial-response><changes><update id="j_idt11:panel"><![CDATA[<span id="j_idt11:panel"><button id="j_idt11:j_idt12" name="j_idt11:j_idt12" onclick="PrimeFaces.ajax.AjaxRequest('/a/process/test?execution=e3s1',{formId:'j_idt11',async:false,global:true,source:'j_idt11:j_idt12',process:'@all'});return false;" type="submit">Standard</button><script type="text/javascript">widget_j_idt11_j_idt12 = new PrimeFaces.widget.CommandButton('j_idt11:j_idt12', {});</script><button id="j_idt11:j_idt13" name="j_idt11:j_idt13" onclick="PrimeFaces.ajax.AjaxRequest('/a/process/test?execution=e3s1',{formId:'j_idt11',async:false,global:true,source:'j_idt11:j_idt13',process:'@all'});return false;" type="submit">LazyLoaded</button><script type="text/javascript">widget_j_idt11_j_idt13 = new PrimeFaces.widget.CommandButton('j_idt11:j_idt13', {});</script><button id="j_idt11:j_idt14" name="j_idt11:j_idt14" onclick="PrimeFaces.ajax.AjaxRequest('/a/process/test?execution=e3s1',{formId:'j_idt11',async:false,global:true,source:'j_idt11:j_idt14',process:'@all',update:'j_idt11:panel'});return false;" type="submit">LazyLoad</button><script type="text/javascript">widget_j_idt11_j_idt14 = new PrimeFaces.widget.CommandButton('j_idt11:j_idt14', {});</script></span>]]></update><update id="javax.faces.ViewState"><![CDATA[e3s1]]></update></changes></partial-response>

    I really now pulling my hair out with this, (I didn't have much to start with) - Can anybody see what's wrong???

    I am assuming this should work?!?

    If there is any other part of the config wanted, please let me know.

    Thanks in advance

    Dave

  • #2
    In an attempt to glean more information about what is going on, I have made a couple of changes to make this 'partial updates':

    The flow:
    Code:
    	<view-state id="start">
    
    		<transition on="testnormal">
    			<evaluate expression="testBean.updateGrowl()" />
    		</transition>
    		
    		<transition on="testlazyload">
    			<evaluate expression="testBean.updateGrowl()" />
    		</transition>
    
    	</view-state>

    The .xhtml (I have the GROWL in the template!)
    Code:
    	<ui:define name="content">
    		
    		<h:form>
    		
    			<p:outputPanel id="panel">
    			
    				<p:commandButton value="Standard" action="testnormal" update="growl"/>
    	
    				<p:commandButton value="LazyLoaded" action="testlazyload" update="growl" 
    					rendered="#{requestScope.renderLazy}" />
    				
    				<p:commandButton value="LazyLoad" update="panel">
    					<f:setPropertyActionListener 
    						target="#{requestScope.renderLazy}" value="#{true}" />
    				</p:commandButton>
    					
    			</p:outputPanel>
    		
    		</h:form>
    		
    	</ui:define>
    The result is that I get the GROWL message with the 'Standard' button, but not with the 'LazyLoaded' button????

    The 'Standard' button log:
    Code:
    13:02:44,733 DEBUG  -  Entering JSF Phase: INVOKE_APPLICATION 5
    13:02:44,733 DEBUG  -  Processing application
    13:02:44,734 DEBUG  -  Invoking action [email protected]f9
    13:02:44,734 DEBUG  -  Event 'testnormal' detected
    13:02:44,734 DEBUG  -  Event 'testnormal' returned from view [JSFView = '/WEB-INF/classes/web/process/test/start.xhtml']
    13:02:44,734 DEBUG  -  Executing [EvaluateAction@18ec6f5 expression = testBean.updateGrowl(), resultExpression = [null]]
    13:02:44,735 DEBUG  -  Putting action execution attributes map[[empty]]
    13:02:44,735 DEBUG  -  Returning cached instance of singleton bean 'testBean'
    13:02:44,735 DEBUG  -  Resolving message using [FlowFacesContextMessageDelegate.FlowFacesMessageAdapter@f1eeb1 severity = INFO, text = 'Growl Message']
    13:02:44,735 DEBUG  -  Adding resolved message [FlowFacesContextMessageDelegate.FlowFacesMessageAdapter@f1eeb1 severity = INFO, text = 'Growl Message']
    13:02:44,735 DEBUG  -  Resolving message using [FlowFacesContextMessageDelegate.FlowFacesMessageAdapter@17fb6e8 severity = INFO, text = 'Event fired']
    13:02:44,735 DEBUG  -  Adding resolved message [FlowFacesContextMessageDelegate.FlowFacesMessageAdapter@17fb6e8 severity = INFO, text = 'Event fired']
    13:02:44,735 DEBUG  -  Clearing action execution attributes map[[empty]]
    13:02:44,735 DEBUG  -  Finished executing [EvaluateAction@18ec6f5 expression = testBean.updateGrowl(), resultExpression = [null]]; result = success
    13:02:44,735 DEBUG  -  Executing [Transition@1378df4 on = testnormal, to = [null]]
    13:02:44,735 DEBUG  -  Rendering + [JSFView = '/WEB-INF/classes/web/process/test/start.xhtml']
    13:02:44,735 DEBUG  -    Flash scope = map['flowRenderResponse' -> true]
    13:02:44,735 DEBUG  -    Messages = [DefaultMessageContext@1f66488 sourceMessages = map[[null] -> list[[empty]], 'null_summary' -> list[[FlowFacesContextMessageDelegate.FlowFacesMessageAdapter@f1eeb1 severity = INFO, text = 'Growl Message']], 'null_detail' -> list[[FlowFacesContextMessageDelegate.FlowFacesMessageAdapter@17fb6e8 severity = INFO, text = 'Event fired']]]]
    13:02:44,735 DEBUG  -  Asking faces lifecycle to render
    13:02:44,736 DEBUG  -  Entering JSF Phase: RENDER_RESPONSE 6
    The 'LazyLoaded' log:
    Code:
    13:03:53,709 DEBUG  -  Entering JSF Phase: INVOKE_APPLICATION 5
    13:03:53,709 DEBUG  -  Processing application
    13:03:53,709 DEBUG  -  Rendering + [JSFView = '/WEB-INF/classes/web/process/test/start.xhtml']
    13:03:53,709 DEBUG  -    Flash scope = map[[empty]]
    13:03:53,709 DEBUG  -    Messages = [DefaultMessageContext@b69eca sourceMessages = map[[null] -> list[[empty]]]]
    13:03:53,709 DEBUG  -  Asking faces lifecycle to render
    13:03:53,709 DEBUG  -  Entering JSF Phase: RENDER_RESPONSE 6

    The 'Standard' Network traffic:
    Code:
    HEADER
    Request URL:http://127.0.0.1:8888/a/process/test?execution=e1s1
    Request Method:POST
    Status Code:200 OK
    ...
    Connection:keep-alive
    Content-Length:205
    Content-Type:application/x-www-form-urlencoded
    Cookie:JSESSIONID=3vqv43nkdk7z
    Faces-Request:partial/ajax
    Host:127.0.0.1:8888
    ...
    X-Requested-With:XMLHttpRequest
    Query String Parameters
    execution:e1s1
    Form Data
    j_idt11:j_idt11
    javax.faces.ViewState:e1s1
    javax.faces.partial.ajax:true
    javax.faces.source:j_idt11:j_idt12
    javax.faces.partial.execute:@all
    javax.faces.partial.render:growl
    j_idt11:j_idt12:j_idt11:j_idt12
    Response Headers
    ...
    
    CONTENT
    <?xml version='1.0' encoding='UTF-8'?>
    <partial-response><changes><update id="growl"><![CDATA[<span id="growl"></span><script type="text/javascript">jQuery(function(){jQuery.gritter.add({title:'Growl Message',text:'Event fired',image:'/a/javax.faces.resource/growl/assets/info.png?ln=primefaces&amp;v=2.2.1',sticky:false,time:5000});});</script>]]></update><update id="javax.faces.ViewState"><![CDATA[e1s1]]></update></changes></partial-response>
    The 'LazyLoaded' Network traffic:
    Code:
    HEADER
    Request URL:http://127.0.0.1:8888/a/process/test?execution=e1s1
    Request Method:POST
    Status Code:200 OK
    ...
    Connection:keep-alive
    Content-Length:205
    Content-Type:application/x-www-form-urlencoded
    Cookie:JSESSIONID=3vqv43nkdk7z
    Faces-Request:partial/ajax
    Host:127.0.0.1:8888
    ...
    X-Requested-With:XMLHttpRequest
    Query String Parameters
    execution:e1s1
    Form Data
    j_idt11:j_idt11
    javax.faces.ViewState:e1s1
    javax.faces.partial.ajax:true
    javax.faces.source:j_idt11:j_idt13
    javax.faces.partial.execute:@all
    javax.faces.partial.render:growl
    j_idt11:j_idt13:j_idt11:j_idt13
    Response Headers
    ...
    
    CONTENT
    <?xml version='1.0' encoding='UTF-8'?>
    <partial-response><changes><update id="growl"><![CDATA[<span id="growl"></span><script type="text/javascript">jQuery(function(){});</script>]]></update><update id="javax.faces.ViewState"><![CDATA[e1s1]]></update></changes></partial-response>
    and finally, the HTML that was produced:
    Code:
    <form id="j_idt11" name="j_idt11" method="post" action="/a/process/test?execution=e1s1" enctype="application/x-www-form-urlencoded">
    <input type="hidden" name="j_idt11" value="j_idt11">
    
    <span id="j_idt11:panel">
    
    <button id="j_idt11:j_idt12" name="j_idt11:j_idt12" onclick="PrimeFaces.ajax.AjaxRequest('/a/process/test?execution=e1s1',
    {formId:'j_idt11',async:false,global:true,source:'j_idt11:j_idt12',process:'@all',update:'growl'});return false;" type="submit" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">Standard</span></button>
    
    <button id="j_idt11:j_idt13" name="j_idt11:j_idt13" onclick="PrimeFaces.ajax.AjaxRequest('/a/process/test?execution=e1s1',
    {formId:'j_idt11',async:false,global:true,source:'j_idt11:j_idt13',process:'@all',update:'growl'});return false;" type="submit" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">LazyLoaded</span></button>
    
    <button id="j_idt11:j_idt14" name="j_idt11:j_idt14" onclick="PrimeFaces.ajax.AjaxRequest('/a/process/test?execution=e1s1',{formId:'j_idt11',async:false,global:true,source:'j_idt11:j_idt14',process:'@all',update:'j_idt11:panel'});return false;" type="submit" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">LazyLoad</span></button>
    
    </span><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="e1s1">
    </form>
    So again, no obvious difference, but the 'Standard' button works, the 'LazyLoaded' button doesn't????

    Hope that helps!

    Cheers

    Dave
    Last edited by davewilliamson; Mar 20th, 2011, 09:29 AM.

    Comment


    • #3
      Taking another look at the stuff above, I assume Webflow maps the post request param:

      javax.faces.source:j_idt11:j_idt12 -> <transition on="testnormal">

      further assumption is that either WebFlow or Primefaces is then failing to map:

      javax.faces.source:j_idt11:j_idt13 -> <transition on="testlazyload">

      during the process of lazyloading the component?

      If this is the case, I am assuming this is a genuine bug?

      So is this SWF or PF??

      Cheers

      Dave
      Last edited by davewilliamson; Mar 20th, 2011, 09:32 AM.

      Comment


      • #4
        Anybody got an idea, or should I raise this as an official bug?

        Comment


        • #5
          BUMP!

          Still not had any feedback on this, has anyone got any idea?

          Comment


          • #6
            I have similar issue as described above. When I dynamically render button, it is not triggering event on click. With another click, it triggers event.

            I dig little more deeper into issue and found that some how javax.faces.ViewState hidden variable generated by framework is not being passed in as request parameter. On second click, parameter is being passed in.

            Spring web flow expects to see this hidden variable(javax.faces.ViewState) to consider executing the event.

            I don't know what exactly is going on. Any ideas???

            Thanks,
            Anil.

            Comment


            • #7
              Same problem

              I'm using Spring 3.0.5 + WF 2.3.0 + MyFaces 2.0.5 and experience same problem - can't use commandLink for the reasons described in this thread. Any resolution to this?

              Comment


              • #8
                please create an issue with an example in the bugtracker. I have the same problem with another setup. This seams to be a general error and should be fixed by spring team.

                Comment


                • #9
                  I found the problem. One of the devs disabled JS in MyFaces so corresponding commandLink code was not generated. Works after enabling.

                  Comment


                  • #10
                    Can you give more detailed informations about what i'll have to enable? Because i have the same issue, but with jsf mojorra.

                    Originally posted by vedmad View Post
                    I found the problem. One of the devs disabled JS in MyFaces so corresponding commandLink code was not generated. Works after enabling.

                    Comment


                    • #11
                      In my case JS was disabled by this:
                      Code:
                      <context-param>
                      	  <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
                      	  <param-value>false</param-value>
                      </context-param>
                      Had to remove that.

                      Comment


                      • #12
                        hmm ok, don't have such an option under mojorra. Bug seams to be somewhere else.

                        I have now tried to replace mojorra with myfaces but I allways get the following error:
                        No Factories configured for this Application. This happens if the faces-initialization does not work at all

                        I then have added the listener to the web.xml file
                        <listener>
                        <listener-class>org.apache.myfaces.webapp.StartupServletCont extListener</listener-class>
                        </listener>

                        Is something else needed to rund Myfaces with Spring Webflow? Would be nice if I could verify that my bug is only apearing in Mojorra and not in MyFaces too.

                        Thanks for any support.

                        Comment


                        • #13
                          Well, MyFaces work for me. You can find detailed info on a configuration process on their site.

                          In addition you can look at generated HTML for commandLink to see if JS is generated.

                          Comment

                          Working...
                          X