• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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

 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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).
 
author & internet detective
Posts: 42105
933
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
I can't beleive you just said that. Now I need to calm down with this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic