Results 1 to 3 of 3

Thread: Spring MVC and JSF navigation rules together

  1. #1
    Join Date
    Dec 2009
    Posts
    5

    Default Spring MVC and JSF navigation rules together

    Hi,

    I have an application using both Spring Framework and JSF.

    Q #1. The big doubt I have is whether I should use Spring Controllers and view resolvers to perform page navigations? OR whether I have to use standard JSF navigation rules (in faces-config.xml) to handle page navigation?

    Q #2. Can any tell me pros and cons of both of them and in which scenarios they could be useful.

    Q #3. Is it possible to use both spring mvc & JSF navigation rules at a same time?

    Can anyone please clarify the above three questions.

    Thanks & Regards,
    Harish

  2. #2
    Join Date
    Dec 2009
    Posts
    5

    Default

    any updates please....?

    not sure why this forum is so un-responsive

    Please help

  3. #3
    Join Date
    Jun 2011
    Posts
    29

    Default

    I'd also love to see an answer for this. Having same scenario.

    Here is the scenario I have:

    Code:
    <!-- Maps request URIs to controllers -->			
    <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
      <property name="mappings">
        <value>
          /myurl.htm=myURLController
        </value>
      </property>
    </bean>
    The myURLController is a @Controller which loads a xhtml view that has a JSF form on it
    Code:
    WebContent
      /WEB-INF/my/path/myPage.xhtml
    Code:
    @Controller
    public class MyController {
    
    	@RequestMapping(method = RequestMethod.GET)
    	public ModelAndView handleGet(HttpServletRequest request, ModelMap model) throws Exception {
    		// Do some stuff here
    		ModelAndView modelAndView = new ModelAndView(new InternalResourceView("/WEB-INF/my/path/myPage.xhtml"), model);		
    		return modelAndView;
    	}
    }
    The xhtml file looks something like this...
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <ui:composition xmlns="http://www.w3.org/1999/xhtml"
    	xmlns:ui="http://java.sun.com/jsf/facelets"
    	xmlns:h="http://java.sun.com/jsf/html"
    	template="../../template/template_withoutmenu.xhtml">
    <ui:define name="content">	
      <!-- Some static content and standard HTML Tags here.... -->
    
      <h:form id="rform">
        <!-- Some input fields here -->
        <h:commandButton id="go" type="submit" action="doIt" title="Go" />
        <h:commandButton id="cancelPassword" action="cancel" title="Cancel" />
      </h:form>
    </ui:define>
    </ui:composition>
    So all this works fine and the xhtml page loads. Now the problem is that JSF form adds in its own action that apparently cannot be overridden so the action is always /my/path/myPage.xhtml (in HTML view source)

    So I read up that I can use JSF navigation.. I added the following to faces-config.xml

    Code:
    <navigation-rule>
      <navigation-case>
        <from-outcome>doIt</from-outcome>
        <to-view-id>/doItPage.htm</to-view-id>
      </navigation-case>
      <navigation-case>
        <from-outcome>cancel</from-outcome>
        <to-view-id>/cancelPage.htm</to-view-id>
      </navigation-case>
    </navigation-rule>
    But this does not seem to do anything... any ideas?
    I also realize I'm missing the <from-view-id>xxxxxxx</from-view-id> tag.. but what would that be? Would it be the htm url or the xhtml url???
    Last edited by avalanche333; Jun 29th, 2011 at 07:41 AM. Reason: Added lots more details

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •