InputFile inputFile = (InputFile) uiComponent;
String clientId = inputFile.getClientId(facesContext);
// Determine the valid content-types and maximum file size from the validator (if specified).
JavaScriptArray contentTypes = new JavaScriptArray();
JavaScriptFragment alloyNamespace = new JavaScriptFragment("A");
long maxFileSize = Long.MAX_VALUE;
InputFileValidator inputFileValidator = getInputFileValidator(inputFile);
if (inputFileValidator != null) {
String validContentTypes = inputFileValidator.getContentTypes();
if (validContentTypes != null) {
contentTypes = new JavaScriptArray(validContentTypes.split(","));
}
maxFileSize = inputFileValidator.getMaxFileSize();
}
// If the component should render the upload progress table, then initialize the YUI progress uploader widget.
if (inputFile.isShowProgress()) {
String clientVarName = ComponentUtil.getClientVarName(facesContext, inputFile);
String clientKey = inputFile.getClientKey();
if (clientKey == null) {
clientKey = clientVarName;
}
UIViewRoot viewRoot = facesContext.getViewRoot();
Locale locale = viewRoot.getLocale();
String formClientId = getParentFormClientId(inputFile);
Application application = facesContext.getApplication();
ViewHandler viewHandler = application.getViewHandler();
String actionURL = viewHandler.getActionURL(facesContext, viewRoot.getViewId());
String partialActionURL = facesContext.getExternalContext().encodePartialActionURL(actionURL);
String namingContainerId = StringPool.BLANK;
if (viewRoot instanceof NamingContainer) {
namingContainerId = viewRoot.getContainerClientId(facesContext);
}
AjaxParameters ajaxParameters = new AjaxParameters(inputFile, clientId, formClientId);
String execute = ajaxParameters.getExecute();
String render = ajaxParameters.getRender();
String notStartedMessage = getMessageContext().getMessage(locale, "not-started");
JavaScriptFragment clientComponent = new JavaScriptFragment("Liferay.component('" + clientKey + "')");
RendererUtil.encodeFunctionCall(responseWriter, "LFAI.initProgressUploader", alloyNamespace,
clientComponent, contentTypes, clientId, formClientId, namingContainerId, inputFile.isAuto(), execute,
render, partialActionURL, maxFileSize, notStartedMessage);
}