cancel
Showing results for 
Search instead for 
Did you mean: 

PropertyNotFoundException in form

kaech
Champ in-the-making
Champ in-the-making
I am trying to map JavaBean properties to form properties as described in the user guide.

<userTask id="order" name="order" activiti:formKey="order.form">
<documentation>order</documentation>      
<extensionElements>
<activiti:formProperty id="quantity" variable="quantity" expression="#{order.quantity}" required="true" type="long" />
</extensionElements>

</userTask>

In the form I always get a javax.el.PropertyNotFoundExeption for the property quantity.
In ACT_RU_VARIABLE I only see the serialized JavaBean.
${order.quantity} is available in the form but ${quantity} is not.

Do you have any advice?
31 REPLIES 31

kaech
Champ in-the-making
Champ in-the-making
I mean that I don't declare the task form properties anywhere. The only occurences are shown below in red.
The process is started using the Activiti Explorer. So thequantity is not provided by the caller when the process starts.

order.bpmn2.0.xml
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
   xmlns:activiti="http://activiti.org/bpmn"
   xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
   xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC"
   xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI"
   xmlns:signavio="http://www.signavio.com"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   expressionLanguage="http://www.w3.org/1999/XPath"
   id="sid-95da716d-f515-46b8-8677-56a60dbc13c5"
   targetNamespace="http://www.signavio.com/bpmn20"
   typeLanguage="http://www.w3.org/2001/XMLSchema"
   xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL http://www.omg.org/spec/BPMN/2.0/20100501/BPMN20.xsd">

   <process id="order" isClosed="false" isExecutable="true" name="order" processType="None">

      <startEvent id="start" name="Start"/>

      <sequenceFlow id="flow4" sourceRef="start" targetRef="init"/>
     
      <scriptTask id="init" name="Init" scriptFormat="groovy">
         <script>
         order = new org.example.Order(quantity:2)
         </script>
      </scriptTask>
     
      <sequenceFlow id="flow3" sourceRef="init" targetRef="placeorder"/>
     
      <userTask id="placeorder" name="Place order" activiti:formKey="order.form">
         <documentation>order</documentation>      
         <extensionElements>
             <activiti:formProperty id="thequantity" expression="#{order.quantity}" />
         </extensionElements>
         <potentialOwner>…</potentialOwner>       
      </userTask>

      <sequenceFlow id="flow2" sourceRef="placeorder" targetRef="orderfood"/>

      <scriptTask id="orderfood" name="Order food" scriptFormat="groovy">
         <script>outSmiley Tonguerint "Ordering $order.quantity\n"</script>
      </scriptTask>

      <sequenceFlow id="flow1" sourceRef="orderfood" targetRef="end"/>

      <endEvent id="end" name="End"/>

   </process>

</definitions>

order.form
<h1>order</h1>
Quantity is ${thequantity}

Is this really enough to map process variables to task form properties?

frederikherema1
Star Contributor
Star Contributor
I see what you are trying to do here… You're mixing up the built-in rendering (that only resolves variables in the HTML expressions, in your order.form) with the form-properties. Form properties should be used when you want to render your own forms, not using getRendered(Start)Form. So the error resulted from rendering the form, rather than getting the form-properties.

Basically, you should decide wether you want to use built-in form rendering (eg. html-forms used in explorer) or use form-properties which you declare with the activiti:formProperty.

Check out http://activiti.org/userguide/index.html#forms -> Built in vs. form properties

kaech
Champ in-the-making
Champ in-the-making
Ah, I see. Thanks.

I am trying to implement an external UI so using form-properties is basically the right approach.
Since my client is external to the Activiti/Tomcat deployment I wanted to use the REST interface (activiti-rest).

When I try that I am getting the same exception:

PropertyNotFoundException: Cannot find property thequantity

Aren't the form-properties exposed via the REST-API?

frederikherema1
Star Contributor
Star Contributor
In the 5.4 release, they are Smiley Wink You shouldn't use the *.form files (and formKey) if you want external rendering

kaech
Champ in-the-making
Champ in-the-making
That's good news. I'll wait for the 5.4. release then.
By the way, are there any plans to expose the serialized JavaBeans via the REST interface as well?
For external UI-Clients it would be great not to be limited to to the flat form-property representation but also having access to the complex process data.

frederikherema1
Star Contributor
Star Contributor
Nothing planned in that direction… but the form-type mechanism is pluggable. So you could easily write a FormType that handles conversion of serializable -> String and visa versa.

see org.activiti.engine.impl.form.AbstractFormType, ProcessEngineConfigurationImpl.customFormTypes

kaech
Champ in-the-making
Champ in-the-making
Is it possible to plug-in a custom form type via configuration?
Or do I have to change the Activiti sourcecode?

frederikherema1
Star Contributor
Star Contributor
It can be done using configuration, ProcessEngineConfigurationImpl.customFormTypes:

<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
    …
    <property name="customFormTypes">
       <list>
         <ref bean="myFormType"/>
       </list>
    </property>
    …

kaech
Champ in-the-making
Champ in-the-making
I implemented a custom form type derived from AbstractFormType and declared it in activiti.cfg.xml of the activiti-rest application as you described in your previous post.

The method getName returns order as the name.

In the process definition I added

<activiti:formProperty id="theorder" expression="#{order}" type="order"/>

to expose the whole order class as a form property.
When I upload the process I get the message unknown type 'order' ….

How do I have to define the formProperty in order to let Actitivi use my custom form type class?

frederikherema1
Star Contributor
Star Contributor
Adding your type to the custom from-types should do the trick:

protected void initFormTypes() {
    if (formTypes==null) {
      formTypes = new FormTypes();
      formTypes.addFormType(new StringFormType());
      formTypes.addFormType(new LongFormType());
      formTypes.addFormType(new DateFormType("dd/MM/yyyy"));
    }
    if (customFormTypes!=null) {
      for (AbstractFormType customFormType: customFormTypes) {
        formTypes.addFormType(customFormType);
      }
    }
  }

Do you get the error when deploying? or when running the process?