Sorry there is errors in previos text
I need to know if its posibble to add custom attributes to an AbstractFormType. Actually I do this job extending class FormTypes.
1. Adding my class TextAreaFormActivitiType extending AbstractFormType with attribute of textarea rows.
<code>
import org.activiti.engine.form.AbstractFormType;
public class TextAreaFormActivitiType extends AbstractFormType {
public static final String TYPE_NAME = "textarea";
private Integer _rows = new Integer(0);
public TextAreaFormActivitiType() {
}
public Integer getRows() {
return this._rows;
}
public void setRows(Integer rows) {
this._rows = rows;
}
@Override
public String getName() {
return TYPE_NAME;
}
@Override
public Object convertFormValueToModelValue(String propertyValue) {
return propertyValue;
}
@Override
public String convertModelValueToFormValue(Object modelValue) {
return (String) modelValue;
}
}
</code>
2. Extending class FormTypes (FormTypesExtended). I am using formValues elements to configure number of rows to print.
<code>
<activiti:formProperty id="tipoAreaTexto" name="Tipo area texto" type="textarea" variable="tipoAreaTexto" required="true">
<activiti:value id="rows" name="10"></activiti:value>
</activiti:formProperty>
</code>
.. instead i would like to us this… :
<code>
<activiti:formProperty id="tipoAreaTexto" name="Tipo area texto" type="textarea" variable="tipoAreaTexto" required="true" rows="10"/>
</code>
<code>
public class FormTypesExtended extends FormTypes {
public FormTypesExtended() {
super.addFormType(new StringFormType());
super.addFormType(new LongFormType());
super.addFormType(new DateFormType("dd/MM/yyyy"));
super.addFormType(new BooleanFormType());
}
@Override
public AbstractFormType parseFormPropertyType(FormProperty formProperty) {
if ("textarea".equals(formProperty.getType())) {
Map values = new LinkedHashMap();
Integer rows = new Integer(3);
// Access formProperty values..
for (FormValue formValue : formProperty.getFormValues()) {
// Contains rows
if ("rows".equals(formValue.getId())) {
rows = Integer.parseInt(formValue.getName());
}
}
// Create new type with rows..
TextAreaFormActivitiType textAreaType = new TextAreaFormActivitiType();
textAreaType.setRows(rows);
return textAreaType;
}
return super.parseFormPropertyType(formProperty);
}
}
</code>
3. Adding configuration to spring-activiti.xml file.
<code>
<!– adding this configuration to spring-activiti.xml –>
<bean id="formTypesExtended" class="com.inditex.tempe.activiti.types.FormTypesExtended">
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="formTypes" ref="formTypesExtended" />
…
</code>