hi again!

of course, here is my sourcecode for the Servlet:

in the servlet-class:


   @Override
   protected void service(HttpServletRequest request, HttpServletResponse
response)
       throws ServletException, IOException {

       String uri = request.getRequestURI();

       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(), request,
response,
                   lifecycle);
       Application application = facesContext.getApplication();
       ViewHandler viewHandler = application.getViewHandler();
       String viewId = "";
       UIViewRoot view = viewHandler.createView(facesContext, viewId);
       facesContext.setViewRoot(view);


       String[] parts = uri.split("/");

       if (uri != null) {

           String app = parts[2];

           if ("news".equals(app)) {
               handleNews(parts);
           } else if ("user".equals(app)) {
               handleUser(parts);
           } else if ("tag".equals(app)) {
               handleTag(parts);
           }
       }


       // specify what outcome value you want to use for navigation
       String outcome="SUCCESS";

       if (facesContext.getResponseComplete()) {
           return;
       }
       if (log.isDebugEnabled()) {
           log.debug("outcome = '" + outcome + "'");
       }
       NavigationHandler navigationHandler =
application.getNavigationHandler();
       navigationHandler.handleNavigation(facesContext, null, outcome);
       lifecycle.render(facesContext);

   }


i have not specified any navigation rules for this one. one thing i noticed,
if i make a

response.sendRedirect("jsp/index.faces");

at the end of the service-method, there is no endless loop, but the URL
changes and i do not want that.


thanks and regards,
Matthes

2007/6/22, Volker Weber <[EMAIL PROTECTED]>:

Hi Matthes,

can you post your source?
the Servlet and the navigation rules.


Regards,
    Volker



2007/6/22, Matthes R. <[EMAIL PROTECTED]>:
> hi volker,
>
> thanks for the tip. seems to be a better solution ;-)
> now, changes it into a servlet, i get another confusing problem. i have
> overwritten the protected void service(...) method as described in the
link
> you have posted. however, now this service method is called in an
infinite
> loop. and from the 2nd time its called the requestURI changes. my URI
looks
> like this:
>
> /webapp/group/1234
>
> and from the second time it is just
>
> /webapp/group
>
>
> hoping for a help on this one! thanks
>
> regards,
> Matthes
>
>
> 2007/6/20, Volker Weber < [EMAIL PROTECTED]>:
> > Hi,
> >
> > i think you should not use a PhaseListener, but a servlet.
> > see:
> >
>
http://wiki.apache.org/myfaces/InvokingJsfPagesWithStandardUrls#head-6c1aaf488d48f938896da962aaa4361ec3ffaf70
> >
> >
> > Regards,
> >     Volker
> >
> > 2007/6/20, Matthes R. <[EMAIL PROTECTED]>:
> > > Hi all,
> > >
> > > i've got a problem with my self-written PhaseListener. It is a
> RESTORE_VIEW
> > > listener and is intended to deal with pretty URLs:
> > >
> > > e.g.:
> > > www.server.com/webapp/user/123
> > >
> > > the listener splits the requestURI (into an array [webapp, user,
123]).
> this
> > > works fine. i then put the parameters into some beans. works fine
too (i
> > > create session-scope beans if they do not exist and put them into
the
> > > FacesContext).
> > >
> > > Now, here is my problem. i then want to change the ViewRoot to do an
> > > internal forward to the index.jsp (this one generates the content
from
> the
> > > beans):
> > >
> > >     private FacesContext context;
> > >     .
> > >     .
> > >      .
> > >         //set the viewroot to show the indexpage!
> > >         UIViewRoot view = context.getApplication().
> > >             getViewHandler().createView(context,
> > > "/jsp/index.jsp");
> > >         context.setViewRoot (view);
> > >
> > >
> > > the index.jsp is loaded correctly, but when it is finished, it
starts
> > > loading again. weird thing about that: it does not load any
css-styles,
> so
> > > it is completely useless (besides its useless cos its loading
twice).
> > >
> > > anyone got an idea?
> > >
> > > regards,
> > > Matthes
> > >
> >
>
>

Reply via email to