cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti Forms with Dependent Properties.

ejyanezp
Champ in-the-making
Champ in-the-making
Hello,

I wish to design an Activiti Form that will be rendered in Activiti Explorer with a sequence of combo boxes that are sequentially dependent, for example:

Country (Combobox)
State (Combobox)
City (Combobox)

At the beginning only the Country combo box is filled with several countries. The other two are empty.

Then, when the user selects a country I wish to trigger an event to fill up the "State" combo box with the country's states. Then when the user selects a state i wish to fill up the City combo box with the respective cities of the selected state.

Which is the best way to do this in Activiti Explorer?

Thanks in advanced.

Regards,
Eduardo Yánez.
6 REPLIES 6

ejyanezp
Champ in-the-making
Champ in-the-making
Hi,

Ok, this time I won't speak with empty hands, but I will also need some help. For this proposal, I am using Activiti 5-16-SNAPSHOT from the Git repository.

I think the best way to solve this problem is modifying the "org.activiti.explorer.ui.form.FormPropertyRenderer" interface. To enable each renderer to know in which form it is, and through the form enquire about any other field it needs. This way, sequential dependencies could be solved in a easy form.

<java>// Comments removed
public interface FormPropertyRenderer extends Serializable {
/// … … original interface code  ….  …. …
  public com.vaadin.ui.Form getForm();
  public void setForm(com.vaadin.ui.Form p_form);
}</java>

Of course, a modification in the implementing class (org.activiti.explorer.ui.form.AbstractFormPropertyRenderer) will be necessary:

<java>/// Coments removed
public abstract class AbstractFormPropertyRenderer implements FormPropertyRenderer {
/// … … original class code  ….  …. …
  public com.vaadin.ui.Form getForm() {
   return theForm;
  }
  public void setForm(com.vaadin.ui.Form p_form) {
   theForm = p_form;
  }
  transient private com.vaadin.ui.Form theForm = null;
}</java>

I declared theForm transient to prevent any other modification.

Lastly, the only needed change that remains is where do we set the form, i think the right place is in the class org.activiti.explorer.ui.form.FormPropertiesComponent , in the method "setFormProperties", just after recovering the renderer:

<java>public void setFormProperties(List<FormProperty> formProperties) {
    this.formProperties = formProperties;
   
    form.removeAllProperties();
   
    // Clear current components in the grid
    if(formProperties != null) {
      for(FormProperty formProperty : formProperties) {
        FormPropertyRenderer renderer = getRenderer(formProperty);
       
        /// Proposal
        /// Be able to get the Form from any Renderer.
        /// this enables widget interdependence programing (cascading comboboxes, for example)
        renderer.setForm(form);
      
        Field editorComponent = renderer.getPropertyField(formProperty);
        if(editorComponent != null) {
          // Get label for editor component.
          form.addField(formProperty.getId(), editorComponent);
        }
      }
    }
  }</java>

Counting with that in the activiti-explorer jar library, a custom renderer could use its getForm() method, and then through this instance to use any of the Vaadin methods to enquire about other fields in the form.

Please let me know if you approve this as the owners of the product to submit the code.

Regards,
Eduardo Yánez.

jbarrez
Star Contributor
Star Contributor
Yes - i can see the value of this.

Can you create a pull request of this in github? That will make it easier for us to collaborate and discuss your work.

ejyanezp
Champ in-the-making
Champ in-the-making
Done.
Pullrequest: < Activiti Forms with interdependent Properties #336 >
Glad to contribute!
Regards,
e.

jbarrez
Star Contributor
Star Contributor
And accepted. Thanks!

aliraza852
Champ in-the-making
Champ in-the-making
No, none at all … And no errors on the server side?

felixho
Champ in-the-making
Champ in-the-making
I found the Java code is already updated on the activiti-explorer libraries (my version is 5.19). I would like to follow the guide and create two dependent combo box like - Country & State.

I have created two new custom form property (Country & State) separately but do not have any idea to get the dependency.

Can anybody share suggestion/ sample code on building a dependent form type ?
Getting started

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.