J
Justin
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.
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.