problem with fileUpload. I need limitToList
madman1 May 23, 2008 7:43 PMHello, sorry for my english.
I have the typical, ajaxRender=true, component. My problem is that I don't want to reRender this component while I upload a file. So I try this:
<a4j:region renderRegionOnly="false">
<h:form id="fileUploadForm">
<h:panelGrid>
<rich:fileUpload maxFilesQuantity="10" id="fileUpload" fileUploadListener="#{filesUploader.listener}">
<a4j:support event="onuploadcomplete" reRender="filesTree" />
<f:facet name="progress">
<rich:progressBar limitToList="true"/>
</f:facet>
</rich:fileUpload>
</h:panelGrid>
</h:form>
</a4j:region>In this way components ajaxRendered=true, don't auto update. The problem is that, this don't work:
<a4j:support event="onuploadcomplete" reRender="filesTree" />
Because filesTree, it's a component outside the region. So I try this:
<a4j:region renderRegionOnly="false">
<h:form id="fileUploadForm">
<h:panelGrid>
<rich:fileUpload maxFilesQuantity="10" onuploadcomplete="hack();" id="fileUpload" fileUploadListener="#{filesUploader.listener}">
<f:facet name="progress">
<rich:progressBar limitToList="true"/>
</f:facet>
</rich:fileUpload>
</h:panelGrid>
</h:form>
</a4j:region>
<a4j:jsFunction name="hack" reRender="filesTree"/>But don't work, I get a javascript error (I saw with firebug).
How can I do it? I think that a limitToList attribute for fileUpload, could be good. I was reading the source, and I find, in the public abstract class FileUploadRendererBase this method:
private String getActionScript(FacesContext context, UIComponent component,
String action, Object oncomplete) throws IOException {
ComponentVariables variables = ComponentsVariableResolver.getVariables(
this, component);
String clientId = component.getClientId(context);
String containerId = (String) variables.getVariable("containerId");
JSFunction ajaxFunction = new JSFunction(
AjaxRendererUtils.AJAX_FUNCTION_NAME);
ajaxFunction.addParameter(containerId);
ajaxFunction.addParameter(new JSReference("formId"));
ajaxFunction.addParameter(new JSReference("event"));
// AjaxRendererUtils.buildAjaxFunction(
// component, context);
Map options = AjaxRendererUtils.buildEventOptions(context, component);
Map parameters = (Map) options.get("parameters");
parameters.put("action", action);
parameters.put(Filter.UPLOAD_FILES_ID, new JSReference("uid"));
parameters.put(clientId, clientId);
parameters.put(AjaxRendererUtils.AJAX_SINGLE_ATTR, clientId);
if (oncomplete != null) {
options.put("onbeforedomupdate", oncomplete);
}
ajaxFunction.addParameter(options);
JSFunctionDefinition function = new JSFunctionDefinition("uid");
function.addParameter("formId");
function.addParameter("event");
function.addToBody(ajaxFunction.toScript());
return function.toScript();
}Maybe only putting, ajaxFunction.setLimitToList(true);
and the same in the intern progressBar, a new limitToList attribute could work. Umm... it's sure that is more dificult, but I suggest a new attribute.
Thanks.