File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Want to call a method rather than property in html:text Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Want to call a method rather than property in html:text" Watch "Want to call a method rather than property in html:text" New topic
Author

Want to call a method rather than property in html:text

Tanveer Rameez
Ranch Hand

Joined: Dec 11, 2000
Posts: 158
Hi,

I have a struts html tag:
<html:text name="myFormBean" property="myProperty" />
I want to call a method instead of the property, i.e I want something like this:
<html:text name="myFormBean" property="someMethod" />
the someMethod returns a string and has signature : public String someMethod().
How do I do it?
Also I would like to have a set method so that the value can be set though that method, rather than set directly into a property.The method can be public void someMethod(String s);
Is there anything like get-method and set-method attribute in the html:text to use?
Thanks in Advance
Tanveer


Author of JPhotoBrush Pro (www.jphotobrushpro.com)
Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456
i'm afraid you have to stick to java bean conventions, which requires getters and setters for the values you want to obtain.

but: that's a feature, not a bug :-)

Is there any specific reason why your String has to be obtained through someMethod() instead of getSomeString()?

bye,
jan
[ October 13, 2006: Message edited by: Jan Groth ]
Tanveer Rameez
Ranch Hand

Joined: Dec 11, 2000
Posts: 158
Originally posted by Jan Groth:

Is there any specific reason why your String has to be obtained through someMethod() instead of getSomeString()?


I want the value to be determined at runtime based on certain conditions. The value in the form bean property is set once but meanwhile certain conditions changes and so only the displayed value should change(while the property should remain same).
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30324
    
150

Tanveer,
Your get and set methods could do that though. There is nothing dictating that a getter can only return a property and a setter can only store a property. You can do validation, calculations, etc within the standard named methods.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
wood burning stoves
 
subject: Want to call a method rather than property in html:text