3

Our team is upgrading Webapplication from Myfaces-1.1.5 to Myfaces-2.1.9 and from Tomahawk-1.1.3 to Tomahawk-1.1.14. Before this upgrade we were using ajax4jsf-1.0.6, after upgrade we are using richfaces-impl-jsf2-3.3.4. The problem is we are not able to render the next page using the following h:commandLink(with action as outboundProfileForm) in an .xhtml file. When we click on this commandLink, instead of next page the current page gets rendered again. No exception in logs. Could you please guide us or give some directions how to move forward. Many thanks in advance.

    <h:column>
            <f:facet name="header">
                <h:panelGroup>
                    <h:commandLink action="#{outboundProfileList.sortTable}"
                        value="#{text['outboundProfileLabel.name']}">
                        <f:param name="sortColumn" value="name" />
                    </h:commandLink>
                    <h:graphicImage value="#{outboundProfileList.model.sortAscending ? '/images/arrowUp.GIF' : '/images/arrowDown.GIF'}"
                            rendered="#{outboundProfileList.model.sortColumn=='name'}" />
                </h:panelGroup>
            </f:facet>
            <h:commandLink action="#{outboundProfileForm.edit}"
                value="#{outboundProfile.name}">
                <f:param name="passedId" value="#{outboundProfile.id}" />
                <f:param name="from" value="list" />
            </h:commandLink>
        </h:column>

Web.xml is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_3_0.xsd">

    <display-name>e-Messaging</display-name>
    <distributable/>

    <!-- precompiled jsp mappings -->

    <!-- Define the default CSS Theme -->
    <context-param>
        <param-name>csstheme</param-name>
        <param-value>group1</param-value>
    </context-param>
    <!-- Define the basename for a resource bundle for I18N -->
    <context-param>
        <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
        <param-value>ApplicationResources</param-value>
    </context-param>
    <!-- Fallback locale if no bundles found for browser's preferred locale -->
    <!-- Force a single locale using param-name 'javax.servlet.jsp.jstl.fmt.locale' -->
    <context-param>
        <param-name>javax.servlet.jsp.jstl.fmt.fallbackLocale</param-name>
        <param-value>en</param-value>
    </context-param>
    <!-- Context Configuration locations for Spring XML files -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath*:/applicationContext-resources.xml
            classpath*:/applicationContext-dao.xml
            classpath*:/applicationContext-service.xml
            classpath*:/applicationContext-monitoring.xml
            classpath*:/applicationContext-inbound.xml
            classpath*:/applicationContext-config.xml
            classpath*:/applicationContext-outbound.xml
            classpath*:/applicationContext.xml
            /WEB-INF/security.xml
            /WEB-INF/applicationContext.xml
            /WEB-INF/cxf.xml
            classpath*:/applicationContext-agent.xml
            classpath*:/applicationContext-ext.xml
        </param-value>
    </context-param>
    <context-param>  
     <param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>  
     <param-value>true</param-value>  
</context-param> 
    <context-param>
        <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
        <!--<param-value>org.ajax4jsf.application.</param-value> -->
        <!--<param-value>org.apache.myfaces.view.facelets.FaceletViewHandler</param-value> -->  
        <param-value>com.g1.emessaging.ui.EmsgFaceletViewHandler</param-value>      
    </context-param>  
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Production</param-value>
    </context-param>
    <context-param>
        <param-name>faces.PROJECT_STAGE</param-name>
        <param-value>Production</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
    </context-param>
    <context-param>
        <param-name>facelets.VIEW_MAPPINGS</param-name>
        <param-value>*.xhtml</param-value>
    </context-param> 
    <context-param>
        <param-name>facelets.DEVELOPMENT</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>facelets.REFRESH_PERIOD</param-name>
        <param-value>-1</param-value>
    </context-param>
    <context-param>  
        <param-name>org.ajax4jsf.RESOURCE_URI_PREFIX</param-name>  
        <param-value>a4j_resource</param-value>  
    </context-param>  
    <context-param>
       <param-name>org.richfaces.SKIN</param-name>
       <param-value>blueSky</param-value>
    </context-param>

    <context-param>
      <param-name>org.richfaces.CONTROL_SKINNING</param-name>
      <param-value>disable</param-value>
    </context-param>
        <context-param>
      <param-name>org.richfaces.CONTROL_SKINNING_CLASSES</param-name>
      <param-value>disable</param-value>
    </context-param>


    <context-param>
        <param-name>facelets.LIBRARIES</param-name>
        <param-value>
<!--            /WEB-INF/taglibs/corejsf-validator.taglib.xml; -->
            /WEB-INF/taglibs/tomahawk.taglib.xml;
            /WEB-INF/taglibs/emessaging.taglib.xml;
    /WEB-INF/taglibs/jsf-core.taglib.xml;
    /WEB-INF/taglibs/jsf-html.taglib.xml;
    /WEB-INF/taglibs/jsf-ui.taglib.xml;
    /WEB-INF/taglibs/jstl-core.taglib.xml;
    /WEB-INF/taglibs/jstl-fn.taglib.xml
        </param-value>
    </context-param>
    <context-param>
        <param-name>configPath</param-name>
        <param-value>/WEB-INF/classes</param-value>
    </context-param>    
    <context-param>
        <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
        <param-value>false</param-value>
     </context-param>

     <filter>
        <filter-name>ajax4jsf</filter-name>
        <filter-class>org.ajax4jsf.Filter</filter-class>
    </filter>
 <!--   <filter>
        <filter-name>cacheFilter</filter-name>
        <filter-class>com.opensymphony.oscache.web.filter.CacheFilter</filter-class>
    </filter> -->
    <filter>
        <filter-name>clickstreamFilter</filter-name>
        <filter-class>com.opensymphony.clickstream.ClickstreamFilter</filter-class>
    </filter>
    <filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>

    <filter>
        <filter-name>extensionsFilter</filter-name>
        <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
    </filter>
    <filter>
        <filter-name>gzipFilter</filter-name>
        <filter-class>net.sf.ehcache.constructs.web.filter.GzipFilter</filter-class>
    </filter>
    <!-- Remove this filter if you're using iBATIS, use OpenEntityManagerInViewFilter if using JPA -->
    <filter>
        <filter-name>lazyLoadingFilter</filter-name>
        <filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
        <!--<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>-->
    </filter>
    <!--
    <filter>
        <filter-name>localeFilter</filter-name>
        <filter-class>org.appfuse.webapp.filter.LocaleFilter</filter-class>
    </filter>
    -->
    <filter>
        <filter-name>messageFilter</filter-name>
        <filter-class>org.appfuse.webapp.filter.MessageFilter</filter-class>
    </filter>
    <filter>
        <filter-name>rewriteFilter</filter-name>
        <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
        <init-param>
            <param-name>logLevel</param-name>
            <param-value>log4j</param-value>
        </init-param>
    </filter>
   <!-- <filter>
        <filter-name>securityFilter</filter-name>
        <filter-class>org.acegisecurity.util.FilterToBeanProxy</filter-class>
        <init-param>
            <param-name>targetClass</param-name>
            <param-value>org.acegisecurity.util.FilterChainProxy</param-value>
        </init-param>
    </filter> -->
    <filter>
        <filter-name>securityFilterChain</filter-name>
        <filter-class>
            org.springframework.web.filter.DelegatingFilterProxy
        </filter-class>
    </filter>
    <filter>
        <filter-name>sitemesh</filter-name>
    <!--    <filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class> -->
    <filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>

    </filter>
    <!-- JavaScriptDetector Filter -->
    <filter>
        <filter-name>javascriptDetector</filter-name>
        <filter-class>
            com.g1.emessaging.webapp.filter.JavaScriptDetectorFilter
        </filter-class>
    </filter>

    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>javascriptDetector</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>securityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>extensionsFilter</filter-name>
        <servlet-name>faces</servlet-name>
    </filter-mapping>
    <filter-mapping>
        <filter-name>extensionsFilter</filter-name>
        <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>ajax4jsf</filter-name>
        <servlet-name>faces</servlet-name>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping> 
    <!-- Commented out for 2 reasons: 1) it's a pain when developing JSPs, and
                                      2) it causes the Signup webtest to fail -->
    <!--filter-mapping>
        <filter-name>cacheFilter</filter-name>
        <url-pattern>*.jsp</url-pattern>
    </filter-mapping-->
    <filter-mapping>
        <filter-name>lazyLoadingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>clickstreamFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <!--
    <filter-mapping>
        <filter-name>localeFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    -->
    <filter-mapping>
        <filter-name>gzipFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>rewriteFilter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>
    <filter-mapping>
        <filter-name>sitemesh</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>
    <filter-mapping>
        <filter-name>messageFilter</filter-name>
        <url-pattern>*.html</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>

    <listener>
        <listener-class>com.opensymphony.clickstream.ClickstreamListener</listener-class>
    </listener>
<!--    <listener>
        <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
    </listener> -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>
    <listener>
        <listener-class>com.g1.emessaging.webapp.listener.StartupListener</listener-class>
    </listener>

    <listener>
        <listener-class>com.g1.emessaging.webapp.listener.LicenseValidationListener</listener-class>
    </listener>


    <listener>
        <listener-class>org.appfuse.webapp.listener.UserCounterListener</listener-class>
    </listener>

    <listener>
        <listener-class>net.sf.navigator.menu.MenuContextListener</listener-class>
    </listener>
    <listener>
        <listener-class>com.g1.emessaging.webapp.action.SessionListener</listener-class>
    </listener>
    <servlet>
         <servlet-name>viewPart</servlet-name>
        <servlet-class>com.g1.emessaging.webapp.action.workflow.servlet.ViewPart</servlet-class>
    </servlet>
        <!--  <init-param>
       <param-name>javax.faces.LIFECYCLE_ID</param-name>
       <param-value>InterceptingLifecycle</param-value>
      </init-param> -->
    <servlet>
      <servlet-name>faces</servlet-name>
      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
    </servlet>
   <!--
    <servlet>
        <servlet-name>faces</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet> -->

    <servlet>
        <servlet-name>dwr-invoker</servlet-name>
        <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>true</param-value>
        </init-param>
    </servlet>

    <servlet>
        <servlet-name>ReadReceiptServlet</servlet-name>
        <servlet-class>com.g1.emessaging.outbound.servlet.ReadReceiptServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>SmsServlet</servlet-name>
        <servlet-class>com.g1.emessaging.inbound.sms.SmsServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>WorkflowItemProvider</servlet-name>
        <servlet-class>com.g1.emessaging.webapp.action.workflow.servlet.WorkflowItemProvider</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>OutMessageProvider</servlet-name>
        <servlet-class>com.g1.emessaging.webapp.action.workflow.servlet.OutMessageProvider</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>FailoverServlet</servlet-name>
        <servlet-class>com.g1.emessaging.failover.servlet.FailoverServlet</servlet-class>
    </servlet>

    <servlet>
        <servlet-name>CXFServlet</servlet-name>
        <servlet-class>
            org.apache.cxf.transport.servlet.CXFServlet
        </servlet-class>
        <load-on-startup>3</load-on-startup>
    </servlet>


    <servlet-mapping>
        <servlet-name>viewPart</servlet-name>
        <url-pattern>/pages/workflow/viewPart.html</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>faces</servlet-name>
        <url-pattern>*.html</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>dwr-invoker</servlet-name>
        <url-pattern>/dwr/*</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>ReadReceiptServlet</servlet-name>
        <url-pattern>/receipt/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>SmsServlet</servlet-name>
        <url-pattern>/sms/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>WorkflowItemProvider</servlet-name>
        <url-pattern>/workflow/WorkflowItemProvider</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>OutMessageProvider</servlet-name>
        <url-pattern>/workflow/OutMessageProvider</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>FailoverServlet</servlet-name>
        <url-pattern>/failover/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>CXFServlet</servlet-name>
        <url-pattern>/resource/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>60</session-timeout>
    </session-config>

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Protect XHTML Templates</web-resource-name>
            <url-pattern>*.xhtml</url-pattern>
        </web-resource-collection>
        <auth-constraint/>
   </security-constraint>

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <error-page>
        <error-code>500</error-code>
        <location>/pages/error/genericException.jsp</location>
    </error-page>

    <error-page>
        <error-code>400</error-code>
        <location>/index.jsp</location>
    </error-page>

    <error-page>
        <error-code>403</error-code>
        <location>/PBBI403.jsp</location> <!-- SCR 69315 - get rid of appfuse picture-->
    </error-page>
    <error-page>
        <error-code>404</error-code>
        <location>/PBBI404.jsp</location> <!-- SCR 69315 - get rid of appfuse picture-->
    </error-page>

    <error-page>
        <exception-type>javax.servlet.ServletException</exception-type>
        <location>/pages/error/genericInvalidator.jsp</location>
    </error-page>

</web-app>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Command link uses JS to submit the form. Are there any errors in JS console? Are there any warnings (no errors) in server log? Do you have `` instead of `` in master template? – BalusC May 20 '15 at 08:18
  • Hi BalusC, Thanks for looking into this. Sorry for late reply, but we were trying deep debugging of myfaces code to investigate the problem before coming back to you. Our analysis is as follows, could you please have a look and please guide us. Replies to your questions are: No errors in JSConsole No errors in server logs We are using in master template. – Amit Aggarwal May 31 '15 at 18:25
  • When we click on h:commandLink in an outprofiles.xhtml file, it does not generate/set parameter with name 'javax.faces.ViewState' in servlet reuest so when control of code goes in execute() function of 'org.apache.myfaces.lifecycle.RestoreViewExecutor' class of myfaces, it looks for this parameter to determine whether this request is postback or not. Since there is no parameter in servletRequest it considers this request as non Postback. – Amit Aggarwal May 31 '15 at 18:27
  • There is one more button h:commandButton on same .xhtml file, When we click on this commandbutton the parameter with name 'javax.faces.ViewState' is set and inside RestoreViewExecutor it is considered as Postback request and next page is successfully rendered.Could you please confirm in JSF 2.1(Myfaces), should 'javax.faces.ViewState' be set on clicking h:commandLink. Should the request generated from h:commandLink should be treated as Postback or not in JSF 2.1 – Amit Aggarwal May 31 '15 at 18:28
  • 3
    Resolved :-) of myfaces 2.1.9 is not generating javascript properly while clicking on it and also not sending javax.facex.ViewState parameter in servlet request. RestoreViewExecuter class of myfaces-impl-2.1.9 jar checks whether it is a post back request or not on the basis of parameter “javax.facex.ViewState” and if parameter is not found then the same view is rendered. After doing a lot of debugging and analysis we used tomahawk tag for command link “ “ which is working fine because it is generating javascript and javax.faces.ViewState properly. – Amit Aggarwal Jun 04 '15 at 11:59
  • 1
    MyFaces 2.1.9 is relatively old (almost 3 years). Consider picking the latest. 3 years leaves pretty a lot of room for potential bugfixes. – BalusC Jun 04 '15 at 15:28
  • Worked for me too. Thanks Amit. – Madhu V Rao Sep 11 '15 at 05:31

0 Answers0