You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Viral Tolat <vi...@integral.com> on 2001/10/05 19:26:06 UTC

Re: [ANNOUNCE] Struts Console

Nathan,

I've just looked at your code and it's definitely something we'd like to use.  I
have some comments on the implementation.

1. In ConvertUtils, you don't use the property editor to convert the object to a
string, the code still uses toString. It would be better to use getAsText on the
property editor for this.

2. The code in the Struts taglibs uses RequestUtils.lookup() to get an "object"
property value and then uses toString to convert to a string.  It would be great
to fix up this code as well so that it uses the property editor to convert from
object to string.  There are several places where toString is just used.  Maybe
we can add a new attribute to the existing tags to specify a property editor
class or descriptor.

3. My last point is that we would like a mechanism that allows the use of a
local property editor manager as there is often more than one way to represent
an object as a string.  The thought is that we could allow the ActionForm to
supply PropertyEditors on a per property basis as opposed to a per class basis.
If we enhance the tags to allow a property editor, the tag could insert the
property editor class name into the form as a hidden field and then we can pick
this up on the populate to use that property editor to convert the string back
to an object.  This would require rewriting RequestUtils.populate().

We'd be happy to work with you on the above changes.

Regards,
Viral


Nathan Coast wrote:

> Hi Ted,
>
> >
> > I'll try to update the TODO list, since many
> > items there are actually being tested, are already done, or just
> > obsolete.
> >
>
> bit off topic from the original post but seeing as your talking about the
> todo list.... I spoted this on the list:
>
> > PropertyEditor Support. Add support for JavaBeans that include
> > a PropertyEditor class for conversion to and from the string
> > representation used in an HTML input field. This support should
> > operate in a manner consistent with the way that standard JSP
> > tags do in JSP 1.2.
>
> I've implemented a proof of concept of this in the commons.beanutils package
> and posted this to the commons-dev list but got no response back, (src
> attached).  If this is wanted for inclusion then I'll gladly clean the code
> up and write more tests.
>
> In summary: Using this code, form bean properties can be any type (assuming
> a PropertyEditor class is provided).  PropertyEditors which provide the same
> functionality as the current ConvertUtils are included in the jar
>
> changes to ConvertUtils
> 1) removed of all conversion code (virtually all of the code is now for the
> defaults)
> 2) default values opened to package scope to enable the PropertyEditor
> classes to use the default values
> 3) registration of the PropertyEditor classes for use with the basic types
> and object wrappers in the static initialiser.
>
> other changes:
> addition of the basic property editors.
> addition of a java.util.Date property editor (example of a non-basic
> property editor)
> added a test to the BeanUtil test case to test the populate method for a
> variety of cases (by no means exhaustive).
>
> The only reason we have to implement all of the Basic Property Editors is
> because of the default property functionality (provide a default value if
> parsing fails - standard editors throw IllegalArgumentException).  Without
> this functionality the we could use the PropertyEditor classes that come
> with the VM.
>
> Cheers
> Nathan
>
> **********************************************************************
> This email and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom they
> are addressed. If you have received this email in error please notify
> the system manager.
>
> This footnote also confirms that this email message has been swept by
> MIMEsweeper at LevelSeas for the presence of computer viruses.
>
> www.mimesweeper.com
> **********************************************************************
>
>   ------------------------------------------------------------------------
>                     Name: beanutils.zip
>    beanutils.zip    Type: Zip Compressed Data (application/x-zip-compressed)
>                 Encoding: base64