got5/tapestry5-jquery — Issue #135: AjaxUpload fails with Function Tapestry.Initializer.uploadable() does not exist.
Author: sommeralex
Created: 2012-02-08 22:33:25+00:00
State: open

The example at http://tapestry5-jquery.com/components/docsajaxupload is not fully documented. I tried to complete the code as shown below with tapestry 5.3.2 and jQuery Version 3.2.0-SNAPSHOT but the upload function fails with the error message: Function Tapestry.Initializer.uploadable() does not exist.

${message}

Uploaded files

package com.scrollstory.pages;

import java.util.ArrayList;

import java.util.Date;
import java.util.List;

import org.apache.tapestry5.Block;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.EventConstants;
import org.apache.tapestry5.PersistenceConstants;
import org.apache.tapestry5.annotations.InjectComponent;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.corelib.components.Zone;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.ioc.internal.util.InternalUtils;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.ajax.AjaxResponseRenderer;
import org.apache.tapestry5.upload.services.UploadedFile;
import org.got5.tapestry5.jquery.JQueryEventConstants;
import org.got5.tapestry5.jquery.components.AjaxUpload;

public class Gallery {

@Inject
private Block uploadResult;

@Inject
private AjaxResponseRenderer ajaxResponseRenderer;

@Property
@Persist
List uploadedFiles;

@Persist(PersistenceConstants.FLASH)
@Property
private String message;

@Inject
private ComponentResources resources;

@OnEvent(component = "uploadImage", value = JQueryEventConstants.AJAX_UPLOAD)
void onImageUpload(UploadedFile uploadedFile) {
if (uploadedFile != null) {
this.uploadedFiles.add(uploadedFile);
}
//message = "This upload was: AJAX_UPLOAD";
ajaxResponseRenderer.addRender("uploadResult", uploadResult);
}
@OnEvent(component = "uploadImage", value = JQueryEventConstants.NON_XHR_UPLOAD)
Object onNonXHRImageUpload(UploadedFile uploadedFile) {
if (uploadedFile != null) {
this.uploadedFiles.add(uploadedFile);
}
final JSONObject result = new JSONObject();
final JSONObject params = new JSONObject()
.put("url", resources.createEventLink("myCustomEvent", "NON_XHR_UPLOAD").toURI())
.put("zoneId", "uploadResult");
result.put(AjaxUpload.UPDATE_ZONE_CALLBACK, params);
return result;
}
@OnEvent(value = "myCustomEvent")
void onMyCustomEvent(final String someParam) {
message = "This upload was: " + someParam;
ajaxResponseRenderer.addRender("uploadResult", uploadResult);
}
}