File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling method in the outputText value attribute

 
Rahul Juneja
Ranch Hand
Posts: 425
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Arun Sudharsanam
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Himanshu Gupta
Ranch Hand
Posts: 598
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17616
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic