Re: Newbie: File upload w/Direct Actions and added parameters
Re: Newbie: File upload w/Direct Actions and added parameters
- Subject: Re: Newbie: File upload w/Direct Actions and added parameters
- From: Lindsey Hotchkies <email@hidden>
- Date: Wed, 24 May 2006 12:35:34 -0700 (PDT)
Thanks for your help!
I tried setting a hidden field in the form, but in the
direct action, request().formValues() only returns the
file from the WOFileUpload component, nothing else.
I am confused because I have used Direct Actions for
non-fileUpload actions, and parameters (whether they
are within a form or set in a hyperlink binding) are
passed in the request. Now that I am using a
WOFileUpload object inside a form, the other form
components and bindings seem to be ignored.
Here are my components (notice I tried to pass a
parameter in the form as well as the HiddenField):
Form2: WOForm {
enctype = "multipart/form-data";
multipleSubmit = true;
?mainphotoid = mainPhotoId;
directActionName = "ProcessTwinFileUploadAsData";
actionClass = "DirectAction";
}
Upload1 : WOFileUpload {
filePath = aFileName;
data = aFileContents;
mimeType = uploadMimeType;
name = "thefile";
}
mainphotoid: WOHiddenField {
name = "mainphotoid";
value = mainPhotoId;
}
This is the result of request().formValues() in
ProcessTwinFileUploadAsDataAction:
{thefile.filename = ("bunny-3c.jpg"); thefile =
(<class
com.webobjects.appserver._private.WOInputStreamData
(stream
com.webobjects.appserver.WOMultipartIterator$_WOFormDataInputStream@a269e2
of length 0), has NOT been accessed>);
thefile.mimetype = ("image/jpeg"); }
The file upload is successful, but no parameter.
Any ideas?
Thanks!
-Lindsey
--- Amedeo Mantica <email@hidden> wrote:
> You can pass parameter to the direct action
>
> look at this code in direct action:
>
>
> public WOActionResults myPersonalAction()
> { //ending with
> "Action" in mendatory
> String theVariable =
> (String)request().formValueForKey("myvariable");
>
> YourWOComponent nextPage =
> (YourWOComponent)pageWithName
> ("YourWOComponent"); //replace "YourWOComponent"
> with the name of
> your component
> nextPage.setTheVariable(theVariable);
> return nextPage;
> }
>
> and you can acccess to the page using this url
>
> http://.../myapp.woa/wa/myPersonal?myvariable=try
> //note
> myPersonal without "Action"
>
> Best Regards
> Amedeo
>
>
> On 24/mag/06, at 08:53, Lindsey Hotchkies wrote:
>
> > Newbie file upload question:
> >
> > I am trying to upload a file using a direct action
> and
> > a WOFileUpload component. I can get the file to
> upload
> > correctly, but my issue is with sending a
> parameter to
> > the direct action so that it can properly set up
> the
> > next page and save the file into the database with
> the
> > right info.
> > The values I need for the file in the database are
> > determined by the page from which the user
> triggers
> > the upload. So, to use direct actions I think I
> need
> > to send those values as parameters (bindings to
> the
> > WOFileUpload or Form) with the upload. I tried
> binding
> > them to the WOFileUpload and/or the Form with no
> > success (the values don't appear in
> > request().formValues() in the DA).
> >
> > Is there any way to send parameters (custom
> bindings)
> > with a Direct Action file upload?
> >
> > Thanks!!
> > -Lindsey
> > _______________________________________________
> > Do not post admin requests to the list. They will
> be ignored.
> > Webobjects-dev mailing list
> (email@hidden)
> > Help/Unsubscribe/Update your Subscription:
> >
>
>
> > 40macintossicati.com
> >
> > This email sent to email@hidden
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden