Hi All,
I want to upload file for party, for which I am using uploadPartyContentFile service. The issue is I have a form with many fields & the "<input type="file>" field and I have set the enctype to "multipart/form-data" of the form, and for form validation I am using simple-method event, inspite of me entering the data the validation gets failed, because the the fields data is not passed, when using "multipart/form-data" and when I remove the enctype of the form the fields data is passed to the simple-method. Am I missing some config settings ? Regards, Abdullah |
Hi All,
I have a user registration form, wherein the user fill all the user details and can also upload a file. I have made the form enctype="multipart/form-data", method="post" and action="<@ofbizUrl>createUser</@ofbizUrl>" Below is my "createUser" request-map : <request-map uri="createUser> <event type="simple" path="com/test/UserEvents.xml" invoke="validateUserForm"/> <response name="success" type="request" value="createUserService"/> </request-map> I am validation the user registration form using simple-method, simple-map-processor. Now the issue is when I submit the form the form data is not submitted and that's why the validation fails, and if I remove enctype="multipart/form-data" the form data is submitted but I need to use enctype for file upload. What do I need to do to make the form work with the simple-method validation and enctype ? Thanks, Abdullah |
Hi Abdullah,
You won't get the form data directly when you use multipart/form-data we need to process the request the get the parameters. We use java end point to do that. I am not sure if it works with simple methods. Here is what I did I created a utility method that gets all the parameters when posted from form of enctype as multipart/form-data so here are some implementation pointers - I included import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.commons.fileupload.disk.DiskFileItemFactory; then in the method I used FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); And further did List items = upload.parseRequest(request); Now iterate the items list While iterating inside the loop you can fetch the parameters if (item.isFormField()) { String fieldName = item.getFieldName(); Note: item is an iterator object Thanks, Tushar J.Abhyankar Amicon Technologies Pvt. Ltd.(Mumbai) India's No. 1 OFBiz Service Provider. -----Original Message----- From: abdullah shaikh [mailto:[hidden email]] Sent: Thursday, February 19, 2009 11:34 AM To: [hidden email] Subject: uploading party content Hi All, I have a user registration form, wherein the user fill all the user details and can also upload a file. I have made the form enctype="multipart/form-data", method="post" and action="<@ofbizUrl>createUser</@ofbizUrl>" Below is my "createUser" request-map : <request-map uri="createUser> <event type="simple" path="com/test/UserEvents.xml" invoke="validateUserForm"/> <response name="success" type="request" value="createUserService"/> </request-map> I am validation the user registration form using simple-method, simple-map-processor. Now the issue is when I submit the form the form data is not submitted and that's why the validation fails, and if I remove enctype="multipart/form-data" the form data is submitted but I need to use enctype for file upload. What do I need to do to make the form work with the simple-method validation and enctype ? Thanks, Abdullah |
One correction in the Note
item is an FileItem object not an iterator object. You also require to Import import org.apache.commons.fileupload.FileItem; -----Original Message----- From: Tushar Abhyankar [mailto:[hidden email]] Sent: Thursday, February 19, 2009 12:25 PM To: [hidden email] Subject: RE: uploading party content Hi Abdullah, You won't get the form data directly when you use multipart/form-data we need to process the request the get the parameters. We use java end point to do that. I am not sure if it works with simple methods. Here is what I did I created a utility method that gets all the parameters when posted from form of enctype as multipart/form-data so here are some implementation pointers - I included import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.commons.fileupload.disk.DiskFileItemFactory; then in the method I used FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); And further did List items = upload.parseRequest(request); Now iterate the items list While iterating inside the loop you can fetch the parameters if (item.isFormField()) { String fieldName = item.getFieldName(); Note: item is an iterator object Thanks, Tushar J.Abhyankar Amicon Technologies Pvt. Ltd.(Mumbai) India's No. 1 OFBiz Service Provider. -----Original Message----- From: abdullah shaikh [mailto:[hidden email]] Sent: Thursday, February 19, 2009 11:34 AM To: [hidden email] Subject: uploading party content Hi All, I have a user registration form, wherein the user fill all the user details and can also upload a file. I have made the form enctype="multipart/form-data", method="post" and action="<@ofbizUrl>createUser</@ofbizUrl>" Below is my "createUser" request-map : <request-map uri="createUser> <event type="simple" path="com/test/UserEvents.xml" invoke="validateUserForm"/> <response name="success" type="request" value="createUserService"/> </request-map> I am validation the user registration form using simple-method, simple-map-processor. Now the issue is when I submit the form the form data is not submitted and that's why the validation fails, and if I remove enctype="multipart/form-data" the form data is submitted but I need to use enctype for file upload. What do I need to do to make the form work with the simple-method validation and enctype ? Thanks, Abdullah |
Thanks Tushar, I will try the given approach.
On Thu, Feb 19, 2009 at 12:33 PM, Tushar Abhyankar < [hidden email]> wrote: > One correction in the Note > item is an FileItem object not an iterator object. > > You also require to Import > import org.apache.commons.fileupload.FileItem; > > > -----Original Message----- > From: Tushar Abhyankar [mailto:[hidden email]] > Sent: Thursday, February 19, 2009 12:25 PM > To: [hidden email] > Subject: RE: uploading party content > > Hi Abdullah, > You won't get the form data directly when you use > multipart/form-data we need to process the request the get the parameters. > We use java end point to do that. I am not sure if it works with simple > methods. > > Here is what I did > > I created a utility method that gets all the parameters when posted from > form of enctype as multipart/form-data > > so here are some implementation pointers - > > I included > import org.apache.commons.fileupload.servlet.ServletFileUpload; > import org.apache.commons.fileupload.disk.DiskFileItemFactory; > > then in the method I used > > FileItemFactory factory = new DiskFileItemFactory(); > ServletFileUpload upload = new ServletFileUpload(factory); > > And further did > > List items = upload.parseRequest(request); > > Now iterate the items list > > While iterating inside the loop you can fetch the parameters > > if (item.isFormField()) { > String fieldName = item.getFieldName(); > > > Note: item is an iterator object > > Thanks, > Tushar J.Abhyankar > Amicon Technologies Pvt. Ltd.(Mumbai) > India's No. 1 OFBiz Service Provider. > > -----Original Message----- > From: abdullah shaikh [mailto:[hidden email]] > Sent: Thursday, February 19, 2009 11:34 AM > To: [hidden email] > Subject: uploading party content > > Hi All, > > > I have a user registration form, wherein the user fill all the user details > and can also upload a file. > > I have made the form enctype="multipart/form-data", method="post" and > action="<@ofbizUrl>createUser</@ofbizUrl>" > > Below is my "createUser" request-map : > > <request-map uri="createUser> > <event type="simple" path="com/test/UserEvents.xml" > invoke="validateUserForm"/> > <response name="success" type="request" value="createUserService"/> > </request-map> > > I am validation the user registration form using simple-method, > simple-map-processor. > > Now the issue is when I submit the form the form data is not submitted and > that's why the validation fails, > and if I remove enctype="multipart/form-data" the form data is submitted > but > I need to use enctype for file upload. > > > What do I need to do to make the form work with the simple-method > validation > and enctype ? > > > Thanks, > Abdullah > > |
Hi Tushar,
The approach you said is already implemented in ServiceEventHandler, this class puts the bytebuffer, filesize, filename & content type into service context I tried to get these values, but I was not able to get the ByteBuffer. Any idea on this .. Thanks, Abdullah On Thu, Feb 19, 2009 at 12:45 PM, abdullah shaikh < [hidden email]> wrote: > Thanks Tushar, I will try the given approach. > > > On Thu, Feb 19, 2009 at 12:33 PM, Tushar Abhyankar < > [hidden email]> wrote: > >> One correction in the Note >> item is an FileItem object not an iterator object. >> >> You also require to Import >> import org.apache.commons.fileupload.FileItem; >> >> >> -----Original Message----- >> From: Tushar Abhyankar [mailto:[hidden email]] >> Sent: Thursday, February 19, 2009 12:25 PM >> To: [hidden email] >> Subject: RE: uploading party content >> >> Hi Abdullah, >> You won't get the form data directly when you use >> multipart/form-data we need to process the request the get the parameters. >> We use java end point to do that. I am not sure if it works with simple >> methods. >> >> Here is what I did >> >> I created a utility method that gets all the parameters when posted from >> form of enctype as multipart/form-data >> >> so here are some implementation pointers - >> >> I included >> import org.apache.commons.fileupload.servlet.ServletFileUpload; >> import org.apache.commons.fileupload.disk.DiskFileItemFactory; >> >> then in the method I used >> >> FileItemFactory factory = new DiskFileItemFactory(); >> ServletFileUpload upload = new ServletFileUpload(factory); >> >> And further did >> >> List items = upload.parseRequest(request); >> >> Now iterate the items list >> >> While iterating inside the loop you can fetch the parameters >> >> if (item.isFormField()) { >> String fieldName = item.getFieldName(); >> >> >> Note: item is an iterator object >> >> Thanks, >> Tushar J.Abhyankar >> Amicon Technologies Pvt. Ltd.(Mumbai) >> India's No. 1 OFBiz Service Provider. >> >> -----Original Message----- >> From: abdullah shaikh [mailto:[hidden email]] >> Sent: Thursday, February 19, 2009 11:34 AM >> To: [hidden email] >> Subject: uploading party content >> >> Hi All, >> >> >> I have a user registration form, wherein the user fill all the user >> details >> and can also upload a file. >> >> I have made the form enctype="multipart/form-data", method="post" and >> action="<@ofbizUrl>createUser</@ofbizUrl>" >> >> Below is my "createUser" request-map : >> >> <request-map uri="createUser> >> <event type="simple" path="com/test/UserEvents.xml" >> invoke="validateUserForm"/> >> <response name="success" type="request" value="createUserService"/> >> </request-map> >> >> I am validation the user registration form using simple-method, >> simple-map-processor. >> >> Now the issue is when I submit the form the form data is not submitted and >> that's why the validation fails, >> and if I remove enctype="multipart/form-data" the form data is submitted >> but >> I need to use enctype for file upload. >> >> >> What do I need to do to make the form work with the simple-method >> validation >> and enctype ? >> >> >> Thanks, >> Abdullah >> >> > |
Hi Abdullah,
Looking at ServiceEventHandler it should work. Its going in the else part where it uses ByteBuffer, its failing this condition if (item.isFormField() || item.getName() == null), may be we are missing something in form widget or ftl. Thanks, Tushar J.Abhyankar Amicon Technologies Pvt. Ltd.(Mumbai) India's No. 1 OFBiz Service Provider. -----Original Message----- From: abdullah shaikh [mailto:[hidden email]] Sent: Thursday, February 19, 2009 4:55 PM To: [hidden email] Subject: Re: uploading party content Hi Tushar, The approach you said is already implemented in ServiceEventHandler, this class puts the bytebuffer, filesize, filename & content type into service context I tried to get these values, but I was not able to get the ByteBuffer. Any idea on this .. Thanks, Abdullah On Thu, Feb 19, 2009 at 12:45 PM, abdullah shaikh < [hidden email]> wrote: > Thanks Tushar, I will try the given approach. > > > On Thu, Feb 19, 2009 at 12:33 PM, Tushar Abhyankar < > [hidden email]> wrote: > >> One correction in the Note >> item is an FileItem object not an iterator object. >> >> You also require to Import >> import org.apache.commons.fileupload.FileItem; >> >> >> -----Original Message----- >> From: Tushar Abhyankar [mailto:[hidden email]] >> Sent: Thursday, February 19, 2009 12:25 PM >> To: [hidden email] >> Subject: RE: uploading party content >> >> Hi Abdullah, >> You won't get the form data directly when you use >> multipart/form-data we need to process the request the get the >> We use java end point to do that. I am not sure if it works with simple >> methods. >> >> Here is what I did >> >> I created a utility method that gets all the parameters when posted from >> form of enctype as multipart/form-data >> >> so here are some implementation pointers - >> >> I included >> import org.apache.commons.fileupload.servlet.ServletFileUpload; >> import org.apache.commons.fileupload.disk.DiskFileItemFactory; >> >> then in the method I used >> >> FileItemFactory factory = new DiskFileItemFactory(); >> ServletFileUpload upload = new ServletFileUpload(factory); >> >> And further did >> >> List items = upload.parseRequest(request); >> >> Now iterate the items list >> >> While iterating inside the loop you can fetch the parameters >> >> if (item.isFormField()) { >> String fieldName = item.getFieldName(); >> >> >> Note: item is an iterator object >> >> Thanks, >> Tushar J.Abhyankar >> Amicon Technologies Pvt. Ltd.(Mumbai) >> India's No. 1 OFBiz Service Provider. >> >> -----Original Message----- >> From: abdullah shaikh [mailto:[hidden email]] >> Sent: Thursday, February 19, 2009 11:34 AM >> To: [hidden email] >> Subject: uploading party content >> >> Hi All, >> >> >> I have a user registration form, wherein the user fill all the user >> details >> and can also upload a file. >> >> I have made the form enctype="multipart/form-data", method="post" and >> action="<@ofbizUrl>createUser</@ofbizUrl>" >> >> Below is my "createUser" request-map : >> >> <request-map uri="createUser> >> <event type="simple" path="com/test/UserEvents.xml" >> invoke="validateUserForm"/> >> <response name="success" type="request" >> </request-map> >> >> I am validation the user registration form using simple-method, >> simple-map-processor. >> >> Now the issue is when I submit the form the form data is not submitted and >> that's why the validation fails, >> and if I remove enctype="multipart/form-data" the form data is submitted >> but >> I need to use enctype for file upload. >> >> >> What do I need to do to make the form work with the simple-method >> validation >> and enctype ? >> >> >> Thanks, >> Abdullah >> >> > |
For me its working but am stuck in attachUploadToDataResource service .. its
not able to get the file name :( On Thu, Feb 19, 2009 at 5:34 PM, Tushar Abhyankar < [hidden email]> wrote: > Hi Abdullah, > Looking at ServiceEventHandler it should work. Its going in > the else part where it uses ByteBuffer, its failing this condition > if (item.isFormField() || item.getName() == null), may be we are missing > something in form widget or ftl. > > Thanks, > Tushar J.Abhyankar > Amicon Technologies Pvt. Ltd.(Mumbai) > India's No. 1 OFBiz Service Provider. > > -----Original Message----- > From: abdullah shaikh [mailto:[hidden email]] > Sent: Thursday, February 19, 2009 4:55 PM > To: [hidden email] > Subject: Re: uploading party content > > Hi Tushar, > > The approach you said is already implemented in ServiceEventHandler, this > class puts the bytebuffer, filesize, filename & content type into service > context > > I tried to get these values, but I was not able to get the ByteBuffer. > > Any idea on this .. > > Thanks, > Abdullah > > > On Thu, Feb 19, 2009 at 12:45 PM, abdullah shaikh < > [hidden email]> wrote: > > > Thanks Tushar, I will try the given approach. > > > > > > On Thu, Feb 19, 2009 at 12:33 PM, Tushar Abhyankar < > > [hidden email]> wrote: > > > >> One correction in the Note > >> item is an FileItem object not an iterator object. > >> > >> You also require to Import > >> import org.apache.commons.fileupload.FileItem; > >> > >> > >> -----Original Message----- > >> From: Tushar Abhyankar [mailto:[hidden email]] > >> Sent: Thursday, February 19, 2009 12:25 PM > >> To: [hidden email] > >> Subject: RE: uploading party content > >> > >> Hi Abdullah, > >> You won't get the form data directly when you use > >> multipart/form-data we need to process the request the get the > parameters. > >> We use java end point to do that. I am not sure if it works with simple > >> methods. > >> > >> Here is what I did > >> > >> I created a utility method that gets all the parameters when posted from > >> form of enctype as multipart/form-data > >> > >> so here are some implementation pointers - > >> > >> I included > >> import org.apache.commons.fileupload.servlet.ServletFileUpload; > >> import org.apache.commons.fileupload.disk.DiskFileItemFactory; > >> > >> then in the method I used > >> > >> FileItemFactory factory = new DiskFileItemFactory(); > >> ServletFileUpload upload = new ServletFileUpload(factory); > >> > >> And further did > >> > >> List items = upload.parseRequest(request); > >> > >> Now iterate the items list > >> > >> While iterating inside the loop you can fetch the parameters > >> > >> if (item.isFormField()) { > >> String fieldName = item.getFieldName(); > >> > >> > >> Note: item is an iterator object > >> > >> Thanks, > >> Tushar J.Abhyankar > >> Amicon Technologies Pvt. Ltd.(Mumbai) > >> India's No. 1 OFBiz Service Provider. > >> > >> -----Original Message----- > >> From: abdullah shaikh [mailto:[hidden email]] > >> Sent: Thursday, February 19, 2009 11:34 AM > >> To: [hidden email] > >> Subject: uploading party content > >> > >> Hi All, > >> > >> > >> I have a user registration form, wherein the user fill all the user > >> details > >> and can also upload a file. > >> > >> I have made the form enctype="multipart/form-data", method="post" and > >> action="<@ofbizUrl>createUser</@ofbizUrl>" > >> > >> Below is my "createUser" request-map : > >> > >> <request-map uri="createUser> > >> <event type="simple" path="com/test/UserEvents.xml" > >> invoke="validateUserForm"/> > >> <response name="success" type="request" > value="createUserService"/> > >> </request-map> > >> > >> I am validation the user registration form using simple-method, > >> simple-map-processor. > >> > >> Now the issue is when I submit the form the form data is not submitted > and > >> that's why the validation fails, > >> and if I remove enctype="multipart/form-data" the form data is submitted > >> but > >> I need to use enctype for file upload. > >> > >> > >> What do I need to do to make the form work with the simple-method > >> validation > >> and enctype ? > >> > >> > >> Thanks, > >> Abdullah > >> > >> > > > > |
Anyways I used the java event to upload the file and its working fine :)
but dont know why the ServiceEventHandler is not working On Thu, Feb 19, 2009 at 5:57 PM, abdullah shaikh < [hidden email]> wrote: > For me its working but am stuck in attachUploadToDataResource service .. > its not able to get the file name :( > > > On Thu, Feb 19, 2009 at 5:34 PM, Tushar Abhyankar < > [hidden email]> wrote: > >> Hi Abdullah, >> Looking at ServiceEventHandler it should work. Its going in >> the else part where it uses ByteBuffer, its failing this condition >> if (item.isFormField() || item.getName() == null), may be we are missing >> something in form widget or ftl. >> >> Thanks, >> Tushar J.Abhyankar >> Amicon Technologies Pvt. Ltd.(Mumbai) >> India's No. 1 OFBiz Service Provider. >> >> -----Original Message----- >> From: abdullah shaikh [mailto:[hidden email]] >> Sent: Thursday, February 19, 2009 4:55 PM >> To: [hidden email] >> Subject: Re: uploading party content >> >> Hi Tushar, >> >> The approach you said is already implemented in ServiceEventHandler, this >> class puts the bytebuffer, filesize, filename & content type into service >> context >> >> I tried to get these values, but I was not able to get the ByteBuffer. >> >> Any idea on this .. >> >> Thanks, >> Abdullah >> >> >> On Thu, Feb 19, 2009 at 12:45 PM, abdullah shaikh < >> [hidden email]> wrote: >> >> > Thanks Tushar, I will try the given approach. >> > >> > >> > On Thu, Feb 19, 2009 at 12:33 PM, Tushar Abhyankar < >> > [hidden email]> wrote: >> > >> >> One correction in the Note >> >> item is an FileItem object not an iterator object. >> >> >> >> You also require to Import >> >> import org.apache.commons.fileupload.FileItem; >> >> >> >> >> >> -----Original Message----- >> >> From: Tushar Abhyankar [mailto:[hidden email]] >> >> Sent: Thursday, February 19, 2009 12:25 PM >> >> To: [hidden email] >> >> Subject: RE: uploading party content >> >> >> >> Hi Abdullah, >> >> You won't get the form data directly when you use >> >> multipart/form-data we need to process the request the get the >> parameters. >> >> We use java end point to do that. I am not sure if it works with simple >> >> methods. >> >> >> >> Here is what I did >> >> >> >> I created a utility method that gets all the parameters when posted >> from >> >> form of enctype as multipart/form-data >> >> >> >> so here are some implementation pointers - >> >> >> >> I included >> >> import org.apache.commons.fileupload.servlet.ServletFileUpload; >> >> import org.apache.commons.fileupload.disk.DiskFileItemFactory; >> >> >> >> then in the method I used >> >> >> >> FileItemFactory factory = new DiskFileItemFactory(); >> >> ServletFileUpload upload = new ServletFileUpload(factory); >> >> >> >> And further did >> >> >> >> List items = upload.parseRequest(request); >> >> >> >> Now iterate the items list >> >> >> >> While iterating inside the loop you can fetch the parameters >> >> >> >> if (item.isFormField()) { >> >> String fieldName = item.getFieldName(); >> >> >> >> >> >> Note: item is an iterator object >> >> >> >> Thanks, >> >> Tushar J.Abhyankar >> >> Amicon Technologies Pvt. Ltd.(Mumbai) >> >> India's No. 1 OFBiz Service Provider. >> >> >> >> -----Original Message----- >> >> From: abdullah shaikh [mailto:[hidden email]] >> >> Sent: Thursday, February 19, 2009 11:34 AM >> >> To: [hidden email] >> >> Subject: uploading party content >> >> >> >> Hi All, >> >> >> >> >> >> I have a user registration form, wherein the user fill all the user >> >> details >> >> and can also upload a file. >> >> >> >> I have made the form enctype="multipart/form-data", method="post" and >> >> action="<@ofbizUrl>createUser</@ofbizUrl>" >> >> >> >> Below is my "createUser" request-map : >> >> >> >> <request-map uri="createUser> >> >> <event type="simple" path="com/test/UserEvents.xml" >> >> invoke="validateUserForm"/> >> >> <response name="success" type="request" >> value="createUserService"/> >> >> </request-map> >> >> >> >> I am validation the user registration form using simple-method, >> >> simple-map-processor. >> >> >> >> Now the issue is when I submit the form the form data is not submitted >> and >> >> that's why the validation fails, >> >> and if I remove enctype="multipart/form-data" the form data is >> submitted >> >> but >> >> I need to use enctype for file upload. >> >> >> >> >> >> What do I need to do to make the form work with the simple-method >> >> validation >> >> and enctype ? >> >> >> >> >> >> Thanks, >> >> Abdullah >> >> >> >> >> > >> >> > |
Free forum by Nabble | Edit this page |