fileUpload bug using #resource ??

UI Components for JSF
Post Reply
md97212
Posts: 5
Joined: 11 Mar 2010, 00:34

12 Mar 2010, 03:17

When using fileUpload in 2.0 with facelets I am trying to customize the skin using #resource but my context path gets added twice so my custom image is not found.
Here's the example:

Code: Select all

			<p:fileUpload fileUploadListener="#{fileHandler.processFileUpload}"
				ajax="false" id="documentToUpload"
				allowTypes="*.pdf;*.doc;*.html;*.rtf;" description="Images"
				update="messages" auto="true"
				image="#{resource['skins/pep/images/btn_upload.gif']}"
				customUI="true" />
which generates:

Code: Select all

</script><span id="j_idt1:messages"></span><script type="text/javascript">PrimeFaces.onContentReady('j_idt1:documentToUpload', function () { 
j_idt1_documentToUpload_widget = new PrimeFaces.widget.Uploader('j_idt1:documentToUpload', {
uploader:'/pep/primefaces_resource/2.0.0.RC/jquery/plugins/uploadify/uploadify.swf',script:'/pep/highschool_crls.jsf',cancelImg:'/pep/primefaces_resource/2.0.0.RC/jquery/plugins/uploadify/cancel.png',formId:'j_idt1:form',fileDataName:'j_idt1:documentToUpload',multi:false,auto:true,update:'messages',buttonImg:'/pep/pep/javax.faces.resource/skins/pep/images/btn_upload.gif.jsf',fileExt:'*.pdf;*.doc;*.html;*.rtf;',fileDesc:'Images'});
});
</script>
Specifically notice that:

Code: Select all

buttonImg:'/pep/pep/javax.faces.resource/skins/pep/images/btn_upload.gif.jsf'
where pep is my context path and it should not appear as :'/pep/pep...

As a workaround specifying the absolute path instead of using #resource works ok:

Code: Select all

		<h:form id="form" enctype="multipart/form-data" prependId="false">
			<p:resources />
			<p:growl id="messages" />
			<p:fileUpload fileUploadListener="#{fileHandler.processFileUpload}"
				ajax="false" id="documentToUpload"
				allowTypes="*.pdf;*.doc;*.html;*.rtf;" description="Images"
				update="messages" auto="true"
				image="/resources/skins/pep/images/btn_upload.gif"
				customUI="true" />
		</h:form>
I assume this is a bug in PrimeFaces

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

12 Mar 2010, 17:07

We just delegate image path to ViewHandler.getResourceUrl api just like standard h:graphicImage does.

Can you try;

Code: Select all

image="/#{resource['skins/pep/images/btn_upload.gif']}"

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 26 guests