Ok, I will do. Thank you very much.
________________________________ From: Matt Raible [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 22, 2008 3:32 PM To: [email protected] Subject: Re: [appfuse-user] Using User from appfuse in appz I don't know of any upgrade issues - I'd suggest upgrading to 2.5.1 which was released last week. Matt On Jan 22, 2008, at 2:24 PM, Ding, Qin wrote: Matt, Yes, I tried. I pasted the code in. It won't compile due to the fact getRequest method is not visible. I am using appfuse 1.9.4. and the spring is 2.0. Is it possible to upgrade the spring to 2.5 then? It there any known issues if I upgrade the spring to 2.5 with appfuse 1.9.4? Thank you. QD ________________________________ From: Matt Raible [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 22, 2008 3:18 PM To: [email protected] Subject: Re: [appfuse-user] Using User from appfuse in appz You have to cast to ServletRequestAttributes - did you try the code below? I'm using this on a project with Spring 2.5 and it works. Matt On Jan 22, 2008, at 2:13 PM, Ding, Qin wrote: Matt: getRequest() method is not visible from requestAttributes. QD ________________________________ From: Matt Raible [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 22, 2008 3:04 PM To: [email protected] Subject: Re: [appfuse-user] Using User from appfuse in appz The following won't work in a test, but it may work in your running application. Spring's RequestContextListener registers the request in a ThreadLocal: private HttpServletRequest getRequest() { return (HttpServletRequest) ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); } HTH, Matt On Jan 22, 2008, at 1:12 PM, Ding, Qin wrote: Again, my goal is to find out how I can get application URL from my bean in service layer. According to Mike, I made my bean servletContextAware so that I can get application URL by calling Url url = servletContext.getResource("/index.jsp"); However, I don't get the host, port information from url.getHost(), urlGetPort().... Is there a way I get inject HttpServletRequest to my service bean? In the BasePage, we get can get HttpServletRequest by calling (HttpServletRequest) getFacesContext().getExternalContext().getRequest(); public static HttpServletRequest getRequest() { return (HttpServletRequest) FacesContext.getCurrentInstance() .getExternalContext() .getRequest(); } If I put the above method into my own bean, or uses FacesUtils.getRequest(), I got nullPointerException. Why the "getRequest()" method in BasePage works but not in my service bean? Seems to me if I couldinject the facesContext to my bean, then I can get HttpServletRequest. With Request object, I should be able to get URL by calling request.getUri or Url. Please advice. Thank you. QD --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
