Announcement Announcement Module
Collapse
No announcement yet.
ContextPath param repeated in url when I use AJAX or h:link Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ContextPath param repeated in url when I use AJAX or h:link

    Hello, the project is developed in Spring 3, Spring web flow 2, Spring security 3 and Primefaces 3. 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 of Spring I have started to have problem in two cases above.

    For example, when I use h:link tag and its attribute outcome="listActivities, the result is href="WEB-INF/views/WEB-INF/views/listActivities.xhtml". I have could this problem using h:outputlink tag, because the result is href="listActivities" and I have configured SWF for to use UrlBasedViewResolver.

    In the case using AJAX then the app not working and the message is serverError: class com.sun.faces.context.FacesFileNotFoundException /WEB-INF/views/WEB-INF/views/comunes/registro.xhtml Not Found in ExternalContext as a Resource. The same problem that using h:link.

    web.xml

    Code:
     <!-- Extensión por defecto para el uso de Facelets -->
     
      <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
      </context-param>
      
      <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
      </context-param>
      
      
      <!-- Archivo de configuración de Spring -->
      
      <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
      </context-param>
      
      	<filter>
       		<filter-name>springSecurityFilterChain</filter-name>
       		<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    	</filter>
    	<filter-mapping>
       		<filter-name>springSecurityFilterChain</filter-name>
       		<url-pattern>/*</url-pattern>
    	</filter-mapping>
      
      <filter>
        <filter-name>charEncodingFilter</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-mapping>
        <filter-name>charEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
      </filter-mapping>
      
      <!-- Carga el spring web application context -->
      
      <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</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>
      
      <!-- Servlet para los recursos de la aplicación -->
      
      <servlet>
      	<servlet-name>Resources Servlet</servlet-name>
      	<servlet-class>org.springframework.js.resource.ResourceServlet</servlet-class>
      	<load-on-startup>0</load-on-startup>
      </servlet>
      
      <servlet-mapping>
      	<servlet-name>Resources Servlet</servlet-name>
      	<url-pattern>/resources/*</url-pattern>
      </servlet-mapping>
      
      <!-- FronController de la aplicación, maneja todas las request -->
      
      <servlet>
    	<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    	<init-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value></param-value>
    	</init-param>
    	<load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    	<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    	<url-pattern>/spring/*</url-pattern>
    </servlet-mapping>
    
      <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.faces</url-pattern>
      </servlet-mapping>
    </web-app>
    webflow-config.xml

    Code:
           	
    <!-- Configuración Spring webflow para JSF 2 -->
    	
    	
    	<bean id="flowController" class="org.springframework.webflow.mvc.servlet.FlowController">  
            <property name="flowExecutor" ref="flowExecutor"/>  
        </bean>  
    	
    	
    	<!-- Configure Web Flow to be able to recognize JSF 2 Ajax requests -->
    	
    	<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
        	<property name="flowExecutor" ref="flowExecutor" />
       		<property name="ajaxHandler">
            	<bean class="org.springframework.faces.webflow.JsfAjaxHandler"/>
        	</property>
    	</bean>
    	
    	<!-- Executes flows: the central entry point into the Spring Web Flow system -->
    	
    	<webflow:flow-executor id="flowExecutor">
    		<webflow:flow-execution-listeners>
    			<webflow:listener ref="facesContextListener"/>
    			<webflow:listener ref="securityFlowExecutionListener" />
    		</webflow:flow-execution-listeners>
    		<webflow:flow-execution-attributes>
    			<webflow:redirect-in-same-state value="false"/>
    		</webflow:flow-execution-attributes>
    	</webflow:flow-executor>
    	
    	<!-- The registry of executable flow definitions -->
    	
    	<webflow:flow-registry id="flowRegistry" flow-builder-services="facesFlowBuilderServices" base-path="/WEB-INF/flows">
    		<webflow:flow-location-pattern value="/**/*-flow.xml" />
    	</webflow:flow-registry>
    	
    	<!-- Configures the Spring Web Flow JSF integration -->
    	
    	<faces:flow-builder-services id="facesFlowBuilderServices" development="true" />
    
    	<!-- Installs a listener that creates and releases the FacesContext for each request. -->
    	
    	<bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener"/>
    	
    	<!-- Installs a listener to apply Spring Security authorities -->
    	
    	<bean id="securityFlowExecutionListener" class="org.springframework.webflow.security.SecurityFlowExecutionListener" />
    
    
    <!-- configuración MVC para JSF 2 -->
    
    	<faces:resources/>
    	
    	<!-- Dispatches requests mapped to flows to FlowHandler implementations -->
    	
    	<bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">
    		<property name="flowExecutor" ref="flowExecutor" />
    	</bean>
    	
    	<!-- Maps request paths to flows in the flowRegistry -->
    	
    	<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
    		<property name="order" value="1"/>
    		<property name="flowRegistry" ref="flowRegistry" />
    		<!-- If no flow match, map path to a view to render; e.g. the "/intro" path would map to the view named "intro"	-->
    		<property name="defaultHandler">
    			<bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
    		</property>
    	</bean>
    
    	<!-- Maps logical view names to Facelet templates in /WEB-INF (e.g. 'search' to '/WEB-INF/search.xhtml' -->
    	
    	<bean id="faceletsViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    		<property name="viewClass" value="org.springframework.faces.mvc.JsfView"/>
    		<property name="prefix" value="/WEB-INF/views/" />
    		<property name="suffix" value=".xhtml" />
    	</bean>
    
    	<!-- Dispatches requests mapped to org.springframework.web.servlet.mvc.Controller implementations -->
    	
    	<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
    </beans>
    partial code of listActivities.xhtml

    Code:
        		<ui:define name="content">
        			<div class="registroUsuario">
        			<h:form id="registroForm">
        				<h:panelGrid columns="3">
        					<h:outputLabel for="distrito" value="Distrito" styleClass="labelInput" />
        					<h:selectOneMenu id="distrito" required="true" requiredMessage="Debe seleccionar un distrito" value="#{registro.idDistrito}" title="Seleccione su distrito">
        						<f:selectItem itemLabel="Seleccione distrito" itemValue="0" noSelectionOption="true"></f:selectItem>
        						<f:selectItems var="distrito" value="#{registro.distritos}" itemLabel="#{distrito.nombre}" itemValue="#{distrito.idDistrito}">
        						</f:selectItems>
        						<f:ajax update="barrio calle messageDistrito" render="barrio calle messageDistrito" listener="#{registro.updateBarrio}" event="blur" />
        						<f:validateBean for="idDistrito" />
        					</h:selectOneMenu>
        					<h:message id="messageDistrito" for="distrito" styleClass="messageError" />			
        					
        					<h:outputLabel for="barrio" value="Barrio" styleClass="labelInput" />
        					<h:selectOneMenu id="barrio" effect="fade" required="true" requiredMessage="Debe seleccionar un barrio" value="#{registro.idBarrio}" title="Seleccione su barrio ">
        						<f:selectItem itemLabel="Seleccione barrio" itemValue="0" noSelectionOption="true"></f:selectItem>
        						<f:selectItems var="barrio" value="#{registro.barrios}" itemLabel="#{barrio.nombre}" itemValue="#{barrio.idBarrio}">
        						</f:selectItems>
        					<f:ajax render="calle messageBarrio" listener="#{registro.updateCalle}" event="valueChange" />
        					<f:validateBean for="idBarrio" />
        					</h:selectOneMenu>
        					<h:message id="messageBarrio" for="barrio" styleClass="messageError" />
    It is a puzzle for me, and I can not think some solution, Any suggestions?

    Regards.

  • #2
    Hello

    When I use dispatcher servlet of JSF2 the view reload with AJAX perfectly and I can use tag h:link
    OK, we are fine

    But since I use dispatcher servlet of Spring I have started to have problem in two cases above.
    Why do you want do that?

    In the case using AJAX then the app not working and the message is serverError:
    class com.sun.faces.context.FacesFileNotFoundException
    /WEB-INF/views/WEB-INF/views/comunes/registro.xhtml Not Found in ExternalContext as a Resource.
    Post the complete error stack trace and see red and blue part is twice

    Comment


    • #3
      Hello, I want to use this configuration because I want to use SWF and to unify all request with spring dispachetServlet, the actual url are http://serverLocation/projectNoun/spring/*, before the urls were http://serverLocation/projectNoun/faces/*

      Another mistake I have is with h:commandButton tag, it dont work.

      The complete trace was that, because the message is a alert in the explorer. The app is being executed from JBOSS 7 by eclipse, and the eclipse's console dont show new error trace.

      Comment


      • #4
        Hello

        Remember JSF should be integrated only with SWF

        The complete trace was that, because the message is a alert in the explorer. The app is being executed from JBOSS 7 by eclipse, and the eclipse's console dont show new error trace.
        What about the server log files? I think there should be expanded

        Comment


        • #5
          Originally posted by dr_pompeii View Post
          Remember JSF should be integrated only with SWF
          This means that I must use spring-faces.jar?? Really, I dont understand you. The problem are two:

          - It seems that ajax is desactived, because when I changeValue in select tag, f:ajax dont call to method in listener attribute.
          - WEB-INF/view is repeated in the url, this problem occurs with h:lin tag for example, and in this case the log is more expanded.

          LOG

          com.sun.faces.context.FacesFileNotFoundException: /WEB-INF/views/WEB-INF/views/comunes/listadoActividades.xhtml Not Found in ExternalContext as a Resource
          at com.sun.faces.facelets.impl.DefaultFaceletFactory. resolveURL(DefaultFaceletFactory.java:232)
          at com.sun.faces.facelets.impl.DefaultFaceletFactory. resolveURL(DefaultFaceletFactory.java:273)
          at com.sun.faces.facelets.impl.DefaultFaceletFactory. getFacelet(DefaultFaceletFactory.java:201)
          at com.sun.faces.application.view.FaceletViewHandling Strategy.buildView(FaceletViewHandlingStrategy.jav a:768)
          at com.sun.faces.lifecycle.RenderResponsePhase.execut e(RenderResponsePhase.java:100)
          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:1 01)
          at com.sun.faces.lifecycle.LifecycleImpl.render(Lifec ycleImpl.java:139)
          at org.springframework.faces.mvc.JsfView.renderMerged OutputModel(JsfView.java:85)
          at org.springframework.web.servlet.view.AbstractView. render(AbstractView.java:250)
          at org.springframework.web.servlet.DispatcherServlet. render(DispatcherServlet.java:1031)
          at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:815)
          at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:717)
          at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:644)
          at org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:549)
          at javax.servlet.http.HttpServlet.service(HttpServlet .java:734)
          at javax.servlet.http.HttpServlet.service(HttpServlet .java:847)
          at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:329)
          at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:248)
          at org.jboss.weld.servlet.ConversationPropagationFilt er.doFilter(ConversationPropagationFilter.java:62)
          at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:280)
          at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:248)
          at org.springframework.web.filter.CharacterEncodingFi lter.doFilterInternal(CharacterEncodingFilter.java :88)
          at org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
          at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:280)
          at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:248)
          at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 366)
          at org.springframework.security.web.access.intercept. FilterSecurityInterceptor.invoke(FilterSecurityInt erceptor.java:109)
          at org.springframework.security.web.access.intercept. FilterSecurityInterceptor.doFilter(FilterSecurityI nterceptor.java:83)
          at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 378)
          at org.springframework.security.web.access.ExceptionT ranslationFilter.doFilter(ExceptionTranslationFilt er.java:97)
          at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 378)
          at org.springframework.security.web.session.SessionMa nagementFilter.doFilter(SessionManagementFilter.ja va:100)
          at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 378)
          at org.springframework.security.web.authentication.An onymousAuthenticationFilter.doFilter(AnonymousAuth enticationFilter.java:78)
          at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 378)
          at org.springframework.security.web.servletapi.Securi tyContextHolderAwareRequestFilter.doFilter(Securit yContextHolderAwareRequestFilter.java:54)
          at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 378)
          at org.springframework.security.web.savedrequest.Requ estCacheAwareFilter.doFilter(RequestCacheAwareFilt er.java:35)
          at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 378)
          at org.springframework.security.web.authentication.http://www.BasicAuthenticationFilter...lter.java:177)
          at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 378)
          at org.springframework.security.web.authentication.ui .DefaultLoginPageGeneratingFilter.doFilter(Default LoginPageGeneratingFilter.java:91)
          at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 378)
          at org.springframework.security.web.authentication.Ab stractAuthenticationProcessingFilter.doFilter(Abst ractAuthenticationProcessingFilter.java:187)
          at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 378)
          at org.springframework.security.web.authentication.lo gout.LogoutFilter.doFilter(LogoutFilter.java:105)
          at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 378)
          at org.springframework.security.web.context.SecurityC ontextPersistenceFilter.doFilter(SecurityContextPe rsistenceFilter.java:79)
          at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 378)
          at org.springframework.security.web.FilterChainProxy. doFilter(FilterChainProxy.java:167)
          at org.springframework.web.filter.DelegatingFilterPro xy.invokeDelegate(DelegatingFilterProxy.java:237)
          at org.springframework.web.filter.DelegatingFilterPro xy.doFilter(DelegatingFilterProxy.java:167)
          at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:280)
          at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:248)
          at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:275)
          at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:161)
          at org.jboss.as.web.security.SecurityContextAssociati onValve.invoke(SecurityContextAssociationValve.jav a:154)
          at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:155)
          at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102)
          at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
          at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:368)
          at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:877)
          at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:671)
          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:930)
          at java.lang.Thread.run(Unknown Source)

          Component Tree

          [I]<UIViewRoot id="j_id1" inView="true" locale="es_ES" renderKitId="HTML_BASIC" rendered="true" transient="true" viewId="/WEB-INF/views/WEB-INF/views/comunes/listadoActividades.xhtml"/>[/]

          Comment


          • #6
            Hello

            Next time use code tags

            This means that I must use spring-faces.jar??
            Yes, I think belong to SWF and is needed to resolve some dependencies.

            Check the SWF documentations to see how integrated well with JSF, with both there is no problem.

            Remember you cant use Spring MVC + JSF, you must use only Spring MVC including JSP support.

            Comment


            • #7
              I think that Spring MVC is compatible with JSF 2, and JSF 2 dont support JSP, for work in JSF 2 must use Facelets template. The problem of my error isnt this.

              13.5. Configuring Spring MVC for JSF 2 in SWF reference.

              I think that the problem is relationed with this configuration.

              Code:
              	<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
              		<!-- <property name="order" value="1"/>-->
              		<property name="flowRegistry" ref="flowRegistry" />
              		<!-- If no flow match, map path to a view to render; e.g. the "/intro" path would map to the view named "intro"	-->
              		<property name="defaultHandler">
              			<bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
              		</property>
              	</bean>
              
              	<!-- Maps logical view names to Facelet templates in /WEB-INF (e.g. 'search' to '/WEB-INF/search.xhtml' -->
              	
              	<bean id="faceletsViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
              		<property name="viewClass" value="org.springframework.faces.mvc.JsfView"/>
              		<property name="prefix" value="/WEB-INF/views/" />
              		<property name="suffix" value=".xhtml" />
              	</bean>
              And another problem is that AJAX behavior how desactived.

              Edit: I use Primefaces 3.2

              Primefaces work fin with SWF 2.4-SNAPSHOT?
              Last edited by Parche_; Apr 15th, 2012, 04:29 PM.

              Comment

              Working...
              X