I'd also like support for validation, but at a higher level. Ideally I would
like Web UI components which could be used in a JSP, and configured with
data type and formatting/validation information, somewhat like the JClass
Swing components. See also the new FormattedTextField (?) coming soon to
Swing.
A component would be able to hold a text value and a data value. The text
value could hold the value entered by the user, prior to validation, then
this could be played back to the user if validation failed on that
component. If validation succeeded, the data value would be updated, then
the text value would be replaced by the formatted value, using the data
value and the formatter.
Formatting should support internationalized numbers, money, dates, percents
etc., depending on user locale for that request/session, together with
custom patterns as suggested below.
Of course, this could be implemented on top of Ted's general package.
There is also a requirement for this formatting/validation for Swing
components, so the basic formatting/validation should not be tied to HTTP,
or to Swing for that matter.
This suggestion of components also relates to another To Do item, namely
dynamic forms. The Swing analogy is a JPanel, or similar JComponent, which
can contain simple components such as a JTextField (FormattedTextField?),
arranged using a Layout. (Hmmm... layouts and events would be nice too, but
let's not get too carried away, after all HTML pages are never going to be
as capable as a Swing GUI.)
Andrew Harris
[EMAIL PROTECTED]
-----Original Message-----
From: Ted Husted [mailto:[EMAIL PROTECTED]]
Sent: 01 June 2001 14:52
To: [EMAIL PROTECTED]
Subject: Re: Proposed feature: Bean property transformations
What I'm missing is a comprehensive, general package for converting data
types and formatting properties for presentation. Most of this
functionality is available somewhere in java and javax space, but it's
spread around.
What would be most useful, I think, is a single, generic package that
provided
(1) validation of Strings using regular expressions (a la David
Winterfeldt's servlet), with direct support for native and JDBC
datatypes,
(2) binary to String and String to binary conversions for all native and
standard types, and support for adding others,
(3) given a formatting specification ("00#.##") and data of any
supported type, return a formatted presentation String,
(4) support for locale-senstive transformations with (3),
(5) support for extending the formatting specification for unusual
circumstances, and
(6) provide simple date-calculation methods and a countdown presentation
format (seconds, minutes, hours, or days from now until then).
We could then use this helper object during the validation cycle to
convert incoming Strings to the other types needed by business-logic
objects, AND pass through the functionality from a <bean:writeTransform
> tag, that could pull a property from a given bean, transform it, and
return a formatted String for direct use by the view.
If there is not something like this already out there, I've very
interested in getting started on this package, since I really, really
need it for my own projects. Could be a nice addition to the Commons ...
I'm cross-posting this to Struts user in case someone can suggest a
package that already provides this functionality.
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/struts/