Actually, my suggestion was not to add an attribute to the script element, but 
allow script text under the script element (surrounded by the funny CDATA 
thingy as needed to avoid having to escape characters all over the place).

As for the expression attribute... IMO it would be better to simplify things 
instead of making them more complex. In other words, it would be nice if the 
only different between the value and from-field attributes is that from-field 
is a single expression and value is a string with embeddable expressions.

It might even be nice to consider more scripting consistency in the project and 
use groovy for everything. I thought about this a while back after seeing that 
groovy supports ${} inside quoted strings, and if things were done this way 
then it would be simple:

from-field: evaluate the groovy expression/scriptlet and get the object it 
evaluates to
value: surround it with the groovy triple quotes ["""] and evaluate it, 
returning a string

I guess what it comes down to is that if we could treat from-field like an 
expression we wouldn't need the hacks in value and we wouldn't need a separate 
expression attribute with yet another set of rules for people to learn.

-David


On Feb 23, 2010, at 11:24 AM, Adrian Crum wrote:

> On a related note...
> 
> The problem Adam tried to fix is one of the problems I have with how the 
> scripting language is used. Here are some examples:
> 
> <set field="someField" value="${someMap.someElement}"/>
> <set field="someField" from-field="someMap.someElement"/>
> 
> Both of those set elements do the same thing. The first example is (in my 
> opinion) a hack - it should throw an exception. The value attribute should 
> contain a constant value - not an expression.
> 
> The specific problem Adam tried to fix was:
> 
> <set field="someField" value="${groovy:...}"/>
> 
> Again, I believe that use of the set element should throw an exception. David 
> suggested adding an attribute to the script element that would accept 
> scriptlets (or script fragments). My suggestion is to add a third choice to 
> the set element: expression. So, the set element would look like this:
> 
> <set field="someField" expression="${groovy:...}"/>
> 
> To summarize, a field value can be assigned from a constant value, or from an 
> existing field, or from an expression. Attempts to hack an attribute to make 
> it behave like one of the others results in an exception.
> 
> That's my two cents.
> 
> -Adrian
> 
> Adam Heath wrote:
>>> update your OFBiz instance to any version after the 912645, compile and
>>> just try to login to
>>> https://localhost:8443/ap/control/main or
>>> https://localhost:8443/ar/control/main
>>> 
>>> The page will not be displayed, and the only thing you will see is this
>>> message
>>> ERROR rendering error page [/error/error.jsp], but here is the error
>>> text: org.ofbiz.widget.screen.ScreenRenderException: Error rendering
>>> screen [component://accounting/widget/ar/CommonScreens.xml#main]:
>>> org.ofbiz.base.util.GeneralException: Error running Groovy script at
>>> location
>>> [component://accounting/webapp/accounting/WEB-INF/actions/invoice/InvoiceReport.groovy]
>>> (The current transaction is marked for rollback, not beginning a new
>>> transaction and aborting current operation; the rollbackOnly was caused
>>> by: Service [getPartyAccountingPreferences] threw an unexpected
>>> exception/errororg.ofbiz.service.ServiceValidationException: The
>>> following required parameter is missing:
>>> [getPartyAccountingPreferences.organizationPartyId] (The following
>>> required parameter is missing:
>>> [getPartyAccountingPreferences.organizationPartyId])) (Error running
>>> Groovy script at location
>>> [component://accounting/webapp/accounting/WEB-INF/actions/invoice/InvoiceReport.groovy]
>>> (The current transaction is marked for rollback, not beginning a new
>>> transaction and aborting current operation; the rollbackOnly was caused
>>> by: Service [getPartyAccountingPreferences] threw an unexpected
>>> exception/errororg.ofbiz.service.ServiceValidationException: The
>>> following required parameter is missing:
>>> [getPartyAccountingPreferences.organizationPartyId] (The following
>>> required parameter is missing:
>>> [getPartyAccountingPreferences.organizationPartyId])))
>> Duplicated, checking...

Reply via email to