The java beans code does not itself provide string conversion
customization, but it contains quite a lot of similar code, including some
string conversion code that is bean specific (ie not changeable based on
form and/or locale) in the PropertyEditor interface.  What I am working on
is a sub-class of PropertyDescriptor that would have a few additional
methods with a signature something like:

Method getReadStringMethod(Locale loc)
Method getReadStringMethod(Locale loc, String form)
Method setWriteStringMethod(Locale loc)
Method setWriteStringMethod(Locale loc, String form)

and for completeness, I'd like to add display info and verification
handling.
String getDisplayName(Locale loc, String form)
PropertyVerifier getVerifierMethod(Locale loc, String form)

where PropertyVerifier is an interface with methods:
     verify(String value)     -returns true if value is a valid value for
this property for the given locale/form combination.
     String[] getEnumeratedValues() - allows pre-verfication by allowing a
sub-set of the entire possible set of values.
     isNullable()   -determines if null is allowed
     Object minValue()   -returns the minimum value allowed (might return a
Date, or a Number etc, or null if no min)
     Object maxValue()   -returns the maximum value allowed

and there would be a BeanVerifier with just the single method:
     verify(Object bean)
that would verify constraints between values

I'm still in the process of thinking this out, specifically deciding what
return types these methods should have.  It is certainly possible to return
something better than just Method for all of these (ie something that takes
a String instead of an array of objects).  Once I've decided on what these
should return, I would like to create versions that can lookup the required
information from a variety of sources, specifically:
1) One or more configuration files (XML) that configure locale,form info
for the entire application
2) Individual configuration files (XML) associated with the particular bean
type
3) Individual class files associated with the particular bean type

It might be necessary to write a new version of Introspector that would
return this extended information, and might have non-static instances of it
in order to allow different configuration files to be used for different
parts of the application.

Bill Wallace

Fax: (716) 295-4718
Element K
'the knowledge catalyst'
www.elementk.com


                                                                                       
       
                    "Viral V.                                                          
       
                    Tolat"               To:     "'[EMAIL PROTECTED]'"     
       
                    <tolat@integr        <[EMAIL PROTECTED]>               
       
                    al.com>              cc:                                           
       
                                                                                       
       
                    09/27/01             Subject:     RE: Data conversion              
       
                    05:48 PM                                                           
       
                    Please                                                             
       
                    respond to                                                         
       
                    struts-dev                                                         
       
                                                                                       
       
                                                                                       
       




Bill,

I've been looking at the JavaBeans API and I don't see where the String
conversion can be customized.  Maybe you can point me to a class or
interface. I've looked throughout the java.beans package.

Thanks.


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 27, 2001 12:51 PM
To: [EMAIL PROTECTED]
Subject: Re: Data conversion



The to/from string conversion should be done similar to how java beans
works, since it can then be used more generally than just the Struts
framework.  However, it needs some I18N additions which currently aren't
available in the java beans work.

Bill Wallace

Fax: (716) 295-4718
Element K
'the knowledge catalyst'
www.elementk.com




                    Viral Tolat

                    <viral.tolat@int        To:
[EMAIL PROTECTED]
                    egral.com>              cc:



                    09/27/01 03:13          Subject:     Data conversion

                    PM

                    Please respond

                    to struts-dev









Is there any intent to modify the code to centralize conversion of
strings to objects and reverse? Currently, ConvertUtils is used to
convert strings to primitive objects, however, toString is used to
convert the object to a string.

We'd like to integrate in a data conversion framework but to do this
cleanly we need a cental place where all data conversion happens.  In
addition, we'd need to be able to access the request or page context in
order to provide custom conversions on a per page basis.

We've looked at the transformations extension and the Capco Mapper,
however, we don't see how the transformations can be used with html:text

tags to provide data conversion from strings to objects since the Tag is

not involved at all in this process.

Thanks










Reply via email to