Re: Setting ViewRoot of FacesContext reloads the page _twice_
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
Re: Setting ViewRoot of FacesContext reloads the page _twice_
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
Setting ViewRoot of FacesContext reloads the page _twice_
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
[tomahawk sandbox] dynamic PPR content changes
hi all, i've got a problem with dynamically changing the content of my page with the PPR components of the sandbox. i'm using myfaces-core-1.1.5, tomahawk-1.1.5 and tomahawk-sandbox-1.1.6-SNAPSHOT. here is my code: - h:form id=form1 t:commandLink id=switchToPage2 action=#{ contentIncludeBean.switchToPage2} value=switch content/ f:verbatimbr //f:verbatim s:pprPanelGroup id=pageContent partialTriggers=switchToPage2 f:subview id=page1Content rendered=#{ contentIncludeBean.includeString == 'page1'} f:verbatimdivpage1/div/f:verbatim /f:subview f:subview id=page2Content rendered=#{ contentIncludeBean.includeString == 'page2'} f:verbatimdivpage2/div/f:verbatim /f:subview h:outputText value=#{contentIncludeBean.includeString == 'page1'}/h:outputText h:outputText value=#{contentIncludeBean.includeString == 'page2'}/h:outputText /s:pprPanelGroup /h:form - and the bean has this method: - public void switchToPage2() { includeString = page2; } - when loading the page for the first time the subview page1Content is rendered, so its working correct. then when i hit the commandLink both subviews are not rendered but the boolean values calculated below are correct: false / true. is there a way to fix this problem? or is there another (perhaps better) way to get this to work? regards, Matthes Rieke
Re: [tomahawk sandbox] dynamic PPR content changes
hi, aaah ok. fixed that one. i'm kind of new to myfaces so things like this happen to me often :-) thanks for the help! regards, Matthes 2007/5/22, Volker Weber [EMAIL PROTECTED]: Hi, you cant use f:verbatim in ppr updates. content of verbatim is transient and not restored at rerendering. Regards, Volker 2007/5/22, Matthes R. [EMAIL PROTECTED]: hi all, i've got a problem with dynamically changing the content of my page with the PPR components of the sandbox. i'm using myfaces-core-1.1.5, tomahawk-1.1.5 and tomahawk-sandbox-1.1.6-SNAPSHOT. here is my code: - h:form id=form1 t:commandLink id=switchToPage2 action=#{contentIncludeBean.switchToPage2} value=switch content/ f:verbatimbr //f:verbatim s:pprPanelGroup id=pageContent partialTriggers=switchToPage2 f:subview id=page1Content rendered=#{ contentIncludeBean.includeString == 'page1'} f:verbatimdivpage1/div/f:verbatim /f:subview f:subview id=page2Content rendered=#{ contentIncludeBean.includeString == 'page2'} f:verbatimdivpage2/div/f:verbatim /f:subview h:outputText value=#{contentIncludeBean.includeString == 'page1'}/h:outputText h:outputText value=#{contentIncludeBean.includeString == 'page2'}/h:outputText /s:pprPanelGroup /h:form - and the bean has this method: - public void switchToPage2() { includeString = page2; } - when loading the page for the first time the subview page1Content is rendered, so its working correct. then when i hit the commandLink both subviews are not rendered but the boolean values calculated below are correct: false / true. is there a way to fix this problem? or is there another (perhaps better) way to get this to work? regards, Matthes Rieke