title: SWF + Primefaces repeat context Path in URL and AJAX not work
body: <p>the project is developed in Spring 3, Spring web flow 2.3, Spring security 3 and Primefaces 3.2. When I use dispatcher servlet of JSF2 the view reload with AJAX perfectly and I can use tag h:link. But since I use dispatcher servlet from SWF I have started to have problem in two cases above.</p>
  
  <p>For example, when I use <em>h:link</em> tag and its attribute <em>outcome="listActivities</em>, the result is <em>href="WEB-INF/views/WEB-INF/views/listActivities.xhtml"</em>. I have could this problem using <em>h:outputlink</em> tag, because the result is href="listActivities" and I have configured SWF for to use UrlBasedViewResolver. </p>
  
  <p>In the case using AJAX then the app not working and the message is serverError: class com.sun.faces.context.FacesFileNotFoundException <strong>/WEB-INF/views/WEB-INF</strong>/views/comunes/registro.xhtml Not Found in ExternalContext as a Resource. The same problem that using h:link.</p>
  
  <p>web.xml</p>
  
  <pre><code> &lt;!-- Extensión por defecto para el uso de Facelets --&gt;
  
  &lt;context-param&gt;
    &lt;param-name&gt;javax.faces.DEFAULT_SUFFIX&lt;/param-name&gt;
    &lt;param-value&gt;.xhtml&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;context-param&gt;
    &lt;param-name&gt;javax.faces.PROJECT_STAGE&lt;/param-name&gt;
    &lt;param-value&gt;Development&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  
  &lt;!-- Archivo de configuración de Spring --&gt;
  
  &lt;context-param&gt;
    &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
    &lt;param-value&gt;/WEB-INF/applicationContext.xml&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;filter&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
  &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  
    &lt;filter&gt;
     &lt;filter-name&gt;charEncodingFilter&lt;/filter-name&gt;
     &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt;
    &lt;init-param&gt;
      &lt;param-name&gt;encoding&lt;/param-name&gt;
      &lt;param-value&gt;UTF-8&lt;/param-value&gt;
    &lt;/init-param&gt;
    &lt;init-param&gt;
      &lt;param-name&gt;forceEncoding&lt;/param-name&gt;
      &lt;param-value&gt;true&lt;/param-value&gt;
    &lt;/init-param&gt;
    &lt;/filter&gt;
    &lt;filter-mapping&gt;
      &lt;filter-name&gt;charEncodingFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
    &lt;/filter-mapping&gt;
  
    &lt;!-- Carga el spring web application context --&gt;
  
    &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.util.Log4jConfigListener&lt;/listener-class&gt;
    &lt;/listener&gt;
  
   &lt;listener&gt;
     &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-..
   &lt;/listener&gt;
  
    &lt;listener&gt;
      &lt;listener-class&gt;
        org.springframework.web.context.request.RequestContextListener
      &lt;/listener-class&gt;
    &lt;/listener&gt;
  
      &lt;!-- Servlet para los recursos de la aplicación --&gt;
  
     &lt;servlet&gt;
   &lt;servlet-name&gt;Resources Servlet&lt;/servlet-name&gt;
   &lt;servlet-class&gt;org.springframework.js.resource.ResourceServlet&lt;/servlet-class&gt;
   &lt;load-on-startup&gt;0&lt;/load-on-startup&gt;
     &lt;/servlet&gt;
  
     &lt;servlet-mapping&gt;
   &lt;servlet-name&gt;Resources Servlet&lt;/servlet-name&gt;
   &lt;url-pattern&gt;/resources/*&lt;/url-pattern&gt;
     &lt;/servlet-mapping&gt;
  
     &lt;!-- FronController de la aplicación, maneja todas las request --&gt;
  
    &lt;servlet&gt;
  &lt;servlet-name&gt;Spring MVC Dispatcher Servlet&lt;/servlet-name&gt;
  &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
  &lt;init-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;&lt;/param-value&gt;
  &lt;/init-param&gt;
  &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
  &lt;servlet-name&gt;Spring MVC Dispatcher Servlet&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/spring/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  
  &lt;servlet&gt;
    &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
    &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
    &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
    &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/faces/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>webflow-config.xml</p>
  
  <pre><code>&lt;!-- Configuración Spring webflow para JSF 2 --&gt;
  
  
  &lt;bean id="flowController"
             class="org.springframework.webflow.mvc.servlet.FlowController"&gt;  
        &lt;property name="flowExecutor" ref="flowExecutor"/&gt;  
      &lt;/bean&gt;  
  
  
  &lt;!-- Configure Web Flow to be able to recognize JSF 2 Ajax requests --&gt;
  
  &lt;bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter"&gt;
      &lt;property name="flowExecutor" ref="flowExecutor" /&gt;
      &lt;property name="ajaxHandler"&gt;
          &lt;bean class="org.springframework.faces.webflow.JsfAjaxHandler"/&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;!-- Executes flows: the central entry point into the Spring Web Flow system --&gt;
  
  &lt;webflow:flow-executor id="flowExecutor"&gt;
      &lt;webflow:flow-execution-listeners&gt;
          &lt;webflow:listener ref="facesContextListener"/&gt;
          &lt;webflow:listener ref="securityFlowExecutionListener" /&gt;
      &lt;/webflow:flow-execution-listeners&gt;
      &lt;webflow:flow-execution-attributes&gt;
          &lt;webflow:redirect-in-same-state value="false"/&gt;
      &lt;/webflow:flow-execution-attributes&gt;
  &lt;/webflow:flow-executor&gt;
  
  &lt;!-- The registry of executable flow definitions --&gt;
  
  &lt;webflow:flow-registry id="flowRegistry" 
            flow-builder-services="facesFlowBuilderServices" base-path="/WEB-INF/flows"&gt;
      &lt;webflow:flow-location-pattern value="/**/*-flow.xml" /&gt;
  &lt;/webflow:flow-registry&gt;
  
  &lt;!-- Configures the Spring Web Flow JSF integration --&gt;
  
  &lt;faces:flow-builder-services id="facesFlowBuilderServices" development="true" /&gt;
  
  &lt;!-- Installs a listener that creates and releases the FacesContext for 
              each request. --&gt;
  
  &lt;bean id="facesContextListener"
           class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener"/&gt;
  
  &lt;!-- Installs a listener to apply Spring Security authorities --&gt;
  
  &lt;bean id="securityFlowExecutionListener"
           class="org.springframework.webflow.security.SecurityFlowExecutionListener" /&gt;
  
  
      &lt;!-- configuración MVC para JSF 2 --&gt;
  
  &lt;faces:resources/&gt;
  
  &lt;!-- Dispatches requests mapped to flows to FlowHandler implementations --&gt;
  
  &lt;bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter"&gt;
      &lt;property name="flowExecutor" ref="flowExecutor" /&gt;
  &lt;/bean&gt;
  
  &lt;!-- Maps request paths to flows in the flowRegistry --&gt;
  
  &lt;bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping"&gt;
      &lt;property name="order" value="1"/&gt;
      &lt;property name="flowRegistry" ref="flowRegistry" /&gt;
      &lt;!-- If no flow match, map path to a view to render; e.g. the "/intro" path 
               would map to the view named "intro"    --&gt;
      &lt;property name="defaultHandler"&gt;
  &lt;bean  class="org.springframework.web.servlet.mvc.UrlFilenameViewController" /&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;!-- Maps logical view names to Facelet templates in /WEB-INF (e.g. 'search' to 
       '/WEB-INF/search.xhtml' --&gt;
  
  &lt;bean id="faceletsViewResolver" 
            class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;
      &lt;property name="viewClass" value="org.springframework.faces.mvc.JsfView"/&gt;
      &lt;property name="prefix" value="/WEB-INF/views/" /&gt;
      &lt;property name="suffix" value=".xhtml" /&gt;
  &lt;/bean&gt;
  
  &lt;!-- Dispatches requests mapped to org.springframework.web.servlet.mvc.Controller
           implementations --&gt;
  
  &lt;bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" /&gt;
     &lt;/beans&gt;
  </code></pre>
  
  <p>partial code view</p>
  
  <pre><code>    &lt;ui:define name="content"&gt;
      &lt;div class="registroUsuario"&gt;
      &lt;h:form id="registroForm"&gt;
          &lt;h:panelGrid columns="3"&gt;
  
      &lt;h:outputLabel for="distrito" value="Distrito" styleClass="labelInput" /&gt;
  
      &lt;h:selectOneMenu id="distrito" required="true" requiredMessage="Debe seleccionar un
         distrito" value="#{registro.idDistrito}" title="Seleccione su distrito"&gt;
  
       &lt;f:selectItem itemLabel="Seleccione distrito" itemValue="0"
                noSelectionOption="true"&gt;&lt;/f:selectItem&gt;
      &lt;f:selectItems var="distrito" value="#{registro.distritos}" itemLabel="#
            {distrito.nombre}" itemValue="#{distrito.idDistrito}"&gt;
      &lt;/f:selectItems&gt;
  
      &lt;f:ajax update="barrio calle messageDistrito" render="barrio calle messageDistrito" 
            listener="#{registro.updateBarrio}" event="blur" /&gt;
  
      &lt;f:validateBean for="idDistrito" /&gt;
      &lt;/h:selectOneMenu&gt;
  
        &lt;h:message id="messageDistrito" for="distrito" styleClass="messageError" /&gt;           
  
      &lt;h:outputLabel for="barrio" value="Barrio" styleClass="labelInput" /&gt;
      &lt;h:selectOneMenu id="barrio" effect="fade" required="true" requiredMessage="Debe
       seleccionar un barrio" value="#{registro.idBarrio}" title="Seleccione su barrio "&gt;
  
    &lt;f:selectItem itemLabel="Seleccione barrio" itemValue="0" noSelectionOption="true" /&gt;     
  
  &lt;f:selectItems var="barrio" value="#{registro.barrios}" itemLabel="#{barrio.nombre}"
                 itemValue="#{barrio.idBarrio}"&gt;
  &lt;/f:selectItems&gt;
  
  &lt;f:ajax render="calle messageBarrio" listener="#{registro.updateCalle}" 
           event="valueChange" /&gt;
  &lt;f:validateBean for="idBarrio" /&gt;
  &lt;/h:selectOneMenu&gt;
  &lt;h:message id="messageBarrio" for="barrio" styleClass="messageError" /&gt;
  </code></pre>
  
  <p><strong>The problem detected are:</strong> When I specific in URL <em>/spring/.....</em></p>
  
  <p>1- f:ajax tag dont call to the method in listener attribute but "reload" view and Second
     point occurs.</p>
  
  <p>2- Repeat context path in URL <em>/WEB-INF/views/WEB-INF/views/</em> this occurs when I use h:link
     tag or I change value in a h:selectOneMenu.</p>
  
  <p>3- h:comammdbuton not working, listener attribute dont call to the method.</p>
  
  <p><strong>When I use</strong> in URL <em>/faces/......</em> The above steps work fine.</p>
  
  <p>Why occurs this behaviour? </p>
  
  <p>Kind regards.</p>