 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Alex Woitak Guest
|
Posted: Fri Apr 23, 2004 10:30 pm Post subject: Struts question |
|
|
Hi,
within the execute method of my struts action I have only ActionMapping,
ActionForward and HttpServletRequest/Response objects available.
But I need (there is no other way, since the service API to be used is not
written by me) an ActionEvent object (as it would be available in an
actionPerformed method) to hand it over to some service object's method.
Is there any way to hand an ActionEvent object over to the execute method or
to get an ActionEvenzt object in some way within the execute method ?
I am sure there is a way, since otherwise everybody who would need an
ActionEvent object within the execute method could not use Struts - and
ActionEvent objects have often been used in actionPerformed methods earlier.
Please help !
Thanks a lot !
-----= Posted via Newsfeed.Com, Uncensored Usenet News =-----
http://www.newsfeed.com - The #1 Newsgroup Service in the World!
-----== 100,000 Groups! - 19 Servers! - Unlimited Download! =-----
|
|
| Back to top |
|
 |
Yan Lijun Guest
|
Posted: Wed Apr 28, 2004 1:57 pm Post subject: Re: Struts question |
|
|
????why do you need a ActionEvent object .
in my option ActionEvent is used in awt or swing,while struts is a tecnology of
server side.i can not find any relation between them .
if you should have one,you can create one yourself
ActionEvent event=new ActionEvent(...);
ÔÚ Sat, 24 Apr 2004 00:30:19 +0200 ʱ, "Alex Woitak" <nospam (AT) web (DOT) de> дÁË:
--
[email]gumpagain (AT) 163 (DOT) com[/email]
/**
/* Java Is Not Platform-independent.It Is The Platform!
*/
|
|
| Back to top |
|
 |
Oscar kind Guest
|
Posted: Tue Aug 24, 2004 10:17 pm Post subject: Re: Struts Question |
|
|
Bryce <spamtrap (AT) berzerker-soft (DOT) com> wrote:
| Quote: | What I do is format using DecimalFormat when I write the value to my
Struts Form. All fields in my Struts form are strings. When I retrieve
a data object, the fields are copied tot he Struts form. For all
Integer, BigDecimal, etc, I use the appropriate Format class.
|
A slightly different approach would be to let the non-String properties
of your Form bean have a twin that represents the same value as a String.
The Form bean can then convert from and to the String representations
(you'll have to call the conversion methods yourself though, unless you
extend Struts).
--
Oscar Kind http://home.hccnet.nl/okind/
Software Developer for contact information, see website
PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2
|
|
| Back to top |
|
 |
WJ Guest
|
Posted: Wed Aug 25, 2004 2:12 am Post subject: Re: Struts Question |
|
|
Thanks. I basically did this. I formatted the number using a NumberFormat,
set the form in the action class, then returned to the page.
I was hoping there was a slick format in struts for this (that works).
~Cheers!
|
|
| Back to top |
|
 |
Bryce Guest
|
Posted: Wed Aug 25, 2004 5:30 pm Post subject: Re: Struts Question |
|
|
On Wed, 25 Aug 2004 00:17:01 +0200, Oscar kind <oscar (AT) danwa (DOT) net>
wrote:
| Quote: | Bryce <spamtrap (AT) berzerker-soft (DOT) com> wrote:
What I do is format using DecimalFormat when I write the value to my
Struts Form. All fields in my Struts form are strings. When I retrieve
a data object, the fields are copied tot he Struts form. For all
Integer, BigDecimal, etc, I use the appropriate Format class.
A slightly different approach would be to let the non-String properties
of your Form bean have a twin that represents the same value as a String.
The Form bean can then convert from and to the String representations
(you'll have to call the conversion methods yourself though, unless you
extend Struts).
|
An even different approach is if your data objects and your struts
forms have the same name, you can use the Jakarta Commons BeanUtils
classes.
BeanUtils.copyProperties(Object destination, Object original);
Will copy all the properties from original to destination (using
reflection). The cool part is, you can "register" your own conversion
objects.
I do this so I don't have to bother writing extra methods to get
certain fields as different types.
--
now with more cowbell
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|