You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by "Jacques Le Roux (JIRA)" <ji...@apache.org> on 2009/08/14 16:42:14 UTC

[jira] Commented: (OFBIZ-2831) Allow fields to be set directly from a bsh scriptlet

    [ https://issues.apache.org/jira/browse/OFBIZ-2831?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12743216#action_12743216 ] 

Jacques Le Roux commented on OFBIZ-2831:
----------------------------------------

Hi Bob,

Quick answer : why not using [UEL|http://docs.ofbiz.org/x/Hhk] ? 

> 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: SVN trunk
>            Reporter: Bob Morley
>         Attachments: 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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.