As many of you know, the introduction of the Uniform Expression Language into the framework caused some backward compatibility problems - specifically with IDs being used as Map keys. I tried to accommodate that with a couple of bits of code, but there are still some issues.

There have been suggestions on the mailing list for workarounds, but not all of them work, nor do they work all the time. I don't want to hack up the UEL library further, because its my viewpoint that OFBiz should conform to existing standards, not twist existing standards to conform to OFBiz.

The crux of the main problem is the implementation of auto-vivify that I added to the UEL. Using the following code as an example:

<set field="someVar[someEntity.someId]" value="Hello World!"/>

If someVar was not previously defined, the auto-vivify code tries to guess what data type someVar is supposed to be. If someEntity.someId evaluates to an integer, the code assumes it is an index and creates a List, otherwise it creates a Map. This works fine in most cases.

The problem comes when someEntity.someId evaluates to an integer (most IDs are integers) and the developer intended someVar to be a Map, not a List. There needs to be a way to create and empty Map in those cases.

I believe the best solution is to modify the <set> element to allow the creation of an empty Map or List. This will remove the ambiguity and solve the problem - without further modifying UEL.

I modified my local copy to allow the creation of an empty Map:

<set field="someVar" type="NewMap"/>
<set field="someVar[someEntity.someId]" value="Hello World!"/>

and it works great.

So, the bottom line is, I would like to add "NewMap" and "NewList" to the <set> element type attribute. What do you think?

-Adrian

Reply via email to