Re: Dynaform Type Conversion

2004-03-26 Thread Joe Germuska
--- Joe Hertz [EMAIL PROTECTED] wrote:
  Does Struts provide a method where I provide it the name of the bean
  defined
  in the struts-config.xml and it return me an instance of the appropriate
  class, with all the dyna properties set up?
At 3:19 PM -0800 3/25/04, Hubert Rabago wrote:
It does for the nightly build and Struts 1.2.0, though I can't recall the
name of the method.  For pre-1.2, you'll need to write code to do that.
There was a thread that discussed this, with the last few messages (of that
thread) still coming in today.  Just look for that.  Richard Yee pasted code
there on how to instantiate a Dyna Bean.  I also pointed to an archive where
I pasted the code I use in my apps to instantiate a Dyna Bean.
Right now, you can look up a FormBeanConfig object from a 
ModuleConfig, and then you can use the FormBeanConfig and the 
ActionServlet to get a new ActionForm instance from RequestUtils. 
This does not go through the request/session scope searching that 
Struts uses when it processes the request parameters into a populated 
ActionForm.

Given the fact that this has come up three or four times in the last 
week, it seems clear that it's time to expose a simple method that 
takes a form bean name and a scope and either finds or creates that 
form bean.  I'm just waiting for a few things to settle down -- 
there's going to be a Struts 1.2.1 release pretty soon now, and we 
have to move the CVS repository to a new location as part of Struts 
becoming a top-level Apache project...  but that stuff should get 
straightened out in the next week or two.

Joe

--
Joe Germuska
[EMAIL PROTECTED]  
http://blog.germuska.com
  Imagine if every Thursday your shoes exploded if you tied them 
the usual way.  This happens to us all the time with computers, and 
nobody thinks of complaining.
-- Jef Raskin

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: DynaForm Type Conversion

2004-03-25 Thread Hubert Rabago
Take a look at BeanUtils.copyProperties.  By default, though, it doesn't
support conversion of dates, since it wouldn't know how you'd want your dates
formatted.  Check the archives of this list, there's been some discussion on
that.  Another archive you can check is that of the commons-user list.

If you're looking for further reduction in code, take a look at
http://www.rabago.net/struts/formdef which I'm working on.  It's alpha, but
an initial release is coming real soon (and I'm looking for folks to help me
develop/maintain it).

I believe the Struts dev team has plans to include functionality like this in
a future version of Struts.  For now, we either make do with BeanUtils, or do
the conversion ourselves, or through third party plugins like what I'm
working on.  If you feel strongly enough about it, you can rant some more on
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27321 though like I said,
the dev team has plans for supporting this functionality in a future version.
 How near or far into the future might be influenced by user requests.  :)


--- Joe Hertz [EMAIL PROTECTED] wrote:
 
 I have a bean I persist with Hibernate. It's properties are:
 
 2 Floats
 1 Integer (the key)
 2 Dates
 
 Now, relying on my handy dandy copies of Struts KickStart, Struts In
 Action, 
 and all of the Web, I'm apparently supposed to declare these methods in the
 
 Form I am using as Strings since automatic type conversion can fubar them.
 
 But Since the JSP I am using is getting these fields with html:text fields,
 I 
 apparently am supposed to have methods in form to do the type conversion
 for 
 me. Okay, that's light years better than putting this in the business
 layer, 
 but fine.
 
 Is there an Automatic way I can get a DynaBean to do this for me? Maybe a
 Get
 (prop, type) and get(prop, type, value) for the types youd find in
 java.lang?
 
 If not, there should be, because it limits what a DynaBean can do in a big 
 kinda way. Why have a type declaration in the DTD if youre only ever going
 to 
 want to use String and String[] ? :-)
 
 I mean, it's not like I couldnt add such a set of methods to my 
 DynaValidatorActionForm subclass, but what I'd want is for the framework to
 
 use them for me without me needing to know about it. (I dont ask for much,
 do 
 I???).
 
 If not, I'd like to continue to use my Subclassed DynaValidatorActionForm 
 anyway, but I am wondering if it is going to be self-defeating to declare 
 custom getters and setters for properties that are declared in struts
 config? 
 Should I just use it as a non-dyna form?
 
 Maybe I've been up too late (okay, I have) but it's the little things like 
 this that makes me feel like Struts is creating work for me rather than 
 saving me from it. 
 
 
 Tx for indulging my sleepy rant.
 -Joe
 
 

__
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Dynaform Type Conversion

2004-03-25 Thread Joe Hertz
Well, I was using copyProperties...or rather I\'d want to. I\'m just trying 
to 
avoid having to declare my Transfer Objects the hard way.

Say I use Mark Lowe\'s idea of the Nested Form Bean (makes sense in alot of 
ways), but I want to do it dynamically. i.e. DynaForm A has a List property 
of what will be a bunch of DynaBean B\'s.

So riddle me this, how do I instantiate a DynaBean myself as it is defined in 
the struts-config.xml?  When it\'s passed in to the Action as the form, it\'s 
all prepped and ready to go. If I instantiate an instance of the class 
myself, it\'s got no dynaproperties. I know BeanUtils will provide 
functionality to do this, but I would hope there\'s an exposed method that 
does based straight out of the contents struts-config.

Does Struts provide a method where I provide it the name of the bean defined 
in the struts-config.xml and it return me an instance of the appropriate 
class, with all the dyna properties set up?

-Joe

 -Original Message-
 From: Hubert Rabago [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, March 25, 2004 8:38 AM
 To: Struts Users Mailing List
 Subject: Re: DynaForm Type Conversion
 
 
 Take a look at BeanUtils.copyProperties.  By default, though, 
 it doesn\'t support conversion of dates, since it wouldn\'t 
 know how you\'d want your dates formatted.  Check the archives 
 of this list, there\'s been some discussion on that.  Another 
 archive you can check is that of the commons-user list.
 
 If you\'re looking for further reduction in code, take a look 
 at http://www.rabago.net/struts/formdef which I\'m working on. 
  It\'s alpha, but an initial release is coming real soon (and 
 I\'m looking for folks to help me develop/maintain it).
 
 I believe the Struts dev team has plans to include 
 functionality like this in a future version of Struts.  For 
 now, we either make do with BeanUtils, or do the conversion 
 ourselves, or through third party plugins like what I\'m 
 working on.  If you feel strongly enough about it, you can 
 rant some more on 
 http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27321 
 though like I said, the dev team has plans for supporting 
 this functionality in a future version.  How near or far into 
 the future might be influenced by user requests.  :)
 
 
 --- Joe Hertz [EMAIL PROTECTED] wrote:
  
  I have a bean I persist with Hibernate. It\'s properties are:
  
  2 Floats
  1 Integer (the key)
  2 Dates
  
  Now, relying on my handy dandy copies of Struts KickStart, 
 Struts In 
  Action, and all of the Web, I\'m apparently supposed to 
 declare these 
  methods in the
  
  Form I am using as Strings since automatic type conversion 
 can fubar 
  them.
  
  But Since the JSP I am using is getting these fields with html:text 
  fields, I apparently am supposed to have methods in form to do the 
  type conversion for
  me. Okay, that\'s light years better than putting this in 
 the business
  layer, 
  but fine.
  
  Is there an Automatic way I can get a DynaBean to do this for me? 
  Maybe a Get (prop, type) and get(prop, type, value) for the 
 types youd 
  find in java.lang?
  
  If not, there should be, because it limits what a DynaBean 
 can do in a 
  big
  kinda way. Why have a type declaration in the DTD if youre 
 only ever going
  to 
  want to use String and String[] ? :-)
  
  I mean, it\'s not like I couldnt add such a set of methods to my
  DynaValidatorActionForm subclass, but what I\'d want is for 
 the framework to
  
  use them for me without me needing to know about it. (I 
 dont ask for 
  much, do I???).
  
  If not, I\'d like to continue to use my Subclassed 
  DynaValidatorActionForm
  anyway, but I am wondering if it is going to be 
 self-defeating to declare 
  custom getters and setters for properties that are declared 
 in struts
  config? 
  Should I just use it as a non-dyna form?
  
  Maybe I\'ve been up too late (okay, I have) but it\'s the 
 little things 
  like
  this that makes me feel like Struts is creating work for me 
 rather than 
  saving me from it. 
  
  
  Tx for indulging my sleepy rant.
  -Joe
  
  
 
 __
 Do you Yahoo!?
 Yahoo! Finance Tax Center - File online. File on time. 
http://taxes.yahoo.com/filing.html

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Dynaform Type Conversion

2004-03-25 Thread Hubert Rabago
It does for the nightly build and Struts 1.2.0, though I can't recall the
name of the method.  For pre-1.2, you'll need to write code to do that. 
There was a thread that discussed this, with the last few messages (of that
thread) still coming in today.  Just look for that.  Richard Yee pasted code
there on how to instantiate a Dyna Bean.  I also pointed to an archive where
I pasted the code I use in my apps to instantiate a Dyna Bean. 

--- Joe Hertz [EMAIL PROTECTED] wrote:
 Well, I was using copyProperties...or rather I\'d want to. I\'m just trying
 
 to 
 avoid having to declare my Transfer Objects the hard way.
 
 Say I use Mark Lowe\'s idea of the Nested Form Bean (makes sense in alot of
 
 ways), but I want to do it dynamically. i.e. DynaForm A has a List property
 
 of what will be a bunch of DynaBean B\'s.
 
 So riddle me this, how do I instantiate a DynaBean myself as it is defined
 in 
 the struts-config.xml?  When it\'s passed in to the Action as the form,
 it\'s 
 all prepped and ready to go. If I instantiate an instance of the class 
 myself, it\'s got no dynaproperties. I know BeanUtils will provide 
 functionality to do this, but I would hope there\'s an exposed method that 
 does based straight out of the contents struts-config.
 
 Does Struts provide a method where I provide it the name of the bean
 defined 
 in the struts-config.xml and it return me an instance of the appropriate 
 class, with all the dyna properties set up?
 
 -Joe
 
  -Original Message-
  From: Hubert Rabago [mailto:[EMAIL PROTECTED] 
  Sent: Thursday, March 25, 2004 8:38 AM
  To: Struts Users Mailing List
  Subject: Re: DynaForm Type Conversion
  
  
  Take a look at BeanUtils.copyProperties.  By default, though, 
  it doesn\'t support conversion of dates, since it wouldn\'t 
  know how you\'d want your dates formatted.  Check the archives 
  of this list, there\'s been some discussion on that.  Another 
  archive you can check is that of the commons-user list.
  
  If you\'re looking for further reduction in code, take a look 
  at http://www.rabago.net/struts/formdef which I\'m working on. 
   It\'s alpha, but an initial release is coming real soon (and 
  I\'m looking for folks to help me develop/maintain it).
  
  I believe the Struts dev team has plans to include 
  functionality like this in a future version of Struts.  For 
  now, we either make do with BeanUtils, or do the conversion 
  ourselves, or through third party plugins like what I\'m 
  working on.  If you feel strongly enough about it, you can 
  rant some more on 
  http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27321 
  though like I said, the dev team has plans for supporting 
  this functionality in a future version.  How near or far into 
  the future might be influenced by user requests.  :)
  
  
  --- Joe Hertz [EMAIL PROTECTED] wrote:
   
   I have a bean I persist with Hibernate. It\'s properties are:
   
   2 Floats
   1 Integer (the key)
   2 Dates
   
   Now, relying on my handy dandy copies of Struts KickStart, 
  Struts In 
   Action, and all of the Web, I\'m apparently supposed to 
  declare these 
   methods in the
   
   Form I am using as Strings since automatic type conversion 
  can fubar 
   them.
   
   But Since the JSP I am using is getting these fields with html:text 
   fields, I apparently am supposed to have methods in form to do the 
   type conversion for
   me. Okay, that\'s light years better than putting this in 
  the business
   layer, 
   but fine.
   
   Is there an Automatic way I can get a DynaBean to do this for me? 
   Maybe a Get (prop, type) and get(prop, type, value) for the 
  types youd 
   find in java.lang?
   
   If not, there should be, because it limits what a DynaBean 
  can do in a 
   big
   kinda way. Why have a type declaration in the DTD if youre 
  only ever going
   to 
   want to use String and String[] ? :-)
   
   I mean, it\'s not like I couldnt add such a set of methods to my
   DynaValidatorActionForm subclass, but what I\'d want is for 
  the framework to
   
   use them for me without me needing to know about it. (I 
  dont ask for 
   much, do I???).
   
   If not, I\'d like to continue to use my Subclassed 
   DynaValidatorActionForm
   anyway, but I am wondering if it is going to be 
  self-defeating to declare 
   custom getters and setters for properties that are declared 
  in struts
   config? 
   Should I just use it as a non-dyna form?
   
   Maybe I\'ve been up too late (okay, I have) but it\'s the 
  little things 
   like
   this that makes me feel like Struts is creating work for me 
  rather than 
   saving me from it. 
   
   
   Tx for indulging my sleepy rant.
   -Joe
   
   
  
  __
  Do you Yahoo!?
  Yahoo! Finance Tax Center - File online. File on time. 
 http://taxes.yahoo.com/filing.html
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional