User tasks with custom forms: custom user inputs validation
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2012 04:44 AM
Hi all,
In the following articles/post is described, how to create the rendering using custom forms within activiti explorer environment:
I miss the information about how to validate the user entries ?
Does anyone know more about it?
Thank you
In the following articles/post is described, how to create the rendering using custom forms within activiti explorer environment:
http://www.activiti.org/userguide/index.html#forms
http://forums.activiti.org/en/viewtopic.php?f=6&t=2366&p=10188&hilit=rendering#p10188
http://forums.activiti.org/en/viewtopic.php?f=9&t=1386&p=9332&hilit=rendering#p9332
https://vaadin.com/wiki/-/wiki/Main/Building%20Vaadin%20Applications%20on%20top%20of%20Activiti
http://forums.activiti.org/en/viewtopic.php?f=6&t=857&hilit=rendering
I miss the information about how to validate the user entries ?
Does anyone know more about it?
Thank you
Labels:
- Labels:
-
Archive
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2012 02:44 PM
I've found the solution, as I have seen the sources of A.E.:
it is possible to register the validator on the vaadin-field in the renderer-class in Vaadin style :
textField.addValidator(new LongValidator("Value must be a long"));
it is possible to register the validator on the vaadin-field in the renderer-class in Vaadin style :
textField.addValidator(new LongValidator("Value must be a long"));
package org.activiti.explorer.ui.form;
….
public class LongFormPropertyRenderer extends AbstractFormPropertyRenderer {
public LongFormPropertyRenderer() {
super(LongFormType.class);
}
@Override
public Field getPropertyField(FormProperty formProperty) {
final TextField textField = new TextField(getPropertyLabel(formProperty));
textField.setRequired(formProperty.isRequired());
textField.setEnabled(formProperty.isWritable());
textField.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));
if (formProperty.getValue() != null) {
textField.setValue(formProperty.getValue());
}
// Add validation of numeric value
textField.addValidator(new LongValidator("Value must be a long"));
textField.setImmediate(true);
return textField;
}
….
The validator:package org.activiti.explorer.ui.validator;
import com.vaadin.data.validator.AbstractStringValidator;
/**
* @author Frederik Heremans
*/
public class LongValidator extends AbstractStringValidator {
private static final long serialVersionUID = 8306001395582004472L;
public LongValidator(String errorMessage) {
super(errorMessage);
}
@Override
protected boolean isValidString(String value) {
try {
Long.parseLong(value);
return true;
} catch (Exception e) {
return false;
}
}
}