Navigation-Rule doesn't work when using <a4j:include> tag
tsunglintsai Nov 1, 2010 4:35 PMHi,
I am trying to use navigation rule with <a4:include> to create wizard like navigation, but i can't get browser navigate to "added.jsp" page when using <a4j:include>. however , if i land to addUser.jsp directly and click save button, it can successfully jump to "added.jsp". i am not sure which part i got wrong. can someone help? following is my code.
i am using JSF 1.2 and Richfaces 3.3.1 on Tomcat 7.0
index.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@taglib uri="http://richfaces.org/a4j" prefix="a4j"%> <%@taglib uri="http://richfaces.org/rich" prefix="rich"%> <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%> <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%> <f:view> <html> <head> <title></title> </head> <body> this is index.jsp <br> <a4j:outputPanel id="content"> this is content:<br> <a4j:include viewId="addUser.jsp"/> </a4j:outputPanel> </body> </html> </f:view>
addUser.jsp
<%@taglib uri="http://richfaces.org/a4j" prefix="a4j"%> <%@taglib uri="http://richfaces.org/rich" prefix="rich"%> <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%> <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%> <f:view> this is addUser.jsp <h:form id="Add-User"> <h:commandButton value="Save" action="#{userBean.save}" ></h:commandButton> </h:form> </f:view>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<f:view>
<html>
<head>
<title></title>
</head>
<body>
this is index.jsp
<br>
<a4j:outputPanel id="content">
this is content:<br>
<a4j:include viewId="addUser.jsp"/>
</a4j:outputPanel>
</body>
</html>
</f:view>
addUser.jsp
added.jsp
user added this is added page
faces-config.xml
.... <navigation-rule> <from-view-id>/addUser.jsp</from-view-id> <navigation-case> <from-outcome>success</from-outcome> <to-view-id>/added.jsp</to-view-id> </navigation-case> </navigation-rule> <managed-bean> <managed-bean-name>userBean</managed-bean-name> <managed-bean-class>UserBean</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean> ....
UserBean.java
public class UserBean implements Serializable{ public String save(){ return "success"; } }