|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
[Tobago] File upload tc:file tx:fileHi,
I'm attempting to use the tc:file / tx:file control to upload a file. But when I click the button responsible for submitting the page the associated action is not invoked, the page is refreshed and showed without any styles (!?). Without the tx:file-tag everything works fine. JSP: <tx:file value="#{controller.fileItem}" required="false" label="Upload file" /> <tc:button action="#{controller.save}" label="Save"/> I have added the following to my web.xml: <filter> <filter-name>multipartFormdataFilter</filter-name> <filter-class>org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataFilter</filter-class> <init-param> <description>Set the size limit for uploaded files...</description> <param-name>uploadMaxFileSize</param-name> <param-value>20m</param-value> </init-param> <init-param> <description>Set the upload repository path for uploaded files. Default value is java.io.tmpdir.</description> <param-name>uploadRepositoryPath</param-name> <param-value>c:/tmp</param-value> </init-param> </filter> <filter-mapping> <filter-name>multipartFormdataFilter</filter-name> <url-pattern>/faces/*</url-pattern> </filter-mapping> There are no errors or warnings, the debug log says: ... DEBUG 21 okt 16:38:30 org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataFilter - Wrapping org.apache.catalina.connector.RequestFacade with ContentType="multipart/form-data; boundary=---------------------------209722283024901" into TobagoMultipartFormdataRequest ... DEBUG 21 okt 16:38:30 org.apache.myfaces.tobago.renderkit.html.scarborough.standard.tag.FileRenderer - Uploaded file name : "image001.gif" size = 5558 ... I'm using Tobago 1.0.23 / MyFaces 1.1.6 / Tomcat 6.0.20 / Java 6u15. I hope someone can provide a hint. Thanks. Best regards Soeren |
|
|
Re: [Tobago] File upload tc:file tx:fileHi Søren,
I've checked the upload and can't find problems. The reference/upload.jsp file in the demo is not full functional yet. So I added some stuff. You may apply these changes on tobago-example-demo on your system and look if it works fine or at any differences. Hope that helps. Regards Udo ------------------------------------------------------------------ reference/upload.jsp <tx:file label="Upload file:" value="#{upload.file}" /> <tc:button label="Submit" defaultCommand="true" action="#{upload.upload}" /> ------------------------------------------------------------------ faces-config.xml <managed-bean> <managed-bean-name>upload</managed-bean-name> <managed-bean-class>org.apache.myfaces.tobago.example.reference.Upload</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> ------------------------------------------------------------------ Upload.java (new) package org.apache.myfaces.tobago.example.reference; import org.apache.commons.fileupload.FileItem; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class Upload { private static final Log LOG = LogFactory.getLog(Upload.class); private FileItem file; public String upload() { LOG.info("type=" + file.getContentType()); LOG.info("file=" + file.get().length); LOG.info("name=" + file.getName()); return null; } public FileItem getFile() { return file; } public void setFile(FileItem file) { this.file = file; } } ------------------------------------------------------------------ Søren Hjarlvig schrieb: > Hi, > > I'm attempting to use the tc:file / tx:file control to upload a file. > But when I click the button responsible for submitting the page the > associated action is not invoked, the page is refreshed and showed > without any styles (!?). > Without the tx:file-tag everything works fine. > > JSP: > <tx:file value="#{controller.fileItem}" required="false" label="Upload > file" /> > <tc:button action="#{controller.save}" label="Save"/> > > I have added the following to my web.xml: > > <filter> > <filter-name>multipartFormdataFilter</filter-name> > > <filter-class>org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataFilter</filter-class> > <init-param> > <description>Set the size limit for uploaded > files...</description> > <param-name>uploadMaxFileSize</param-name> > <param-value>20m</param-value> > </init-param> > <init-param> > <description>Set the upload repository path for uploaded > files. Default value is java.io.tmpdir.</description> > <param-name>uploadRepositoryPath</param-name> > <param-value>c:/tmp</param-value> > </init-param> > </filter> > <filter-mapping> > <filter-name>multipartFormdataFilter</filter-name> > <url-pattern>/faces/*</url-pattern> > </filter-mapping> > > There are no errors or warnings, the debug log says: > ... > DEBUG 21 okt 16:38:30 > org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataFilter - > Wrapping org.apache.catalina.connector.RequestFacade with > ContentType="multipart/form-data; > boundary=---------------------------209722283024901" into > TobagoMultipartFormdataRequest > ... > DEBUG 21 okt 16:38:30 > org.apache.myfaces.tobago.renderkit.html.scarborough.standard.tag.FileRenderer > - Uploaded file name : "image001.gif" size = 5558 > ... > > I'm using Tobago 1.0.23 / MyFaces 1.1.6 / Tomcat 6.0.20 / Java 6u15. > > I hope someone can provide a hint. Thanks. > > Best regards > > Soeren > > > > > > |
|
|
Re: [Tobago] File upload tc:file tx:fileHi Udo,
Thank you for your reply. I have applied the suggested changes to the example-demo application and, as you said, it works fine. So now I know that the problem is not related to my Tomcat or Java installation. I must try to figure out the difference between my own app and the example-demo app... Best regards Soeren 2009/10/22 Udo Schnurpfeil <udo@...> > Hi Søren, > > I've checked the upload and can't find problems. The reference/upload.jsp > file in the demo is not full functional yet. So I added some stuff. You may > apply these changes on tobago-example-demo on your system and look if it > works fine or at any differences. > > Hope that helps. > > Regards > > Udo > > ------------------------------------------------------------------ > reference/upload.jsp > <tx:file label="Upload file:" value="#{upload.file}" /> > <tc:button label="Submit" defaultCommand="true" > action="#{upload.upload}" /> > > ------------------------------------------------------------------ > faces-config.xml > <managed-bean> > <managed-bean-name>upload</managed-bean-name> > > <managed-bean-class>org.apache.myfaces.tobago.example.reference.Upload</managed-bean-class> > <managed-bean-scope>session</managed-bean-scope> > </managed-bean> > > ------------------------------------------------------------------ > Upload.java (new) > package org.apache.myfaces.tobago.example.reference; > > import org.apache.commons.fileupload.FileItem; > import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; > > public class Upload { > > private static final Log LOG = LogFactory.getLog(Upload.class); > > private FileItem file; > > public String upload() { > LOG.info("type=" + file.getContentType()); > LOG.info("file=" + file.get().length); > LOG.info("name=" + file.getName()); > return null; > } > > public FileItem getFile() { > return file; > } > > public void setFile(FileItem file) { > this.file = file; > } > } > ------------------------------------------------------------------ > > > > Søren Hjarlvig schrieb: > > Hi, >> >> I'm attempting to use the tc:file / tx:file control to upload a file. >> But when I click the button responsible for submitting the page the >> associated action is not invoked, the page is refreshed and showed without >> any styles (!?). >> Without the tx:file-tag everything works fine. >> >> JSP: >> <tx:file value="#{controller.fileItem}" required="false" label="Upload >> file" /> >> <tc:button action="#{controller.save}" label="Save"/> >> >> I have added the following to my web.xml: >> >> <filter> >> <filter-name>multipartFormdataFilter</filter-name> >> >> <filter-class>org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataFilter</filter-class> >> <init-param> >> <description>Set the size limit for uploaded >> files...</description> >> <param-name>uploadMaxFileSize</param-name> >> <param-value>20m</param-value> >> </init-param> >> <init-param> >> <description>Set the upload repository path for uploaded files. >> Default value is java.io.tmpdir.</description> >> <param-name>uploadRepositoryPath</param-name> >> <param-value>c:/tmp</param-value> >> </init-param> >> </filter> >> <filter-mapping> >> <filter-name>multipartFormdataFilter</filter-name> >> <url-pattern>/faces/*</url-pattern> >> </filter-mapping> >> >> There are no errors or warnings, the debug log says: >> ... >> DEBUG 21 okt 16:38:30 >> org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataFilter - Wrapping >> org.apache.catalina.connector.RequestFacade with >> ContentType="multipart/form-data; >> boundary=---------------------------209722283024901" into >> TobagoMultipartFormdataRequest >> ... >> DEBUG 21 okt 16:38:30 >> org.apache.myfaces.tobago.renderkit.html.scarborough.standard.tag.FileRenderer >> - Uploaded file name : "image001.gif" size = 5558 >> ... >> >> I'm using Tobago 1.0.23 / MyFaces 1.1.6 / Tomcat 6.0.20 / Java 6u15. >> >> I hope someone can provide a hint. Thanks. >> >> Best regards >> >> Soeren >> >> >> >> >> >> >> -- Med venlig hilsen / Best regards Søren Hjarlvig Partner, M.Sc.E Bluewhale ApS Fruebjergvej 3, boks 1 DK-2100 Copenhagen Ø Denmark (+45) 39 17 99 72 Phone (+45) 39 17 99 73 Support (+45) 22 85 70 04 Mobile |
|
|
Re: [Tobago] File upload tc:file tx:fileHi again,
Now I have found the cause for the "no styles"-error: My own app is deployed in the ROOT-context ("/"), if I deploy it under some other context (e.g. "/somewebapp") upload works! If I deploy the example-demo app in the ROOT-context, upload fails there too, e.g.: <Context path="/" docBase="C:/work/myfaces-tobago-1.0.23/tobago-example-demo-1.0.23" /> Best regards Soeren 2009/10/24 Søren Hjarlvig <shj@...> > Hi Udo, > > Thank you for your reply. > I have applied the suggested changes to the example-demo application and, > as you said, it works fine. > So now I know that the problem is not related to my Tomcat or Java > installation. I must try to figure out the difference between my own app and > the example-demo app... > > Best regards > > Soeren > > 2009/10/22 Udo Schnurpfeil <udo@...> > > Hi Søren, >> >> I've checked the upload and can't find problems. The reference/upload.jsp >> file in the demo is not full functional yet. So I added some stuff. You may >> apply these changes on tobago-example-demo on your system and look if it >> works fine or at any differences. >> >> Hope that helps. >> >> Regards >> >> Udo >> >> ------------------------------------------------------------------ >> reference/upload.jsp >> <tx:file label="Upload file:" value="#{upload.file}" /> >> <tc:button label="Submit" defaultCommand="true" >> action="#{upload.upload}" /> >> >> ------------------------------------------------------------------ >> faces-config.xml >> <managed-bean> >> <managed-bean-name>upload</managed-bean-name> >> >> <managed-bean-class>org.apache.myfaces.tobago.example.reference.Upload</managed-bean-class> >> <managed-bean-scope>session</managed-bean-scope> >> </managed-bean> >> >> ------------------------------------------------------------------ >> Upload.java (new) >> package org.apache.myfaces.tobago.example.reference; >> >> import org.apache.commons.fileupload.FileItem; >> import org.apache.commons.logging.Log; >> import org.apache.commons.logging.LogFactory; >> >> public class Upload { >> >> private static final Log LOG = LogFactory.getLog(Upload.class); >> >> private FileItem file; >> >> public String upload() { >> LOG.info("type=" + file.getContentType()); >> LOG.info("file=" + file.get().length); >> LOG.info("name=" + file.getName()); >> return null; >> } >> >> public FileItem getFile() { >> return file; >> } >> >> public void setFile(FileItem file) { >> this.file = file; >> } >> } >> ------------------------------------------------------------------ >> >> >> >> Søren Hjarlvig schrieb: >> >> Hi, >>> >>> I'm attempting to use the tc:file / tx:file control to upload a file. >>> But when I click the button responsible for submitting the page the >>> associated action is not invoked, the page is refreshed and showed without >>> any styles (!?). >>> Without the tx:file-tag everything works fine. >>> >>> JSP: >>> <tx:file value="#{controller.fileItem}" required="false" label="Upload >>> file" /> >>> <tc:button action="#{controller.save}" label="Save"/> >>> >>> I have added the following to my web.xml: >>> >>> <filter> >>> <filter-name>multipartFormdataFilter</filter-name> >>> >>> <filter-class>org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataFilter</filter-class> >>> <init-param> >>> <description>Set the size limit for uploaded >>> files...</description> >>> <param-name>uploadMaxFileSize</param-name> >>> <param-value>20m</param-value> >>> </init-param> >>> <init-param> >>> <description>Set the upload repository path for uploaded >>> files. Default value is java.io.tmpdir.</description> >>> <param-name>uploadRepositoryPath</param-name> >>> <param-value>c:/tmp</param-value> >>> </init-param> >>> </filter> >>> <filter-mapping> >>> <filter-name>multipartFormdataFilter</filter-name> >>> <url-pattern>/faces/*</url-pattern> >>> </filter-mapping> >>> >>> There are no errors or warnings, the debug log says: >>> ... >>> DEBUG 21 okt 16:38:30 >>> org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataFilter - Wrapping >>> org.apache.catalina.connector.RequestFacade with >>> ContentType="multipart/form-data; >>> boundary=---------------------------209722283024901" into >>> TobagoMultipartFormdataRequest >>> ... >>> DEBUG 21 okt 16:38:30 >>> org.apache.myfaces.tobago.renderkit.html.scarborough.standard.tag.FileRenderer >>> - Uploaded file name : "image001.gif" size = 5558 >>> ... >>> >>> I'm using Tobago 1.0.23 / MyFaces 1.1.6 / Tomcat 6.0.20 / Java 6u15. >>> >>> I hope someone can provide a hint. Thanks. >>> >>> Best regards >>> >>> Soeren >>> >>> >>> >>> >>> >>> >>> > > > -- > Med venlig hilsen / Best regards > > Søren Hjarlvig > Partner, M.Sc.E > > Bluewhale ApS > Fruebjergvej 3, boks 1 > DK-2100 Copenhagen Ø > Denmark > > (+45) 39 17 99 72 Phone > (+45) 39 17 99 73 Support > (+45) 22 85 70 04 Mobile > -- Med venlig hilsen / Best regards Søren Hjarlvig Partner, M.Sc.E Bluewhale ApS Fruebjergvej 3, boks 1 DK-2100 Copenhagen Ø Denmark (+45) 39 17 99 72 Phone (+45) 39 17 99 73 Support (+45) 22 85 70 04 Mobile |
|
|
Re: [Tobago] File upload tc:file tx:fileHi,
I've just tested the two actual wars (1.0.24-SNAPSHOT and 1.5.0-alpha-2-SNAPSHOT). I've hot-deployed it with copying to webapps/ROOT.war in a new installed tomcat 6.0.20. In both version the upload.jsp works fine. So I can't reproduce the problem sadly. Regards Udo Søren Hjarlvig schrieb: > Hi again, > > Now I have found the cause for the "no styles"-error: > > My own app is deployed in the ROOT-context ("/"), if I deploy it under some > other context (e.g. "/somewebapp") upload works! > If I deploy the example-demo app in the ROOT-context, upload fails there > too, e.g.: > > <Context path="/" > docBase="C:/work/myfaces-tobago-1.0.23/tobago-example-demo-1.0.23" /> > Best regards > > Soeren > 2009/10/24 Søren Hjarlvig <shj@...> > > >> Hi Udo, >> >> Thank you for your reply. >> I have applied the suggested changes to the example-demo application and, >> as you said, it works fine. >> So now I know that the problem is not related to my Tomcat or Java >> installation. I must try to figure out the difference between my own app and >> the example-demo app... >> >> Best regards >> >> Soeren >> >> 2009/10/22 Udo Schnurpfeil <udo@...> >> >> Hi Søren, >> >>> I've checked the upload and can't find problems. The reference/upload.jsp >>> file in the demo is not full functional yet. So I added some stuff. You may >>> apply these changes on tobago-example-demo on your system and look if it >>> works fine or at any differences. >>> >>> Hope that helps. >>> >>> Regards >>> >>> Udo >>> >>> ------------------------------------------------------------------ >>> reference/upload.jsp >>> <tx:file label="Upload file:" value="#{upload.file}" /> >>> <tc:button label="Submit" defaultCommand="true" >>> action="#{upload.upload}" /> >>> >>> ------------------------------------------------------------------ >>> faces-config.xml >>> <managed-bean> >>> <managed-bean-name>upload</managed-bean-name> >>> >>> <managed-bean-class>org.apache.myfaces.tobago.example.reference.Upload</managed-bean-class> >>> <managed-bean-scope>session</managed-bean-scope> >>> </managed-bean> >>> >>> ------------------------------------------------------------------ >>> Upload.java (new) >>> package org.apache.myfaces.tobago.example.reference; >>> >>> import org.apache.commons.fileupload.FileItem; >>> import org.apache.commons.logging.Log; >>> import org.apache.commons.logging.LogFactory; >>> >>> public class Upload { >>> >>> private static final Log LOG = LogFactory.getLog(Upload.class); >>> >>> private FileItem file; >>> >>> public String upload() { >>> LOG.info("type=" + file.getContentType()); >>> LOG.info("file=" + file.get().length); >>> LOG.info("name=" + file.getName()); >>> return null; >>> } >>> >>> public FileItem getFile() { >>> return file; >>> } >>> >>> public void setFile(FileItem file) { >>> this.file = file; >>> } >>> } >>> ------------------------------------------------------------------ >>> >>> >>> >>> Søren Hjarlvig schrieb: >>> >>> Hi, >>> >>>> I'm attempting to use the tc:file / tx:file control to upload a file. >>>> But when I click the button responsible for submitting the page the >>>> associated action is not invoked, the page is refreshed and showed without >>>> any styles (!?). >>>> Without the tx:file-tag everything works fine. >>>> >>>> JSP: >>>> <tx:file value="#{controller.fileItem}" required="false" label="Upload >>>> file" /> >>>> <tc:button action="#{controller.save}" label="Save"/> >>>> >>>> I have added the following to my web.xml: >>>> >>>> <filter> >>>> <filter-name>multipartFormdataFilter</filter-name> >>>> >>>> <filter-class>org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataFilter</filter-class> >>>> <init-param> >>>> <description>Set the size limit for uploaded >>>> files...</description> >>>> <param-name>uploadMaxFileSize</param-name> >>>> <param-value>20m</param-value> >>>> </init-param> >>>> <init-param> >>>> <description>Set the upload repository path for uploaded >>>> files. Default value is java.io.tmpdir.</description> >>>> <param-name>uploadRepositoryPath</param-name> >>>> <param-value>c:/tmp</param-value> >>>> </init-param> >>>> </filter> >>>> <filter-mapping> >>>> <filter-name>multipartFormdataFilter</filter-name> >>>> <url-pattern>/faces/*</url-pattern> >>>> </filter-mapping> >>>> >>>> There are no errors or warnings, the debug log says: >>>> ... >>>> DEBUG 21 okt 16:38:30 >>>> org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataFilter - Wrapping >>>> org.apache.catalina.connector.RequestFacade with >>>> ContentType="multipart/form-data; >>>> boundary=---------------------------209722283024901" into >>>> TobagoMultipartFormdataRequest >>>> ... >>>> DEBUG 21 okt 16:38:30 >>>> org.apache.myfaces.tobago.renderkit.html.scarborough.standard.tag.FileRenderer >>>> - Uploaded file name : "image001.gif" size = 5558 >>>> ... >>>> >>>> I'm using Tobago 1.0.23 / MyFaces 1.1.6 / Tomcat 6.0.20 / Java 6u15. >>>> >>>> I hope someone can provide a hint. Thanks. >>>> >>>> Best regards >>>> >>>> Soeren >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >> -- >> Med venlig hilsen / Best regards >> >> Søren Hjarlvig >> Partner, M.Sc.E >> >> Bluewhale ApS >> Fruebjergvej 3, boks 1 >> DK-2100 Copenhagen Ø >> Denmark >> >> (+45) 39 17 99 72 Phone >> (+45) 39 17 99 73 Support >> (+45) 22 85 70 04 Mobile >> >> > > > > |
| Free embeddable forum powered by Nabble | Forum Help |