• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Calling method in the outputText value attribute

 
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
<ice:outputText value="#{bean.name}"/>

and code in the bean as follows:

String Name;

//Getters and setters for the Variable
 
Ranch Hand
Posts: 598
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 24499
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic