Hi All,
Not getting any help from the Spring community on this so I'm really hoping someone here can help me out.
I want to know if it is possible to use a JSF Form on a page loaded by a Spring MVC @Controller?
Right now I'm really thinking it is not...
Here is what I am doing now:
I am mapping a Spring @Controller to handle requests made to the myurl.html URL in my web site... for example www.somesite.com/myurl.htm:
<!-- 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
This xhtml page is found at WebContent/WEB-INF/my/path/myPage.xhtml
@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...
<!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). When really I want it to post back to /myurl.html so the controller can handle the post request.
So I read up that I can use JSF navigation.. I added the following to faces-config.xml
<navigation-rule>
<navigation-case>
<from-outcome>doIt</from-outcome>
<to-view-id>/myurl.htm</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>cancel</from-outcome>
<to-view-id>/myurl.htm</to-view-id>
</navigation-case>
</navigation-rule>
But this does not seem to do anything... the page just attempts to posts to /my/path/myPage.xhtml which will not be resolved since the SimpleUrlHandlerMapping does not have this mapping.
Any ideas?
As a side now what I am trying to do is replace a web page that was originally loaded by a Spring Web flow with a Spring @Controller so I can remove several things Spring Web flows added to HttpSession. This is to help with a potential Denial Of Service Attack.
Thanks in advance!