Re: http parameter casting

From: Malte (forgetme_at_spam_here.nowhere.com)
Date: 02/05/05


Date: Sat, 05 Feb 2005 09:55:42 +0100

Justin wrote:
> This is a web form design discussion. When handling input from a web
> form I usually have a "form" object that handles getting the parameters
> from the request validating etc. I want to store what the user enters
> in variables of the appropriate type. (i.e. if they enter a quantity it
> comes through the request as a String but should be stored as an int).
> Now let's say the user is prompted to enter a date. The "form" class
> attempts to parse the data but fails. When the form renders with the
> error message explaining the required format for dates I want to
> populate the input with the users previous entry. There in lies the
> problem. I've lost what they entered when I tried to parse the date
> and it failed. That is unless I store all of the user's original
> string input in the form object. Another option might be to have a
> form manager object that maintains the data as Strings until it's valid
> and then kicks out a business object that contains appropriately typed
> values. I'm interested in other suggestions and opinions on what
> I've listed above.
>

In my current application project I have a need to:

a: get form input from a user
b: validate the input and stick it in Oracle
c: be able to get the data for subsequent editing
d: supply all functions via html and via xml based web services

Therefore I have chosen this model:

Generate HTML output from XML using XSLT. Using this model it is very
easy to:

a: accept form input
b: pass the HttpRequest to a FormChecker class that returns a form
object. This object also has a getAsXML() method that wil render the
form's fields as xml. This xml is the same as the xml that would be
returned from the database.

Thus, I can reuse my XSL stylesheet. If there is data, it will be shown,
if there is not, an input field in the form will just be empty.

If validation fails, all other fields are in the xml, and I have a small
method that will put out an error message pointing to the offending
input object.

Oh yes, I do know about Struts, but the xml requirement (for web
services) is a strong one, and I have no intention of writing two GUI's,
because it is my experience that once the business logic is in place,
the GUI will be changed frequently.



Relevant Pages

  • Re: Storing condition in bitfield?
    ... constraints with XML or string. ... and validation function to a small integer or so. ... At best, we could store the function in a medium-to-large integer, but then you've got the performance overhead of decrypting the integer into runnable PHP code, or of directly interpreting the integer somehow. ... Putting strings and XML will be of overhead, ...
    (comp.programming)
  • Re: How to store numerical data in metadata
    ... Dan Musicant wrote: ... :Given those data elements for every value, I might be tempted to move:towards XML, that wholly modrun thang:that feels like a total throwback. ... :You could store each data item in a memo field as a "node" from a larger:XML document that doesn't actually exist: ... I can still run it in FPW. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Wanted:MAIL.MAI structure definition
    ... exports using XML. ... SMTP mail and all the software out there which processes RFC-compliant headers ... I would maintain that to store mail messages you would need to use CLOB ... Every mail message arriving into an OpenVMS system gets its format converted. ...
    (comp.os.vms)
  • Re: ruby / rexml / xpath bug?
    ... puts of the XML. ... end # end each store ... Longitude: -74.107299 ...
    (comp.lang.ruby)
  • RE: Embedd XML within XML - Possible ??
    ... it is not quite recommended that we store such ... If you do want to store complex XML data into the attribute field. ... Microsoft MSDN Online Support Lead ... ID Field and String Field ...
    (microsoft.public.dotnet.languages.csharp)