dev@jsftemplating.java.net

Re: JSFTemplating: How to retreive submitted data?

From: Ken Paulsen <Ken.Paulsen_at_Sun.COM>
Date: Wed, 24 Jan 2007 16:46:30 -0800

Karam Singh Badesha wrote:
> Hi,
> I have a very simple test page:
>
> <sun:page>
> <sun:html>
> <sun:head id="head" />
> <sun:body>
> <sun:form id="form">
> "<p>&nbsp;</p>
> <sun:staticText value="requestParameter is
> $requestParameter{in}" />
To get it directly from a request parameter, you'd need to do
"$requestParameter{form:in}" because the "id" you set here is not the
"id" in the HTML. Do a browser "view source" to see what I mean.
> "<br>
> <sun:staticText value="requestScope is
> #{requestScope.in}" />
> "<br>
> <sun:staticText value="noScope is #{in}" />
> "<br>
> <sun:textField id="in" immediate="$boolean{true}"/>
You are missing:

    value="#{requestScope.in}"

The "id" property is not used by JSF to access the data. The "id" in
JSF gets translated to a "client ID" which end up looking like
"form:in". This is what is used in the HTML for the component
(typically). You can also use the "client ID" in java code to locate
the "component" and from the component access the data. If you don't
bind the value to anything (as you did above), you'd need to get the
component in this way to get its value. This is not common, though.
Binding the value is the better approach.
> "<br /><br />
> <sun:button text="Go!" />
> </sun:form>
> </sun:body>
> </sun:html>
> </sun:page>
>
> I can't seem to get the value of the textfield entry to show up. I
> don't want to set up a pageSession variable using action.
No need... see above. You can select the appropriate scope in the EL
binding for the value field. Or use a manged bean.
> Just want to know how the form variables can be retrieved so that I
> can show the data on the same page with when the page gets refreshed.
> What is the correct call?
See above.

Good luck!

Ken
>
> thanks
> Karam