-
1. Re: Custom fileUpload renderer
shikida Jan 6, 2011 1:33 PM (in response to shikida)Forgot to say, RF 3.3.3.
-
2. Re: Custom fileUpload renderer
shikida Jan 7, 2011 7:35 AM (in response to shikida)Well, half of the problem seems to be solved.
To change filenames to links, here´s what I had to do
[1] it seems the renderer is
<render-kit>
<renderer>
<component-family>org.richfaces.component.FileUpload</component-family>
<renderer-type>org.richfaces.renderkit.html.FileUploadRenderer</renderer-type>
<renderer-class>org.richfaces.renderkit.html.FileUploadRenderer</renderer-class>
</renderer>
</render-kit>
[2] to get FileUploadRenderer, I had to decompile the class from the jar using jad, since this file seems to be absent of the richfaces source code (I don´t know why exactly, maybe it´s there with another name)
[3] then, in this file, I´ve changed the js file name to something I can change (see bold part)
private final InternetResource scripts[] = {
new PrototypeScript(), new AjaxScript(),getResource("/org/richfaces/renderkit/html/scripts/utils.js"), getResource("/org/richfaces/renderkit/html/scripts/json/json-dom.js"), getResource("/org/richfaces/renderkit/html/js/FileUpload2.js"), getResource("/org/richfaces/renderkit/html/js/swfobject.js"), getResource("/org/richfaces/renderkit/html/js/progressBar.js"), getResource("/org/ajax4jsf/javascript/scripts/form.js")
};
[4] finally, in the js file above, I´ve found FileUploadEntry.template
[newET(function (context) { return Richfaces.evalMacro("fileName",context)})]
and I´ve replaced it to
[new E('a',{'style':'','onclick': function (context) { return'alert(1);return false;';}, 'className':function (context) { return 'rich-fileupload-anc' + Richfaces.evalMacro("labelClassName", context) +Richfaces.evalMacro("className", context); },'href':'#'},
[new ET(function (context) { returnRichfaces.evalMacro("fileName", context)})])]),
so now, the filename comes inside an anchor that has a javascript action on it (alert), so all I have to do is to put some javascript up there.
so, the other half of my problem seems to be how to get the initial list of uploaded files populated :-)
best regards
Leo K.