| Author |
Calling method in the outputText value attribute
|
Rahul Juneja
Ranch Hand
Joined: Aug 03, 2002
Posts: 425
|
|
Folks, I want to do something like the following in my code. Is it possible to use method calls in value parameter of outputText. Any pointers are appreciated. Thanks, Rahul
|
Rahul Juneja
ThoughtClicks - http://techlabs.thoughtclicks.com
|
 |
Arun Sudharsanam
Greenhorn
Joined: May 29, 2008
Posts: 21
|
|
Why do you want to call a method from an outputText. If you want to assign the return value of the method to the outputText you can just do it as: <ice utputText value="#{bean.name}"/> and code in the bean as follows: String Name; //Getters and setters for the Variable
|
A S
|
 |
Himanshu Gupta
Ranch Hand
Joined: Aug 18, 2008
Posts: 598
|
|
You can call a method in Value just do one thing for that. Name the method in backing Bean like getXXX() and in the Page bind it like value="#{beanName.XXX}". Point to remember: The return type of the Method should be String.
|
My Blog SCJP 5 SCWCD 5
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14460
|
|
You shouldn't call action code in an attribute (property) accessor. Technically, that's known as a side-effect. In JSF it's especially important, since the accessor may get invoked more than once and at unpredictable times. If you desire a placid life, always make your getter functions read-only and your setters should update only data and not fire off actions of their own. Leave the heavy-duty logic to action processor methods.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
 |
|
|
subject: Calling method in the outputText value attribute
|
|
|