Hello David,
Comments are below.
Thursday, June 14, 2001, 8:31:45 AM, you wrote:
DW> I just saw the type conversion thread going on in the
DW> user list, but I've thought about this for a bit and
DW> you mentioned possibly modeling or taking code from an
DW> existing framework.
DW> How closely have you looked at Barracuda Ted? Some of
DW> what they do is interesting. I think we could make an
DW> ActionForm derivitive that loosely followed their
DW> steps in processing an object.
DW> Barracuda
DW> -------------
DW> FormMap
DW> FormElement
DW> key - the key/property name
DW> type - the FormType (ie. String, Boolean,
DW> Integer, etc)
DW> defaultVal - the default value (ie. the value to
DW> be used if the key is not present in the form source)
DW> validator - FormValidators responsible for
DW> validating this particular element
DW> allowMultiples - is it possible for this key to
DW> have multiple values in the form source
DW> add these other fields to the field element in the
DW> valdation.xml
DW> public class BarracudaActionForm extends ActionForm {
DW> Map formMap = new HashMap();
DW> public Map getFormMap() { return formMap; }
DW> public void setFormMap(Map formMap) {
DW> this.formMap = formMap;
DW> }
DW> public void reset(ActionMapping mapping,
DW> HttpServletRequest request) {
DW> formMap.clear();
DW> }
DW> }
Good. I spent two weeks to implement such approach to the struts -
main ideas really are congruent with listed above. But I trying to
create new design ideas - here is smooth change to the new paradigm.
DW> populate map
DW> perform transformations from map to real objects using
DW> subclasses of java.text.Format as Rey Francois has
DW> suggested, if the transformation was successful remove
DW> the item from the Map. (Struts html tags would need to
DW> be able to try the Map first and then the actual
DW> ActionForm property. This could tie in with a dynamic
DW> ActionForm class)
One thing. Guess one field successfully converted to the target type,
but another has errors. Whole form needs to be displayed with all
fields - not only failed to convert.
Struts html tags can use additional attribute - 'useMap' for example -
to switch between map and properties. And if attribute not present in
tag then search map firstly and after that go to the properties.
DW> populate default values
DW> perform other validations
How will errors of validation process be stored to show it after form
validation? There must exist some kind of bridge between validation
process and html:errors tag.
DW> Or we could make a transformation class for the
DW> general transformation package you suggested and you
DW> would pass in any two JavaBeans and it could map
DW> values between the two. Something like this could be
DW> used from a short cut method in the ActionForm.
DW> public Object getDataBean() {
DW> // Class name could come from an xml
DW> transform/mapping file
DW> Object bean =
DW> Class.forName(className).newInstance();
DW> Transformation.transform(this, bean);
DW> return bean;
DW> }
DW> It seems from discussions that most people would
DW> prefer the latter based on current usage on the lists,
DW> but you wouldn't need two classes with the first
DW> approach and it is from a working framework. What is
DW> your opinion?
I think that ActionForms hard coding is not accelerator for
development process. Dynamic properties support something like that is
good solution for flexible application.
DW> David
DW> --- Ted Husted <[EMAIL PROTECTED]> wrote:
>> I still have the feeling that we lack a decent
>> foundation package to do
>> the grunt work of typecasting and String formatting,
>> so that things like
>> a Validation servlet and something like a
>> <bean:transform
>> picture="##/##/##" > tag could share a common
>> codebase.
>>
>> We might want to start with something like this:
>>
>> <
>>
DW> http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg01522.html
>> >
>>
>> Perhaps as an extension to java.text.Format, as Rey
>> Francois has been
>> suggesting:
>>
>> <
>>
DW> http://www.mail-archive.com/struts-user@jakarta.apache.org/msg02711.html
>> >
>>
>> And then look at how we can use this package to
>> extend the Validation
>> servlet and enhance the bean tags.
>>
>> It's a little confusing now, since validations,
>> conversions, and
>> transformations and are closely linked, but appear
>> at different points
>> in the input / store / output continuum. Even so, I
>> think the processes
>> have enough in common to create a cohesive package,
>> even if you would
>> not use every method on any one layer of a MVC
>> application.
>>
>>
>> -- Ted Husted, Husted dot Com, Fairport NY USA.
>> -- Custom Software ~ Technical Services.
>> -- Tel 716 737-3463.
>> -- http://www.husted.com/about/struts/
DW> __________________________________________________
DW> Do You Yahoo!?
DW> Spot the hottest trends in music, movies, and more.
DW> http://buzz.yahoo.com/
--
Best regards,
Oleg mailto:[EMAIL PROTECTED]