You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Federica Oltolina <fe...@ubiquity.it> on 2009/04/17 15:31:30 UTC
Is there a way to make Struts2 working with other methods different
than classic getter/setter?
Hi all,
my head office yesterday asked me if it's possible to declare
in some special file a mapping between actions and their methods
because he'd like to use custom getter/setter methods containing some
little formatting operations.
For example, for the action attribute:
/
private String bankingCode;/
he liked having in our action more than one getter that would sound like:
/getBankingCodePrecedeedByAnyZero();
getBankingCodePrecedeedByFiveZero();
and so on...
/and then in the jsp that corresponds to the action cited above ho would
Struts2 to be able
to understanding the correct setter/getter method, for example he'd like
to write
/...
<s:property value="//bankingCodePrecedeedByAnyZero//"/>
...//
/
obtaining the result of the method /getBankingCodePrecedeedByAnyZero();
/Someone knows if there is a way to do this?
No matter if this sounds like a swearword for a Struts2 good user
or if this is not smart, he asked me this.
Thanks in advance
Federica
Re: Is there a way to make Struts2 working with other methods
different than classic getter/setter?
Posted by Pierre Lavignotte <pi...@gmail.com>.
Hi,
Not sure to understand but I think you don't have any problem...
If you use a tag like <s:property value="bankingCodePrecedeedByAnyZero"/>
Struts will not look to the attribute bankingCodePrecedeedByAnyZero but for
the method getBankingCodePrecedeedByAnyZero().
You can even write this method without having the
bankingCodePrecedeedByAnyZero attribute at all, or name it myBankingCode, or
superMan or anything you want.
Hope it helps,
Pierre
Cordialement,
Pierre Lavignotte
Ingénieur Conception & Développement
http://pierre.lavignotte.googlepages.com
On Fri, Apr 17, 2009 at 3:31 PM, Federica Oltolina <
federica.oltolina@ubiquity.it> wrote:
> Hi all,
> my head office yesterday asked me if it's possible to declare
> in some special file a mapping between actions and their methods
> because he'd like to use custom getter/setter methods containing some
> little formatting operations.
>
> For example, for the action attribute:
> /
> private String bankingCode;/
>
> he liked having in our action more than one getter that would sound like:
>
> /getBankingCodePrecedeedByAnyZero();
> getBankingCodePrecedeedByFiveZero();
> and so on...
>
> /and then in the jsp that corresponds to the action cited above ho would
> Struts2 to be able
> to understanding the correct setter/getter method, for example he'd like to
> write
>
> /...
> <s:property value="//bankingCodePrecedeedByAnyZero//"/>
> ...//
> /
> obtaining the result of the method /getBankingCodePrecedeedByAnyZero();
>
> /Someone knows if there is a way to do this?
> No matter if this sounds like a swearword for a Struts2 good user
> or if this is not smart, he asked me this.
>
> Thanks in advance
> Federica
>
>
Re: Is there a way to make Struts2 working with other methods different
than classic getter/setter?
Posted by Federica Oltolina <fe...@ubiquity.it>.
Thank you all, that worked fine!
Regards
Federica
Jim Kiley wrote:
> You can do that right out of the box. I do it all the time. Give it a try.
> Create method with those names, and reference them in JSPs by those names.
> It should work.
> jk
>
> On Fri, Apr 17, 2009 at 9:31 AM, Federica Oltolina <
> federica.oltolina@ubiquity.it> wrote:
>
>
>> Hi all,
>> my head office yesterday asked me if it's possible to declare
>> in some special file a mapping between actions and their methods
>> because he'd like to use custom getter/setter methods containing some
>> little formatting operations.
>>
>> For example, for the action attribute:
>> /
>> private String bankingCode;/
>>
>> he liked having in our action more than one getter that would sound like:
>>
>> /getBankingCodePrecedeedByAnyZero();
>> getBankingCodePrecedeedByFiveZero();
>> and so on...
>>
>> /and then in the jsp that corresponds to the action cited above ho would
>> Struts2 to be able
>> to understanding the correct setter/getter method, for example he'd like to
>> write
>>
>> /...
>> <s:property value="//bankingCodePrecedeedByAnyZero//"/>
>> ...//
>> /
>> obtaining the result of the method /getBankingCodePrecedeedByAnyZero();
>>
>> /Someone knows if there is a way to do this?
>> No matter if this sounds like a swearword for a Struts2 good user
>> or if this is not smart, he asked me this.
>>
>> Thanks in advance
>> Federica
>>
>>
>>
>
>
>
Re: Is there a way to make Struts2 working with other methods different
than classic getter/setter?
Posted by Dave Newton <ne...@yahoo.com>.
Martin Gainty wrote:
> if you mean spring specify struts.objectFactory.spring.autowire
> in /resources/struts-plugin.xml e.g.
>
> struts.objectFactory.spring.autoWire = type
Whoops-I think you replied to the wrong message! This thread was about
accessing getter methods of the action.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Is there a way to make Struts2 working with other methods
different than classic getter/setter?
Posted by Martin Gainty <mg...@hotmail.com>.
if you mean spring specify struts.objectFactory.spring.autowire
in /resources/struts-plugin.xml e.g.
struts.objectFactory.spring.autoWire = type
The autowire property can be set to several options.
name
Auto-wire by matching the name of the bean in Spring with the name of the property in your action. This is the default
type
Auto-wire by looking for a bean registered
with Spring of the same type as the property in your action. This
requires you to have only one bean of this type registered with Spring
auto
Spring will attempt to auto-detect the best method for auto-wiring your action
constructor
Spring will auto-wire the parameters of the bean's constructor
http://cwiki.apache.org/S2PLUGINS/spring-plugin.html
hth
Martin
______________________________________________
Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung / Note de déni et de confidentialité
This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
> From: jhkiley@summa-tech.com
> Date: Fri, 17 Apr 2009 09:39:57 -0400
> Subject: Re: Is there a way to make Struts2 working with other methods different than classic getter/setter?
> To: user@struts.apache.org
>
> You can do that right out of the box. I do it all the time. Give it a try.
> Create method with those names, and reference them in JSPs by those names.
> It should work.
> jk
>
> On Fri, Apr 17, 2009 at 9:31 AM, Federica Oltolina <
> federica.oltolina@ubiquity.it> wrote:
>
> > Hi all,
> > my head office yesterday asked me if it's possible to declare
> > in some special file a mapping between actions and their methods
> > because he'd like to use custom getter/setter methods containing some
> > little formatting operations.
> >
> > For example, for the action attribute:
> > /
> > private String bankingCode;/
> >
> > he liked having in our action more than one getter that would sound like:
> >
> > /getBankingCodePrecedeedByAnyZero();
> > getBankingCodePrecedeedByFiveZero();
> > and so on...
> >
> > /and then in the jsp that corresponds to the action cited above ho would
> > Struts2 to be able
> > to understanding the correct setter/getter method, for example he'd like to
> > write
> >
> > /...
> > <s:property value="//bankingCodePrecedeedByAnyZero//"/>
> > ...//
> > /
> > obtaining the result of the method /getBankingCodePrecedeedByAnyZero();
> >
> > /Someone knows if there is a way to do this?
> > No matter if this sounds like a swearword for a Struts2 good user
> > or if this is not smart, he asked me this.
> >
> > Thanks in advance
> > Federica
> >
> >
>
>
> --
> Jim Kiley
> Senior Technical Consultant | Summa
> [p] 412.258.3346
> http://www.summa-tech.com
_________________________________________________________________
Windows Live™: Life without walls.
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1b_explore_042009
Re: Is there a way to make Struts2 working with other methods
different than classic getter/setter?
Posted by Jim Kiley <jh...@summa-tech.com>.
You can do that right out of the box. I do it all the time. Give it a try.
Create method with those names, and reference them in JSPs by those names.
It should work.
jk
On Fri, Apr 17, 2009 at 9:31 AM, Federica Oltolina <
federica.oltolina@ubiquity.it> wrote:
> Hi all,
> my head office yesterday asked me if it's possible to declare
> in some special file a mapping between actions and their methods
> because he'd like to use custom getter/setter methods containing some
> little formatting operations.
>
> For example, for the action attribute:
> /
> private String bankingCode;/
>
> he liked having in our action more than one getter that would sound like:
>
> /getBankingCodePrecedeedByAnyZero();
> getBankingCodePrecedeedByFiveZero();
> and so on...
>
> /and then in the jsp that corresponds to the action cited above ho would
> Struts2 to be able
> to understanding the correct setter/getter method, for example he'd like to
> write
>
> /...
> <s:property value="//bankingCodePrecedeedByAnyZero//"/>
> ...//
> /
> obtaining the result of the method /getBankingCodePrecedeedByAnyZero();
>
> /Someone knows if there is a way to do this?
> No matter if this sounds like a swearword for a Struts2 good user
> or if this is not smart, he asked me this.
>
> Thanks in advance
> Federica
>
>
--
Jim Kiley
Senior Technical Consultant | Summa
[p] 412.258.3346
http://www.summa-tech.com
Re: Is there a way to make Struts2 working with other methods different
than classic getter/setter?
Posted by Dave Newton <ne...@yahoo.com>.
Federica Oltolina wrote:
> my head office yesterday asked me if it's possible to declare
> in some special file a mapping between actions and their methods
> because he'd like to use custom getter/setter methods containing some
> little formatting operations.
>
> For example, for the action attribute:
> /
> private String bankingCode;/
>
> he liked having in our action more than one getter that would sound like:
>
> /getBankingCodePrecedeedByAnyZero();
> getBankingCodePrecedeedByFiveZero();
> and so on...
>
> /and then in the jsp that corresponds to the action cited above ho would
> Struts2 to be able
> to understanding the correct setter/getter method, for example he'd like
> to write
>
> /...
> <s:property value="//bankingCodePrecedeedByAnyZero//"/>
> ...//
> /
> obtaining the result of the method /getBankingCodePrecedeedByAnyZero();
>
> /Someone knows if there is a way to do this?
> No matter if this sounds like a swearword for a Struts2 good user
> or if this is not smart, he asked me this.
As others have said, this works out-of-the-box.
There are other, simpler mechanisms for doing such formatting, though,
that don't require loading up the action class with a million getters,
though!
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org