webtier@glassfish.java.net

Re: [webtier] Setting initial inputarea contents from request parameters

From: <webtier_at_javadesktop.org>
Date: Thu, 04 Sep 2008 12:23:55 PDT

Yes of course. If you use JSF 1.2, you can read the parameter from the request in a managed bean method annotated with @postconstruct and put it in a managed bean property. From there it is easy to show it on your page.

On a pre-1.2 deployment, you can just put the logic in your bean, like this:

class MyManagedBean {
    private String someText;

    String getSomeText() {
        if (someText == null) {
            someText = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("the_parameter_name");
        }

        return someText;
    }

    setSomeText(String s) {
        this.someText = s;
    }

}

In your page you can then use the expression #{myManagedBean.someText}.

You just have to watch out with special characters in your request parameters and encoding, but that isn't really related to JSF.

You can even fill your textarea from the JSP/Facelet, by using this expression #{param.the_parameter_name}, but with this option, you can't bind your textarea to a managed bean property.

Or do you mean something else???

Cheers,

Jan-Kees van Andel
[Message sent by forum member 'jkva' (jkva)]

http://forums.java.net/jive/thread.jspa?messageID=297284