tags:

views:

235

answers:

1

Hi,

i have a JSF web application. I use Beans as Spring Beans (not JSF managed beans). Now i have an URL to application www.xxx.com?parameter=2

I would like to set this parameter into bean on the page load. I now how to do this with spring web flow but with JSF Navigation i cant do this.

What do you think about using JSTL c:set or jsp:setProperty?

Thanks for your help.

Kind regards Sebastian

+1  A: 

From here:

One could extend a Springs org.springframework.beans.factory.config.PropertyPlaceholderConfigurer which accesses the RequestContext (org.springframework.web.context.request.RequestContextHolder#getRequestAttributes()) to resolve ${xyz}-like properties in the bean. Of course that would only work for Spring beans with “request”-scope.

If the bean is in session-scope you could simply use the following in a Phase Listener method:

property = FacesContezt.getCurrentInstance().getExternalContext
      .getRequestMap().get("paramName");

the phase listener is defined with

<f:view beforePhase="#{bean.method}">

if using facelets, its beforePhaseListener

If you were using faces-context.xml, you could've used the <managed-property>.

Bozho
The Bean is in session scope :(Thanky you for your answer.
Sebastian
Which action method? I dont have any action method. The page is loaded via url adress with parameter. The user doesnt do any action. The page should displays some data on the base of the request parameter.Im not using faces-config.xml for defining managed beans. All beans are spring beans definden in application context files.
Sebastian
@Sebastian, sorry, I added an update
Bozho
Thank you. I think i will be need to write my own Phaselistener because im using JSF 1.1 and there is no beforPhase tag attribute.
Sebastian