Re: Validating WOUpload form element before submitting
Re: Validating WOUpload form element before submitting
- Subject: Re: Validating WOUpload form element before submitting
- From: Randall Perry <email@hidden>
- Date: Tue, 20 Apr 2004 12:20:56 -0400
Seems like a MAJOR omission to me to have a WOForm component with no methods
to do form validation other than Javascript.
I discovered how to validate WOText elements. By:
Putting action in WOForm
Using static Submit button
Adding bindings to WOForm: name and onsubmit
Writing javascript code to validate WOText fields
In order to pass java vars to javascript I created an onsubmitCode var
within a set method for the variable I needed in javascript. For example,
the following shows an alert displaying fileName when the form is submitted:
public void setFileName(String newFileName)
{
fileName = newFileName;
onsubmitCode = "var fileName = '" + fileName + "alert('fileName = '
+ fileName);";
}
From .wod file:
Form1: WOForm {
actionClass = "DirectAction";
directActionName = "test";
name="theForm";
onsubmit = onsubmitCode;
}
But, discovered that if a WOFileUpload element is placed in the form, and
the form is submitted, it generates javascript errors:
Warning: Form contains a file input, but is missing method=POST and
enctype=multipart/form-data on the form.
I added the 'method' binding to the form, but WO prevented me from creating
an 'enctype' binding (presumably because it already does so).
So, yeah, there's no way to do this using WOFileUpload (that I can see).
> At 3:45 PM -0400 4/19/04, Randall Perry wrote:
>> Also, is it possible using WOFileUpload to prevent the data from being
>> uploaded after form submission and just pass the filename so a subsequent
>> page can do the actual upload?
>
> I can not think of any way to do that.
>
>
>>> Got a WO component page which requests a filename from a user. The form is
>>> submitted to a DirectAction for processing.
>>>
>>> But, I need to make sure the filename starts with the customer's
>>> file code and
>>> ends with '.zip' before allowing the upload.
>>>
>>> I'm using WOFileUpload within a WOForm. Should I send the form to an action
>>> that checks the name before sending it on to the DA, or is there a way to
>>> do
>>> form validation of WOForms like you can with the javascript
>>> onsubmit() method?
--
Randall Perry
sysTame
Xserve Web Hosting/Co-location
Website Development/Promotion
Mac Consulting/Sales
http://www.systame.com/
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.