uploadedFile = upFile;
}
@SuppressWarnings("unchecked")
public String upload() throws IOException {
FacesContext fc = FacesContext.getCurrentInstance();
VariableResolver vr = fc.getApplication().getVariableResolver();
DcWebImage wi = (DcWebImage) vr.resolveVariable(fc, "image");
byte[] b = uploadedFile.getBytes();
DcWebObject wo = (DcWebObject) vr.resolveVariable(fc, "webObject");
DcObject dco = wo.getDcObject();
dco.setValue(wi.getFieldIdx(), new DcImageIcon(b));
try {
dco.saveUpdate(false);
wi.setPicture((Picture) dco.getValue(wi.getFieldIdx()));
wo.load();
DcWebObjects objects = (DcWebObjects) vr.resolveVariable(fc, "webObjects");
objects.update(wo);
} catch (ValidationException ve) {
ve.printStackTrace();
}
fc.getExternalContext().getApplicationMap().put("fileupload_bytes", uploadedFile.getBytes());
fc.getExternalContext().getApplicationMap().put("fileupload_type", uploadedFile.getContentType());
fc.getExternalContext().getApplicationMap().put("fileupload_name", uploadedFile.getName());
return current();
}