A getter with a paramteter is not a bean property, and so won't be accessible with the usual tags.
This is true, and in general, Paul's suggestion below is the right way to go.
Still, it's interesting to note out that Struts (or more accurately, commons-beanutils) does support one special case where you can pass a parameter, the MappedProperty. This is a property which requires a String parameter in the accessor: theoretically a key to a map. You can subvert this to have an accessor which does something else with the String, such as use it for a date format.
I did this for a Struts 1.0 project before the JSTL was released and when the Struts bean tags also hadn't yet added any formatting control.
Joe
I'd suggest that the formatting of your date is the responsibility of your view layer, and not the form bean. The easiest way to do waht you ar after is to use the JSTL's <fmt: formatDate> tag:
<fmt: formatDate> <bean:write name="theClass" property="lastChangedDateString"/> </fmt: formatDate>
This will automatically pick up the request locale.
Paul
-----Original Message----- From: Vaclavik Radek [mailto:[EMAIL PROTECTED] Sent: Friday, August 27, 2004 9:53 AM To: [EMAIL PROTECTED] Subject: Bean's get method with parameter
Hi,
this question may have a simple answer, but currently I don't see it :)
From my JSP I wanto access some bean's property which returns, say, date as string in localized format, depending on currently selected locale (Globals.LOCALE_KEY).
Currently, I have method like this in my bean: getLastChangedDateString(Locale locale){ .. return some_string }
Therefor, the returned date string is formatted accordingly to current locale. Is it possible to pass this parameter (locale) to the get method, from jsp? Something like: <bean:write name="theClass" property="lastChangedDateString(here_I_need_the_current_locale)"/>
OR
another solution came to my mind: Have the method getLastChagedDateString() without parameters and let the method find out the current locale itself. But here I don't know wheter, and if so then how, the bean has access to current session in order to retrieve the current locale.
Any hints?
Thanks in advance.
Radek
_____________________________
Ing. Radek Václavík ICS Department - webmaster
ZeNTIVA a.s. U Kabelovny 130, 102 37 Praha 10 Czech Republic tel. +420 267 243 296 _____________________________
**********************************************************************
Axios Email Confidentiality Footer
Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such case, you should destroy this message, and notify us immediately. If you or your employer does not consent to Internet email messages of this kind, please advise us immediately. Opinions, conclusions and other information expressed in this message are not given or endorsed by my Company or employer unless otherwise indicated by an authorised representative independent of this message.
WARNING:
While Axios Systems Ltd takes steps to prevent computer viruses from being transmitted via electronic mail attachments we cannot guarantee that attachments do not contain computer virus code. You are therefore strongly advised to undertake anti virus checks prior to accessing the attachment to this electronic mail. Axios Systems Ltd grants no warranties regarding performance use or quality of any attachment and undertakes no liability for loss or damage howsoever caused.
**********************************************************************
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--
Joe Germuska
[EMAIL PROTECTED]
http://blog.germuska.com
"In fact, when I die, if I don't hear 'A Love Supreme,' I'll turn back; I'll know I'm in the wrong place."
- Carlos Santana