aspose file tools*
The moose likes JSF and the fly likes Calling method in the outputText value attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Calling method in the outputText value attribute" Watch "Calling method in the outputText value attribute" New topic
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:
<iceutputText 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: 16012
    
  19

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling method in the outputText value attribute