The following comment has been added to this issue:
Author: Cameron Braid
Created: Tue, 26 Aug 2003 10:48 AM
Body:
I forgot to mention that it would also be a good idea to provide a public API to allow
programatic registration of converters. (both toString and fromString)
An example of this need is :
Currently, we use Hibernate with PersistentStringEnums. We already have a list of
these Class objects. We have a PersistentStringEnumConverter that we use for all of
our enums, therefore it would be better if we could iterate over this list,
registering our PersistentStringEnumConverter for the PersistentStringEnum classes.
Something like
ConverterManager.getInstance().registerToStringConverter(Converter converterInstance,
Class fromClass)
ConverterManager.getInstance().registerFromStringConverter(Converter
converterInstance, Class toClass)
I would think that the Converter interface is quite simple :
public Object convert(Object, Class toClass)
In the case of a 1:1 mapping from types to converters, the toClass isn't needed,
though if you have a converted that handles multiple classes, it is needed.
---------------------------------------------------------------------
View the issue:
http://jira.opensymphony.com/secure/ViewIssue.jspa?key=WW-271
Here is an overview of the issue:
---------------------------------------------------------------------
Key: WW-271
Summary: Converter framework needs to be able to support plugable to String
converters
Type: Improvement
Status: Assigned
Priority: Major
Project: WebWork
Components:
Views
Assignee: Patrick Lightbody
Reporter: Cameron Braid
Created: Tue, 26 Aug 2003 10:03 AM
Updated: Tue, 26 Aug 2003 10:03 AM
Description:
Currently they conversion framework allows for plugable converters that are used when
converting http request string values into the action properties.
This works really well.
However, when converting action properties to strings the vm macros use toString().
I believe that this system needs to be configurable. Allowing user defined converter
classes to be specified for converting to string.
I also propose that a public API be created to allow reuse of the converters within
actions and views.
i.e. a custom form that posts to an action. The action doesn't use the
params-interceptor because the number of form fields are determined at runtime. The
action processes the http request itself, calling
CustomClass cc =
(CustomClass)ConverterManager.getInstance().convertFromString(requestMap.get("thingy"),
CustomClass.class);
AND
in a velocity view. Put the ConverterManager instance as into the velo context as
$converterManager
#foreach $item in $items
<input type='text'
value='${stringUtil.toHtml(converterManager.convertToString($item))}'>
#end
Some reasons for having this feature :
a) most of the custom types in our applications use interfaces, with dynamic proxies.
I wish to not rely on toString()
b) allows customization of default date formatting, numeric formatting, etc..
ALSO :
As demonstrated above, there exists a need to a stringUtil class to escape HTML.
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://jira.opensymphony.com/secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines
at the same time. Free trial click here:http://www.vmware.com/wl/offer/358/0
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork