I have a URL
in this way http:/myDomain/myWAR/myServletReceiver
I don't want end User to know about my WAR file name nor about the Servlet Receiver name. So, I thought I will personalize this URL into something like http:/myDomain/MyAccount .
I have added below piece of code for achieving this.
Created my own package. Code below.
package myOwnPackage
import javax.el.ExpressionFactory;
import javax.el.ValueExpression;
import javax.faces.application.ViewHandler;
import javax.faces.context.FacesContext;
import com.sun.facelets.FaceletViewHandler;
public class DynamicViewHandler extends FaceletViewHandler{
public DynamicViewHandler(ViewHandler parent) {
super(parent);
System.out.println("Entered into DynamicViewHandler");
}
public String getActionURL(FacesContext context, String viewId) {
System.out.println("Inside getActionURL");
ExpressionFactory expressionFactory = context.getApplication().getExpressionFactory();
ValueExpression valueExpression = expressionFactory.createValueExpression(context.getELContext(), viewId, String.class);
String result = (String) valueExpression.getValue(context.getELContext());
System.out.println("Value of Result is:" +result);
//I am in the beginning steps and just want to print the value of "result" for each response
return result;
}
}
I registered this in faces-config.xml
<application>
<view-handler>myOwnPackage.FaceletViewHandler</view-handler>
<state-manager>org.jboss.portletbridge.application.PortletStateManager</state-manager>
</application>
When I hit my application, the welcome page that my Servlet redirects to is /jsp/html/index.xhtml
.
So, in the logs I get below values printed.
Entered into DynamicViewHandler
Value of Result is:/jsp/html/index.xhtml
There are other links in index.jsf
page. When I click on other links I get below error message on my Browser(instead of going to /jsp/html/secondPage.jsf
)
http:/myDomain/jsp/html/index.html not found (404) error.
Am definitely missing things in my DynamicViewHandler
, faces-config.xml
and may be more.
What else am I missing here?
Also, I would like to map jsp/html/secondPage.jsf
to /MyAccount