You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Jonathon -- Improov <jo...@improov.com> on 2007/05/27 09:32:54 UTC

test for Map does not do deep test

Hey Chris (Howes),

I think you use Minilang a lot, so I really need your advice.

Currently, <if-empty field-name="someMap"> returns false even if "someMap" contains keys pointing 
to empty values. See Java method ObjectType.isEmpty(Object value) where value is a java.util.Map.

Do you think we should add an attribute say "deep-test" (true/false value)?

I handle nested maps a lot, since it's more organized (structured) that way.

Jonathon

Re: test for Map does not do deep test

Posted by Jacques Le Roux <ja...@les7arts.com>.
Just a quick note.

It's often in the other way, but would not this thread be better in dev
ML ?

Jacques

----- Message d'origine ----- 
De : "Chris Howe" <cj...@yahoo.com>
À : <us...@ofbiz.apache.org>
Envoyé : dimanche 27 mai 2007 17:57
Objet : Re: <if-empty> test for Map does not do deep test


> Hi Jonathon,
>
> (it's Howe btw, no "s")
>
> I wouldn't agree with that approach.  A map is empty if it has no
> name/value pairs, not if one (or all) of the name/value pairs is
empty.
> 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.  Remember that the simple methods are
> primarily for business logic not a replacement for java, so if you're
> running into complicated scenarios you may want to rethink whether
> logic is "business" or if it's application.
>
> If you're simply looking to avoid resetting the server or rebuilding
> your packages, you can still use the <call-bsh><![CDATA[ and run
> beanshell inside of it, just make sure you return the field before
> exiting ]]></call-bsh>.
>
>
> --- Jonathon -- Improov <jo...@improov.com> wrote:
>
> > Hey Chris (Howes),
> >
> > I think you use Minilang a lot, so I really need your advice.
> >
> > Currently, <if-empty field-name="someMap"> returns false even if
> > "someMap" contains keys pointing
> > to empty values. See Java method ObjectType.isEmpty(Object value)
> > where value is a java.util.Map.
> >
> > Do you think we should add an attribute say "deep-test" (true/false
> > value)?
> >
> > I handle nested maps a lot, since it's more organized (structured)
> > that way.
> >
> > Jonathon
> >


Re: test for Map does not do deep test

Posted by Chris Howe <cj...@yahoo.com>.
Hi Jonathon,

(it's Howe btw, no "s")

I wouldn't agree with that approach.  A map is empty if it has no
name/value pairs, not if one (or all) of the name/value pairs is empty.
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.  Remember that the simple methods are
primarily for business logic not a replacement for java, so if you're
running into complicated scenarios you may want to rethink whether
logic is "business" or if it's application.

If you're simply looking to avoid resetting the server or rebuilding
your packages, you can still use the <call-bsh><![CDATA[ and run
beanshell inside of it, just make sure you return the field before
exiting ]]></call-bsh>.


--- Jonathon -- Improov <jo...@improov.com> wrote:

> Hey Chris (Howes),
> 
> I think you use Minilang a lot, so I really need your advice.
> 
> Currently, <if-empty field-name="someMap"> returns false even if
> "someMap" contains keys pointing 
> to empty values. See Java method ObjectType.isEmpty(Object value)
> where value is a java.util.Map.
> 
> Do you think we should add an attribute say "deep-test" (true/false
> value)?
> 
> I handle nested maps a lot, since it's more organized (structured)
> that way.
> 
> Jonathon
>