FAQ

On 2/18/07, Rodrigo Pereira wrote:
Is there any way of passing parameters to the action instead of form fields?
I mean, I have a value on a managed bean and I'd like to pass it to
the action, how can I do that?
If the managed bean has been created already, and you know what scope
it is in, you can just use the normal mechanism to get a request
attribute, or a session attribute, and so on. But often, in a JSF
based app, that is not always the case. For that scenario, there is a
way to evaluate value binding expressions programmatically that will
work inside your action, *if* it has been forwarded to from a JSF post
(which means that the JSF lifecycle created a FacesContext for it):

FacesContext fc = FacesContext.getCurrentInstance();
ValueBinding vb = fc.getApplication().createValueBinding("#{mybean.param}");
String param = (String) vb.getValue(fc);

This will cause the managed bean named "mybean" to be created (if
necessary), then the getParam() method to be called, and that value to
be returned. In this example I presumed that the data type was a
string, but it can be any object type.
Thanks,
Rodrigo Pereira
Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 2 | next ›
Discussion Overview
groupuser @
categoriesstruts
postedFeb 18, '07 at 12:57p
activeFeb 20, '07 at 11:16p
posts2
users2
websitestruts.apache.org
irc#struts

People

Translate

site design / logo © 2017 Grokbase