cancel
Showing results for 
Search instead for 
Did you mean: 

New components for Form Properties

marc_carrio
Champ in-the-making
Champ in-the-making
Hi,

I'm migrating Forms of my old process in Activiti < 5.7 to Form Properties (5.7), but I need more components… like this, textarea, radio button…  :?

Further I have 20 fields in my Form, and I need put in two colums for being useful. 

My question are if you think work more in Form Properties in the next future, or if is better that I work in this now. I would not do useless work, because you develop better than me  Smiley Very Happy

If not, can you tell me what strategy and classes for change?  :roll:

Thanks a lot!!  :mrgreen:
13 REPLIES 13

trademak
Star Contributor
Star Contributor
Right. We're not planning Form properties enhancements for the next releases. So if you would like to contribute this that would be great.
In the source code you can look at the current form types implemented, which are for example BooleanFormType and StringFormType.

Best regards,

marc_carrio
Champ in-the-making
Champ in-the-making
Thanks trademak!!

I'm creating the textArea component,

I create the Class TextAreaFormType in activiti-engine

package org.activiti.engine.impl.form;public class TextAreaFormType extends AbstractFormType {  public String getName() {    return "textarea";  }  public String getMimeType() {    return "text/plain";  }  public Object convertFormValueToModelValue(String propertyValue) {    return propertyValue;  }  public String convertModelValueToFormValue(Object modelValue) {    return (String) modelValue;  }} 
and the class TextAreaFormPropertyRenderer  in activiti-webapp-explorer2

package org.activiti.explorer.ui.form;import org.activiti.engine.form.FormProperty;public class TextAreaFormPropertyRenderer extends AbstractFormPropertyRenderer {  public TextAreaFormPropertyRenderer() {    super(TextAreaFormType.class);  }  @Override  public Field getPropertyField(FormProperty formProperty) {    TextArea textArea = new TextArea(getPropertyLabel(formProperty));    textArea.setRequired(formProperty.isRequired());    textArea.setEnabled(formProperty.isWritable());    textArea.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));    if (formProperty.getValue() != null) {        textArea.setValue(formProperty.getValue());    }    return textArea;  }} 
and the initialitzacion method in ProcessEngineConfigurationImpl

  protected void initFormTypes() {    if (formTypes==null) {      formTypes = new FormTypes();      formTypes.addFormType(new StringFormType());     formTypes.addFormType(new TextAreaFormType()); // <<<< NEW LINE FOR TEXTAREA      formTypes.addFormType(new LongFormType());      formTypes.addFormType(new DateFormType("dd/MM/yyyy"));      formTypes.addFormType(new BooleanFormType());    }    if (customFormTypes!=null) {      for (AbstractFormType customFormType: customFormTypes) {        formTypes.addFormType(customFormType);      }    } 
I compiled with maven the activiti-engine and activiti-explorer correctly. Smiley Very Happy  I deployed a process with textarea form property, and the tomcat display the next exception:  :cry:

27-sep-2011 12:36:36 com.vaadin.Application terminalError
GRAVE: Terminal error:
com.vaadin.event.ListenerMethod$MethodException
Cause: com.vaadin.event.ListenerMethod$MethodException
Cause: org.activiti.engine.ActivitiException: No property renderer found for type: textarea, class org.activiti.engine.impl.form.TextAreaFormType
        at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510)
        at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164)
        at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1193)
        at com.vaadin.ui.Button.fireClick(Button.java:539)
        at com.vaadin.ui.Button.changeVariables(Button.java:206)
        at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariableBurst(AbstractCommunicationManager.java:1299)
        at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1219)
        at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:735)
        at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:296)
        at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:501)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:662)
Caused by: com.vaadin.event.ListenerMethod$MethodException
Cause: org.activiti.engine.ActivitiException: No property renderer found for type: textarea, class org.activiti.engine.impl.form.TextAreaFormType
        at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510)
        at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164)
        at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1193)
        at com.vaadin.ui.AbstractField.fireValueChange(AbstractField.java:891)
        at com.vaadin.ui.AbstractField.setValue(AbstractField.java:529)
        at com.vaadin.ui.AbstractSelect.setValue(AbstractSelect.java:666)
        at com.vaadin.ui.AbstractSelect.setValue(AbstractSelect.java:635)
        at com.vaadin.ui.Table.setValue(Table.java:1852)
        at com.vaadin.ui.AbstractSelect.select(AbstractSelect.java:1377)
        at org.activiti.explorer.ui.AbstractTablePage.selectElement(AbstractTablePage.java:104)
        at org.activiti.explorer.ui.task.TaskPage.initUi(TaskPage.java:71)
        at org.activiti.explorer.ui.AbstractPage.attach(AbstractPage.java:43)
        at com.vaadin.ui.AbstractComponent.setParent(AbstractComponent.java:570)
        at com.vaadin.ui.AbstractComponentContainer.addComponent(AbstractComponentContainer.java:211)
        at com.vaadin.ui.CssLayout.addComponent(CssLayout.java:93)
        at org.activiti.explorer.ui.mainlayout.MainLayout.setMainContent(MainLayout.java:60)
        at org.activiti.explorer.ui.MainWindow.switchView(MainWindow.java:79)
        at org.activiti.explorer.DefaultViewManager.switchView(DefaultViewManager.java:272)
        at org.activiti.explorer.DefaultViewManager.showInboxPage(DefaultViewManager.java:162)
        at org.activiti.explorer.ui.mainlayout.MainMenuBar$ShowTasksClickListener.buttonClick(MainMenuBar.java:191)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:490)
        … 22 more
Caused by: org.activiti.engine.ActivitiException: No property renderer found for type: textarea, class org.activiti.engine.impl.form.TextAreaFormType
        at org.activiti.explorer.ui.form.FormPropertyRendererManager.getPropertyRendererForType(FormPropertyRendererManager.java:56)
        at org.activiti.explorer.ui.form.FormPropertiesComponent.getRenderer(FormPropertiesComponent.java:123)
        at org.activiti.explorer.ui.form.FormPropertiesComponent.setFormProperties(FormPropertiesComponent.java:67)
        at org.activiti.explorer.ui.form.FormPropertiesForm.setFormProperties(FormPropertiesForm.java:75)
        at org.activiti.explorer.ui.task.TaskDetailPanel.initTaskForm(TaskDetailPanel.java:297)
        at org.activiti.explorer.ui.task.TaskDetailPanel.init(TaskDetailPanel.java:118)
        at org.activiti.explorer.ui.task.TaskDetailPanel.attach(TaskDetailPanel.java:99)
        at com.vaadin.ui.AbstractComponent.setParent(AbstractComponent.java:570)
        at com.vaadin.ui.AbstractComponentContainer.addComponent(AbstractComponentContainer.java:211)
        at com.vaadin.ui.GridLayout.addComponent(GridLayout.java:223)
        at org.activiti.explorer.ui.AbstractPage.setDetailComponent(AbstractPage.java:137)
        at org.activiti.explorer.ui.task.TaskPage.access$0(TaskPage.java:1)
        at org.activiti.explorer.ui.task.TaskPage$1.valueChange(TaskPage.java:118)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:490)
        … 46 more

I supose that I forget some class… but I don't know… Can you help me?

Thanks!!   Smiley Happy

trademak
Star Contributor
Star Contributor
Hi,

I think you are missing only one piece of configuration. You have to add the FormPropertyRenderer to the following list in the src/main/webapp/WEB-INF/activiti-ui-context.xml file of the activiti-webapp-explorer2 project:

<!– Custom form property renderers can be plugged in here –>
  <bean id="formPropertyRendererManager" class="org.activiti.explorer.ui.form.FormPropertyRendererManager" lazy-init="true">
    <!– Default renderer –>
    <property name="noTypePropertyRenderer">
      <bean class="org.activiti.explorer.ui.form.StringFormPropertyRenderer" />
    </property>
    <!– Renderers by property type –>
    <property name="propertyRenderers">
      <list>
        <bean class="org.activiti.explorer.ui.form.StringFormPropertyRenderer" />
        <bean class="org.activiti.explorer.ui.form.EnumFormPropertyRenderer" />
        <bean class="org.activiti.explorer.ui.form.LongFormPropertyRenderer" />
        <bean class="org.activiti.explorer.ui.form.DateFormPropertyRenderer" />
        <bean class="org.activiti.explorer.ui.form.UserFormPropertyRenderer" />
        <bean class="org.activiti.explorer.ui.form.BooleanFormPropertyRenderer" />
      </list>
    </property>
  </bean>

Best regards,

marc_carrio
Champ in-the-making
Champ in-the-making
Brillant!! It works Fine!!!  Smiley Very Happy  Smiley Very Happy

Thanks a lot for your suport. I  will work in the new components catalog!   :mrgreen:  :mrgreen:

Best Regards,

marc_carrio
Champ in-the-making
Champ in-the-making
Hi,

I need a new complex component. Search product. I think that maybe the better is a button that opens a popup and put the result in a table. But this table needs erase products if is necessary.

Do you think is possible with Form Properties and Vaadin components?  any idea for start?

thanks a lot!

Best Regards,

trademak
Star Contributor
Star Contributor
Sure, just look at the UserComponent that's already available in the Activiti Explorer.
That also shows a popup and it pretty complex.

Best regards,

marc_carrio
Champ in-the-making
Champ in-the-making
Smiley Happy

The UserComponent is the best example and good template to start the work, but i don't know if can put a "complex component" in a Form… because Forms uses Fields and don't Components…

public abstract Field getPropertyField(FormProperty formProperty);
Do you think that I can solve this problem with Form Properties?

Thanks and best regards

trademak
Star Contributor
Star Contributor
Hi,

You can work with process variables that can be as complex as you want.
For the form properties themselves, you always have to transform them to and from String values. So there the possibilities are more limited.

Best regards,

marc_carrio
Champ in-the-making
Champ in-the-making
Hi,

If I use process variables, the table out of Form Properties… the problem we have is that this table is not for all processes, and therefore the process should be defined the fields, popup and other casuistics…

In short, how can I make a custom table from the process definition (Form properties or other)?

- Should I use a FormLayout CustomLayout by allowing components?
- I make a new "Form properties extended" with new tags and all that entails?
- Or resigns  Smiley Wink

Thank you and good weekend!