Hi Jonathon,
I'm finding it a bit difficult to follow, so I'll attempt to group it.
Please correct me if I group your concerns incorrectly.
1. <call-bsh>
If you find some part of simple methods cumbersome or too difficult,
you can always drop into beanshell script (interpreted Java) by using
the <call-bsh> tag e.g.
<call-bsh><![CDATA[
...
some java code or beanshell script code
...
return org.ofbiz.base.util.UtilMisc.toMap("noMapVariableName", value);
or
mapName.put("variableName", value);
]]/></call-bsh>
this makes available either nomapVariableName or mapName.variableName
for the rest of your simple method.
2. if conditionals
if you're wanting to test multiple statements, you can use the
following
<if>
<condition>
<or>
<not>
<if-empty field-name=""></if-empty>
<if-empty field-name=""></if-empty>
<if-empty field-name=""></if-empty>
</not>
</or>
</condition>
<then>
...
</then>
</if>
or you may find it easier to accomplish what you're wanting through a
java method
<call-class-method method="jonathonEmptyMapTest"
class="org.jon.w.specialClass" ret-field="emptyMapBoolean">
<field field-name="mapToTest" type="Map"/>
</call-class-method>
<if-compare field="emptyMapBoolean" operator="equals" value="true"
type="Boolean">
...
</if-compare>
3. final thoughts...
What helps to keep simple methods easy to use is it's limited
operations. As far as the scope improvement, I'm on the fence on the
benefit it may offer versus how it might complicate and confuse the
easy to understand non-scoped call. Be careful thinking of simple
methods as a replacement for java classes, it's simply another tool in
your OFBiz toolbox. No sense outfitting a nail gun with a rotary
attachment when you already have a Dremel lying on your bench.
--- Jonathon -- Improov <[EMAIL PROTECTED]> wrote:
> Topic was "Re: <if-empty> test for Map does not do deep test".
>
> Hi Chris (Howe),
>
> You were saying that I can avoid restarting the server or recompiling
> my codes if I use
> <call-bsh><![CDATA]> and Minilang. I haven't explored using Minilang
> in bean shell. Is it possible?
>
> > To attempt the test that you're trying, either test the actual
> field that
> > you're interested in or if unknown run an iterate-map and set the
> value of
> > some field (to if-not-empty test later) to a value if you
> encounter an empty
> > field.
>
> I currently do it in some "validateInputs" method, which avoids
> setting a field (inside a deep map
> structure, a constructed result, like a map-processor but more
> elaborate) if the input parameters
> were empty. It's a matter of doing it there, or later on before I use
> the constructed results.
>
> If there were a deep if-empty test for Map(s), it'll just mean I can
> do away with many individual
> <if-empty> statements, and just plonk values in "parameters" into my
> constructed result.
>
> Ultimately, I want to do <if-not-empty
> field-name="result.primaryPhone">, rather than go through
> primaryPhone.countryCode and primaryPhone.areaCode individually.
>
> When you say "test the field [I] am interested in", that's difficult
> to apply in my case. I think
> I've been using Minilang too much like Java, object-oriented, with
> nested Map structures being
> passed around.
>
> Well, if you're interested, and I think you use lots of Minilang,
> I've been unwittingly making
> Minilang more and more robust like OO Java. It started out with the
> motivation to avoid server
> restarts and Java code compiles, but is looking like the resultant
> Minilang is as good and clean
> as Java can be. I might just continue to use Minilang and avoid Java
> as much as possible. The
> extensions to Minilang is minimal. Took me an hour or less to create
> and test
> CallSimpleMethodScoped.java.
>
> Jonathon
>