AnsweredAssumed Answered

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

Question asked by davidparraz41 on Jun 22, 2017
Latest reply on Jul 7, 2017 by ryandawson

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.

 

Outcomes