06-21-2011 06:07 AM
<input type="file" name="datafile" size="40">
07-10-2012 02:43 AM
Hi,
It looks like you try to set a variable of type EmailAttachment in the process instance context, is that right?
You can't do that because EmailAttachment doesn't implement the Serializable interface. Therefore this error message.
Best regards,
Tijs
07-10-2012 05:30 AM
07-10-2012 07:18 AM
Hi,
What I think you should do is not use the EmailAttachment container class but your own version of that which does implements Serializable.
Then you can convert your own Class attributes to an EmailAttachment in the MailActivityBehavior class.
Best regards,
07-12-2012 01:23 AM
07-16-2012 03:34 AM
07-18-2012 01:18 AM
07-18-2012 06:05 AM
07-23-2012 05:58 AM
Sources for Mail-activity are here: org.activiti.engine.impl.bpmn.behavior.MailActivityBehavior
08-03-2012 02:36 AM
Sources for Mail-activity are here: org.activiti.engine.impl.bpmn.behavior.MailActivityBehavior
package org.activiti.explorer.form;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.impl.form.AbstractFormType;
public class AttachmentFormType extends AbstractFormType{
public static final String TYPE_NAME = "sample";
public String getName() {
return TYPE_NAME;
}
@Override
public Object convertFormValueToModelValue(String propertyValue) {
System.out.println("inside convertFormValueToModelValue of AttachmentFormType");
// Check if user exists
if(propertyValue != null) {
// TODO: perhaps better wiring mechanism for service
long count = ProcessEngines.getDefaultProcessEngine()
.getIdentityService()
.createUserQuery()
.userId(propertyValue).count();
if(count == 0) {
throw new ActivitiException("File " + propertyValue + " does not exist");
}
System.out.println("coming out of convertFormValueToModelValue of AttachmentFormType");
return propertyValue;
}
return null;
}
@Override
public String convertModelValueToFormValue(Object modelValue) {
System.out.println("inside convertModelValueToFormValue type of AttachmentFormType");
return (String) modelValue;
}
}
My AttachmentFormPropertyRenderer.java class looks like this:package org.activiti.explorer.ui.form;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import org.activiti.engine.form.FormProperty;
import org.activiti.engine.form.FormType;
import org.activiti.explorer.Messages;
import org.activiti.explorer.form.AttachmentFormType;
import org.activiti.explorer.form.UserFormType;
import org.activiti.explorer.ui.form.MyUploader;
import com.vaadin.data.Property;
import com.vaadin.ui.Field;
import com.vaadin.ui.Upload;
import com.vaadin.ui.Upload.Receiver;
public class AttachmentFormPropertyRenderer extends AbstractFormPropertyRenderer{
// File file;
public AttachmentFormPropertyRenderer() {
super(AttachmentFormType.class);
}
@Override
public Field getPropertyField(FormProperty formProperty) {
// TODO Auto-generated method stub
MyUploader myuploader=new MyUploader(getPropertyLabel(formProperty));
((Field) myuploader).setRequired(formProperty.isRequired());
((Field) myuploader).setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));
myuploader.setEnabled(formProperty.isWritable());
if (formProperty.getValue() != null) {
((Property) myuploader).setValue(formProperty.getValue());
}
return (Field) myuploader.getUpload();
}
}
package org.activiti.explorer.ui.form;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import com.vaadin.terminal.FileResource;
import com.vaadin.ui.*;
public class MyUploader extends CustomComponent
implements Upload.SucceededListener,
Upload.FailedListener,
Upload.Receiver {
/**
*
*/
private static final long serialVersionUID = 1L;
Panel root; // Root element for contained components.
Panel imagePanel; // Panel that contains the uploaded image.
File file; // File to write to.
private Upload upload;
public Upload getUpload() {
return upload;
}
public void setUpload(Upload upload) {
this.upload = upload;
}
MyUploader(String caption) {
setCaption(caption);
root = new Panel("My Upload Component");
setCompositionRoot(root);
// Create the Upload component.
final Upload upload =
new Upload("Upload the file here", this);
// Use a custom button caption instead of plain "Upload".
upload.setButtonCaption("Upload Now");
// Listen for events regarding the success of upload.
upload.addListener((Upload.SucceededListener) this);
upload.addListener((Upload.FailedListener) this);
root.addComponent(upload);
root.addComponent(new Label("Click 'Browse' to "+
"select a file and then click 'Upload'."));
// Create a panel for displaying the uploaded image.
imagePanel = new Panel("Uploaded image");
imagePanel.addComponent(
new Label("No image uploaded yet"));
root.addComponent(imagePanel);
}
// Callback method to begin receiving the upload.
public OutputStream receiveUpload(String filename,
String MIMEType) {
FileOutputStream fos = null; // Output stream to write to
file = new File("/tmp/uploads/" + filename);
try {
// Open the file for writing.
System.out.println(file.getAbsolutePath());
fos = new FileOutputStream(file);
} catch (final java.io.FileNotFoundException e) {
// Error while opening the file. Not reported here.
e.printStackTrace();
return null;
}
return fos; // Return the output stream to write to
}
// This is called if the upload is finished.
public void uploadSucceeded(Upload.SucceededEvent event) {
// Log the upload on screen.
root.addComponent(new Label("File " + event.getFilename()
+ " of type '" + event.getMIMEType()
+ "' uploaded."));
// Display the uploaded file in the image panel.
final FileResource imageResource =
new FileResource(file, getApplication());
imagePanel.removeAllComponents();
imagePanel.addComponent(new Embedded("", imageResource));
}
// This is called if the upload fails.
public void uploadFailed(Upload.FailedEvent event) {
// Log the failure on screen.
root.addComponent(new Label("Uploading "
+ event.getFilename() + " of type '"
+ event.getMIMEType() + "' failed."));
}
}
08-03-2012 03:10 AM
/**
* Field which allows you to select a user. The field-value is the
* id of the selected user.
*
* @author Frederik Heremans
*/
public class SelectUserField extends HorizontalLayout implements Field {
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.