<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic put 'null' to ProcessVariableMap in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/put-null-to-processvariablemap/m-p/139916#M98024</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for a save method of tasks i'm iterating over a list of available ProcessVariableKeys and using the &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;runtime service to flush variables without completing the task:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;for (String varName : processVariableKeyList) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; runtimeService.setVariable(businessProcess.getExecutionId(), varName, processVariables.get(varName));&lt;BR /&gt;}&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;This works perfectly fine for all variables. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;However, if the user "removes" a entry from a Input, that is converted to a Double OR Date OR Long ….&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The Converter returns "null" for that value, and therefore calls &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;processVariables.put("someDate",null);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;calling&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;processVariables.get("someDate") afterwards will however return the PRIOR value of the date / double ….&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is this a known bug or expected behaviour and im doing something wrong?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;processVariables.put("aDouble", 50.0); //works&lt;BR /&gt;processVariables.put("aDouble", null);&lt;BR /&gt;System.out.println(processVariables.get("aDouble")); //returns 50.0&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Working with activiti 5.10&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Mar 2013 17:08:12 GMT</pubDate>
    <dc:creator>dognose</dc:creator>
    <dc:date>2013-03-20T17:08:12Z</dc:date>
    <item>
      <title>put 'null' to ProcessVariableMap</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/put-null-to-processvariablemap/m-p/139916#M98024</link>
      <description>Hello,for a save method of tasks i'm iterating over a list of available ProcessVariableKeys and using the runtime service to flush variables without completing the task:for (String varName : processVariableKeyList) {&amp;nbsp;&amp;nbsp; runtimeService.setVariable(businessProcess.getExecutionId(), varName, processVari</description>
      <pubDate>Wed, 20 Mar 2013 17:08:12 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/put-null-to-processvariablemap/m-p/139916#M98024</guid>
      <dc:creator>dognose</dc:creator>
      <dc:date>2013-03-20T17:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: put 'null' to ProcessVariableMap</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/put-null-to-processvariablemap/m-p/139917#M98025</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;CODE&gt;processVariables.put("someDate",null);&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;Is this activiti-code or your code?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Mar 2013 08:09:37 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/put-null-to-processvariablemap/m-p/139917#M98025</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2013-03-21T08:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: put 'null' to ProcessVariableMap</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/put-null-to-processvariablemap/m-p/139918#M98026</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;sry for posting "a little" late. Until now we bypassed the problem, but now we need to reconsider a solution to this problem. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Basically a user is able to "empty" a textfield from the UI-Point of view. Until now, we putted an empty string, which worked fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But for Data-Maintenance Reasons we need to store a null value instead of an empty string, whenever a user is going to empty the text-field.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Therefore we setup the following in the web.xml:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;lt;context-param&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;param-name&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/param-name&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;param-value&amp;gt;true&amp;lt;/param-value&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;/context-param&amp;gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;So, what has this to do with activiti? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Our form-elements are directly bounded to the entry in the ProcessvariableMap. Using a JSF 2.2 ViewScope, we perform some Ajax Operations and finally the submission of the form. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Every change to a field is stored properly, eccept when it resolves to `null`. We followed the Stacktrace down to the `ConversationScopeAssociation` of `DefaultContextAssociationManager` and found the following piece of code being executed:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;DefaultContextAssociationManager&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;@Override&lt;BR /&gt;&amp;nbsp; public Object getVariable(String variableName) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ExecutionEntity execution = getExecutionFromContext();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(execution != null) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return execution.getVariable(variableName);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return getScopedAssociation().getVariable(variableName);&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;Here, execution will resolve to null, and the else-case will call the ConversationScopedAssociation:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt; public &amp;lt;T&amp;gt; T getVariable(String variableName) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Object value = cachedVariables.get(variableName);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(value == null) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(execution != null) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = runtimeService.getVariable(execution.getId(), variableName);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cachedVariables.put(variableName, value);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return (T) value;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;At this point, the cachedVariable-Map may contain our desired "key=null" - for loging purposes we are iterating over the map and &lt;/SPAN&gt;&lt;STRONG&gt;getting&lt;/STRONG&gt;&lt;SPAN&gt; the values again, to log the change: And this "removes" the null value from the cachedVariable map: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If the "value" is null - it's reloaded by the runtimeService. However at this point, we did not yet save the variables (flush). That means: the null is removed and the "old" value is restored inside the cachedVariable-Map before actually saving the changes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure wheter this is a bug or serves some purpose, but it looks pretty strange. It is essentially saying: "You are not allowing to have null values in the cachedVariable Map".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, the current event-sequence is like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ProcessVariableMap.put("someKey", null); //old value was "Hello World"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-&amp;gt; stored in CachedMap&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-&amp;gt; calling ProcessVariableMap.get("someKey") // returns "Hello World", cause of the code outlined above.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-&amp;gt; calling businessProcess.complete() // now stores "Hello World" again, because the getter writes back to the cachedVariable map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;edit: Running on activiti 5.13&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 May 2014 12:43:03 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/put-null-to-processvariablemap/m-p/139918#M98026</guid>
      <dc:creator>dognose</dc:creator>
      <dc:date>2014-05-14T12:43:03Z</dc:date>
    </item>
  </channel>
</rss>

