[ https://issues.apache.org/jira/browse/OFBIZ-2831?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14568977#comment-14568977 ]
Pierre Smits commented on OFBIZ-2831: ------------------------------------- Should we still keep this open, or is this sufficiently resolved? > Allow fields to be set directly from a bsh scriptlet > ---------------------------------------------------- > > Key: OFBIZ-2831 > URL: https://issues.apache.org/jira/browse/OFBIZ-2831 > Project: OFBiz > Issue Type: Improvement > Components: framework > Affects Versions: Trunk > Reporter: Bob Morley > Attachments: OFBIZ-2831.patch, OFBIZ-2831.patch > > > We have made an improvement to the SetField class in Screen, Field, Menu, and > Tree. You used to do something like this -- > <set field="name" value="${bsh:org.ofbiz.Foo.Bar()}" type="Integer" /> > A disadvantage of this technique is that the value is handled by a > FlexibleStringExpander (which will always return a string). Implementation > of this expander will notice the "bsh" and parse out the scriptlet, interpret > and get an Object back, then convert the Object to a String. The caller (say > ModelScreenAction) will then take this Object and do a simple type conversion > (on ObjectType) to the desired type for the user. This works fine if the > function can return something that can convert to a String and then back to > the desired type. When the return result can not (say a List) then you are > pooched. > My proposed solution is make the grammar more clear in the xml for the Model > Action by explicitly stating that we will be providing a bsh scriptlet. > Moreover, since we directly call for the Object we can directly convert to > the desired object which will work properly for non-string serializable > objects like lists and maps. > <set field="name" from-bsh="org.ofbiz.Foo.Bar()" type="Integer" /> > The implementation does treat the scriptlet as a FlexibleString so it will > convert inside for labels resolution and the like. -- This message was sent by Atlassian JIRA (v6.3.4#6332)