How can I add a button that executes an expression on my form?

cancel
Showing results for 
Search instead for 
Did you mean: 
Active Member

How can I add a button that executes an expression on my form?

I am trying to add a button to my form that executes a method of my class. I declare my method as an expression on the button, but it never runs, apparently I'm missing an event definition in the class that defines my button.

Here my code

public class ButtonFormType extends AbstractFormType implements Serializable {
private static final long serialVersionUID = 3256341958493366115L;

private static final String TYPE_NAME = "button";

@Override
public String getName() {
return TYPE_NAME;
}

@Override
public Object convertFormValueToModelValue(String propertyValue) {
return propertyValue;
}

@Override
public String convertModelValueToFormValue(Object modelValue) {
return modelValue == null ? null : modelValue.toString();
}
}

//BUTTON DEFINITION

public ButtonFormPropertyRenderer() {
super(ButtonFormType.class);
}

@Override
public Field getPropertyField(FormProperty formProperty) {
Button button = new Button();
button.setRequired(formProperty.isRequired());
button.setEnabled(formProperty.isWritable());
button.addStyleName(Reindeer.BUTTON_DEFAULT);
button.click();

return button;
}

//BUTTON IN FORM

<activiti:formProperty id="save" name="Save" type="button" expression="${myClass.save(execution, id, variable)}"></activiti:formProperty>

Regards.

 

1 Reply
Alfresco Employee

Re: How can I add a button that executes an expression on my form?

Perhaps this thread is of help - Buttons to be used inside Alfresco Activiti Task Forms . If it's a custom action that you're looking to perform perhaps it's something you could do or invoke in javascript or process as part of a task or listener.