Chris,
Have a look at a thread I started at
http://www.nabble.com/forum/ViewPost.jtp?post=10803536&framed=y . You also responded to that
thread too.
When you say "extend" a simple method, it might be easier to simply think of how you would extend
a Java method. We would create a new method that first calls the old method, and then perform some
custom actions after that (or the order could be flipped).
Your suggestion with "selective reuse of parts of a simple method" would mean changing the
original method (by inserting <section-begin> <section-end>), to "generic-ize" the original
method. Then you might as well not call it "extension", but "customization" or "enhancement" or
"refactor" instead.
In that thread I pointed to, I had implemented a <call-simple-method-scoped> which allows simple
methods to call other simple methods *exactly like how Java methods can call other Java methods*.
Unfortunately, the client I worked for now has exclusive rights to that new and convenient
artifact. :/
So what's the problem of having simple methods call other simple methods now, you may ask? Scope
is all mixed up into a single bowl of alphabet soup, single namespace. For those of us who know
Java (or C or VB or just about any programming language at all), we know this isn't conventional,
barely "right".
To offer a solution to your question, I've found that the only way to call other methods in
Minilang with proper scope (stored in call stack) is to use the Service Engine. Yeah, it means
that for every simple method you want to call, wrap them in a service and call the service instead.
Jonathon
Chris Howe wrote:
I'm looking for some feedback on an idea I'm tossing around
Problem: When creating a custom application, often times you will be creating
business logic that is exactly like what is in OFBiz but needs to be slightly
modified before sending it to the entity engine for storage or before creating
a result. (changing the way a price is calculated, adding specialized field
information, etc).
It would helpful to be able to call the OFBiz maintained method and then extend
it through a custom call.
A couple ideas on how to accomplish this
1) Add two new element groups,
<section-begin>
<section name="sectionA"/>
</section-begin
...some logic...
<section-end>
<section name="sectionA"/>
</section-end>
...more logic...
and salt the ofbiz method so that you can pull only the logic between the two
2) mimic the screen-widget's decorator pattern
3) add a map of simple-methods to the method's context that allows running
extended code
extendMethod.myLocation#myMethod
and then salt the ofbiz method to call if it exist.
TIA for any thoughts
,Chris