to make it short and sweet: isn't there a working example of a custom
viewhandler where i can look into the code?
my english isn't that good and i am not sure about the terminologies -- so
i am afraid it will become a long and straining discussion ...
the long part:
i wrote a servlet that catches all urls of the type
http://host/app/document/* (configured in web.xml)
public void doGet(HttpServletRequest req, HttpServletResponse res) throws
IOException, ServletException
{
LifecycleFactory lFactory = (LifecycleFactory)
FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
Lifecycle lifecycle =
lFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
FacesContextFactory fcFactory = (FacesContextFactory)
FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
FacesContext facesContext =
fcFactory.getFacesContext(getServletContext(), req, res, lifecycle);
Application application = facesContext.getApplication();
if(viewHandler==null) viewHandler = new
MyViewHandler(application.getViewHandler());
viewHandler.setActionURL(req.getRequestURI());
application.setViewHandler(viewHandler);
UIViewRoot view = viewHandler.createView(facesContext,
"/presentation/document.jsf");
facesContext.setViewRoot(view);
TeuchosSearchBean myBean = (TeuchosSearchBean)
application.getVariableResolver().resolveVariable(facesContext,
"teuchosSearchBean");
String id=req.getRequestURI();
myBean.setObjectID(id.substring(id.indexOf("documents/")+10));
try
{
req.getRequestDispatcher(facesContext.getViewRoot().getViewId()).forward(req,
res);
}
catch (Exception e)
{
LOGGER.error(e.getMessage(), e);
return;
}
}
MyViewHandler is:
class MyViewHandler extends ViewHandlerImpl
{
private final ViewHandler myViewHandler;
private String myActionUrl;
public MyViewHandler(ViewHandler vh)
{
super(vh);
myViewHandler=vh;
}
@Override
public String getActionURL(FacesContext context, String viewId)
{
if(myActionUrl!=null && myActionUrl.split("/").length>4)
return myActionUrl.replace("/documents", "");
return myActionUrl;
}
public void setActionURL(String au)
{
myActionUrl=au;
}
}
now every attempt to navigate from this page (by jscookmenu or
t:commandButton) ends with a blank page and no error.
it's most probably something very stupid -- but usually the more stupid
the longer it takes to find out ....