You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by footh <fo...@yahoo.com> on 2005/07/22 19:52:54 UTC
Test for blank or null string in Jx
This seems like it should be easy but I've tried a
million different combinations and I can't seem to get
a jx if tag to test for a blank or null string.
Can someone point me in the right direction?
__________________________________
Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mailtour.html
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Test for blank or null string in Jx
Posted by Andrew Franz <af...@optushome.com.au>.
The following is JSP/JSTL equivalent to test for null parameters or
database columns:
<c:when test="${empty rs.foo}">
<c:when test="${empty param.foo}">
footh wrote:
>Thanks for the reply but still no luck using this
>(with a param that is null):
>
><jx:if test="isEmpty (${mynullparam})">
>
>I even tried:
>
><jx:if test="isEmpty (null)">
>and
><jx:if test="isEmpty ('')">
>
>Both resolve to false. Additionally, I have a
>parameter that I know I'm passing as a blank string
>(""). And when I do this:
>
><jx:if test="${myblankparam} == ''">
>
>It resolves to true as expected. However, when I do
>this:
>
><jx:if test="${myparam} != ''">
>
>It still resolves to true. This is driving me crazy.
>Any other suggestions?
>
>--- Mark Lundquist <ml...@wrinkledog.com> wrote:
>
>
>
>>On Jul 22, 2005, at 10:52 AM, footh wrote:
>>
>>
>>
>>>This seems like it should be easy but I've tried a
>>>million different combinations and I can't seem to
>>>
>>>
>>get
>>
>>
>>>a jx if tag to test for a blank or null string.
>>>
>>>Can someone point me in the right direction?
>>>
>>>
>>Been there, felt the pain. I don't know why it
>>doesn't "just work" the
>>way you would expect.
>>
>>Anyway, this will work
>>
>> <jx:if test="isEmpty (theString)">
>>
>>cheers,
>>—ml—
>>
>>
>>
>>
>>
>---------------------------------------------------------------------
>
>
>>To unsubscribe, e-mail:
>>users-unsubscribe@cocoon.apache.org
>>For additional commands, e-mail:
>>users-help@cocoon.apache.org
>>
>>
>>
>>
>
>
>
>
>____________________________________________________
>Start your day with Yahoo! - make it your home page
>http://www.yahoo.com/r/hs
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Test for blank or null string in Jx
Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Jul 22, 2005, at 2:37 PM, JD Daniels wrote:
> Hmm. to my way of thinking you need two checks, because null is not
> the same as ''
>
> <jx:if test="$var!=null">
> <jx:if test="empty($var)">
> var is empty
> </jx:if>
> var is null
> </jx:if>
>
no, empty( ) returns true for null (see
http://jakarta.apache.org/commons/jexl/reference/syntax.html).
—ml—
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Test for blank or null string in Jx
Posted by JD Daniels <jd...@kismetsoftware.com>.
Hmm. to my way of thinking you need two checks, because null is not the
same as ''
<jx:if test="$var!=null">
<jx:if test="empty($var)">
var is empty
</jx:if>
var is null
</jx:if>
footh wrote:
> Ugh...still the same problem. Would you expect this
> to work?
>
> <jx:if test="empty (null)">
>
> Because that returns false. Same with this:
>
> <jx:if test="empty ('')">
>
> I searched all the samples for the text "empty(" and I
> can't seem to find any examples. Any other
> suggestions? I've spent way too much time on such a
> simple logic statement. Doh!
>
> --- Mark Lundquist <ml...@wrinkledog.com> wrote:
>
>
>>On Jul 22, 2005, at 11:42 AM, footh wrote:
>>
>>
>>>Thanks for the reply but still no luck using this
>>>(with a param that is null):
>>>
>>><jx:if test="isEmpty (${mynullparam})">
>>>
>>>I even tried:
>>>
>>><jx:if test="isEmpty (null)">
>>>and
>>><jx:if test="isEmpty ('')">
>>>
>>Sorry, my bad... the function is 'empty', not
>>'isEmpty'! I remember
>>now that I'm looking at it in email :-/
>>
>>—ml—
>>
>>
>>
>
> ---------------------------------------------------------------------
>
>>To unsubscribe, e-mail:
>>users-unsubscribe@cocoon.apache.org
>>For additional commands, e-mail:
>>users-help@cocoon.apache.org
>>
>>
>
>
>
>
>
> ____________________________________________________
> Start your day with Yahoo! - make it your home page
> http://www.yahoo.com/r/hs
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Test for blank or null string in Jx
Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Jul 22, 2005, at 1:37 PM, footh wrote:
> Trying a million more combinations, I finally figured
> it out. These both return true (for a null param and
> blank string param respectively):
>
> <jx:if test="${empty(mynullparam)}">
> <jx:if test="${empty(myblankparam)}">
Yes, that should be correct: see
http://jakarta.apache.org/commons/jexl/reference/syntax.html
>
> Also, the problems I was having comparing params with
> "==" and "!=" operators was due to the fact that they
> were strings. I forgot that when dealing with strings
> in java, one should use the "equals()" function.
well hmmmm... according to the doc referenced above, == and != use Java
equals().
—ml—
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Test for blank or null string in Jx
Posted by footh <fo...@yahoo.com>.
Trying a million more combinations, I finally figured
it out. These both return true (for a null param and
blank string param respectively):
<jx:if test="${empty(mynullparam)}">
<jx:if test="${empty(myblankparam)}">
Also, the problems I was having comparing params with
"==" and "!=" operators was due to the fact that they
were strings. I forgot that when dealing with strings
in java, one should use the "equals()" function.
Ex.
<jx:if test="${myblankparam.equals(''}">
resolves to true
<jx:if test="${mynullparam.equals(NULL}">
doesn't work...probably hits a null pointer exception
the generator
<jx:if test="${mynullparam == NULL}">
resolves to true
Another key thing I was missing is I was only putting
the brackets around the parameter, not the whole
expression. Oh well, lesson learned. Thanks for the
help.
--- footh <fo...@yahoo.com> wrote:
> Ugh...still the same problem. Would you expect this
> to work?
>
> <jx:if test="empty (null)">
>
> Because that returns false. Same with this:
>
> <jx:if test="empty ('')">
>
> I searched all the samples for the text "empty(" and
> I
> can't seem to find any examples. Any other
> suggestions? I've spent way too much time on such a
> simple logic statement. Doh!
>
> --- Mark Lundquist <ml...@wrinkledog.com> wrote:
>
> >
> > On Jul 22, 2005, at 11:42 AM, footh wrote:
> >
> > > Thanks for the reply but still no luck using
> this
> > > (with a param that is null):
> > >
> > > <jx:if test="isEmpty (${mynullparam})">
> > >
> > > I even tried:
> > >
> > > <jx:if test="isEmpty (null)">
> > > and
> > > <jx:if test="isEmpty ('')">
> > >
> >
> > Sorry, my bad... the function is 'empty', not
> > 'isEmpty'! I remember
> > now that I'm looking at it in email :-/
> >
> > ml
> >
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail:
> > users-help@cocoon.apache.org
> >
> >
>
>
>
>
> ____________________________________________________
> Start your day with Yahoo! - make it your home page
> http://www.yahoo.com/r/hs
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail:
> users-help@cocoon.apache.org
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Test for blank or null string in Jx
Posted by footh <fo...@yahoo.com>.
Ugh...still the same problem. Would you expect this
to work?
<jx:if test="empty (null)">
Because that returns false. Same with this:
<jx:if test="empty ('')">
I searched all the samples for the text "empty(" and I
can't seem to find any examples. Any other
suggestions? I've spent way too much time on such a
simple logic statement. Doh!
--- Mark Lundquist <ml...@wrinkledog.com> wrote:
>
> On Jul 22, 2005, at 11:42 AM, footh wrote:
>
> > Thanks for the reply but still no luck using this
> > (with a param that is null):
> >
> > <jx:if test="isEmpty (${mynullparam})">
> >
> > I even tried:
> >
> > <jx:if test="isEmpty (null)">
> > and
> > <jx:if test="isEmpty ('')">
> >
>
> Sorry, my bad... the function is 'empty', not
> 'isEmpty'! I remember
> now that I'm looking at it in email :-/
>
> ml
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail:
> users-help@cocoon.apache.org
>
>
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Test for blank or null string in Jx
Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Jul 22, 2005, at 11:42 AM, footh wrote:
> Thanks for the reply but still no luck using this
> (with a param that is null):
>
> <jx:if test="isEmpty (${mynullparam})">
>
> I even tried:
>
> <jx:if test="isEmpty (null)">
> and
> <jx:if test="isEmpty ('')">
>
Sorry, my bad... the function is 'empty', not 'isEmpty'! I remember
now that I'm looking at it in email :-/
—ml—
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Test for blank or null string in Jx
Posted by footh <fo...@yahoo.com>.
Thanks for the reply but still no luck using this
(with a param that is null):
<jx:if test="isEmpty (${mynullparam})">
I even tried:
<jx:if test="isEmpty (null)">
and
<jx:if test="isEmpty ('')">
Both resolve to false. Additionally, I have a
parameter that I know I'm passing as a blank string
(""). And when I do this:
<jx:if test="${myblankparam} == ''">
It resolves to true as expected. However, when I do
this:
<jx:if test="${myparam} != ''">
It still resolves to true. This is driving me crazy.
Any other suggestions?
--- Mark Lundquist <ml...@wrinkledog.com> wrote:
>
> On Jul 22, 2005, at 10:52 AM, footh wrote:
>
> > This seems like it should be easy but I've tried a
> > million different combinations and I can't seem to
> get
> > a jx if tag to test for a blank or null string.
> >
> > Can someone point me in the right direction?
>
> Been there, felt the pain. I don't know why it
> doesn't "just work" the
> way you would expect.
>
> Anyway, this will work
>
> <jx:if test="isEmpty (theString)">
>
> cheers,
> ml
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail:
> users-help@cocoon.apache.org
>
>
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Test for blank or null string in Jx
Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Jul 22, 2005, at 10:52 AM, footh wrote:
> This seems like it should be easy but I've tried a
> million different combinations and I can't seem to get
> a jx if tag to test for a blank or null string.
>
> Can someone point me in the right direction?
Been there, felt the pain. I don't know why it doesn't "just work" the
way you would expect.
Anyway, this will work
<jx:if test="isEmpty (theString)">
cheers,
—ml—
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org