|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
pretty url -- wrong name in jshi,
after some research regarding pretty urls i found both http://blogs.steeplesoft.com/jsf-phaselisteners-and-get-requests/ and http://wiki.apache.org/myfaces/InvokingJsfPagesWithStandardUrls i tried the second approach first (servlet) and instead of invoking the NavigationHandler i did a forward: req.getRequestDispatcher(facesContext.getViewRoot().getViewId()).forward(req, res); the page is rendered wonderfully, the url is intact -- all seems nice, until ... i got an <h:collapsiblePanel> on my page -- and clicking the panel to expand it changes the url. instead of my nice url now there's the url of the viewId i render inside my servlet. with the phaselistener it's mostly the same -- only the url is now the pseudo-directory and the viewId appended which results in an error ... pretty url: http://foo.bar/document/doc001 wrong url after servlet: http://foo.bar/presentation/presentation.jsf wrong url after phaselistener: http://foo.bar/document/presentation/presentation.jsf so, is there a way to force the prettified url even inside the rendered page? maybe some string replacement in a phaselistener? i hop, i could make my problem clear. thanks |
|
|
Re: pretty url -- wrong name in jsHave a look at getActionURL. You can create your own
ViewHandlerWrapper and create your own action URLs for the passed in view IDs: http://tinyurl.com/3jnv4w -Andrew On Fri, May 2, 2008 at 4:15 AM, arne anka <dojo@...> wrote: > hi, > after some research regarding pretty urls i found both > http://blogs.steeplesoft.com/jsf-phaselisteners-and-get-requests/ > and > http://wiki.apache.org/myfaces/InvokingJsfPagesWithStandardUrls > > i tried the second approach first (servlet) and instead of invoking the > NavigationHandler i did a forward: > > req.getRequestDispatcher(facesContext.getViewRoot().getViewId()).forward(req, > res); > > the page is rendered wonderfully, the url is intact -- all seems nice, > until ... > i got an <h:collapsiblePanel> on my page -- and clicking the panel to > expand it changes the url. > instead of my nice url now there's the url of the viewId i render inside my > servlet. > > with the phaselistener it's mostly the same -- only the url is now the > pseudo-directory and the viewId appended which results in an error ... > > pretty url: > http://foo.bar/document/doc001 > > wrong url after servlet: > http://foo.bar/presentation/presentation.jsf > > wrong url after phaselistener: > http://foo.bar/document/presentation/presentation.jsf > > so, is there a way to force the prettified url even inside the rendered > page? > maybe some string replacement in a phaselistener? > > i hop, i could make my problem clear. > > thanks > |
|
|
Re: pretty url -- wrong name in js> Have a look at getActionURL. You can create your own
> ViewHandlerWrapper and create your own action URLs for the passed in > view IDs: that kind of works -- but now all other links do not work, most notably jscookmenu is dead. |
|
|
Re: pretty url -- wrong name in jsHow do they not work? Will need more information than that.
On Wed, May 7, 2008 at 9:35 AM, arne anka <dojo@...> wrote: > > > Have a look at getActionURL. You can create your own > > ViewHandlerWrapper and create your own action URLs for the passed in > > view IDs: > > > > that kind of works -- but now all other links do not work, most notably > jscookmenu is dead. > |
|
|
Re: pretty url -- wrong name in jsto 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 .... |
| Free Forum Powered by Nabble | Forum Help |