You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Neil Aggarwal <ne...@JAMMConsulting.com> on 2007/07/18 23:47:53 UTC

[Struts 2] If exists tag?

Hello:

Is there a struts tag to check if a collection is not null
and has at least one element?

I want to check a collection before printing the table
containing the elements using an <s:iterator> tag.

Thanks,
	Neil


--
Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [Struts 2] If exists tag?

Posted by Dale Newfield <Da...@Newfield.org>.
Musachy Barroso wrote:
> <s:if test="collection != null && !collection.isEmpty()">
> ...
> </s:if>
> 
> //more elegant :)

<s:if test="collection != null && !collection.isEmpty">
...
</s:if>

http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/specialCollectionsProperties.html

isEmpty is a "pseudo-property" of every collection, so there's no reason 
to call it as a method().

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [Struts 2] If exists tag?

Posted by Musachy Barroso <mu...@gmail.com>.
<s:if test="collection != null && !collection.isEmpty()">
...
</s:if>

//more elegant :)

On 7/18/07, Musachy Barroso <mu...@gmail.com> wrote:
>
> <s:if test="collection != null && collection.size() > 0">
> ...
> </s:if>
>
> musachy
>
> On 7/18/07, Neil Aggarwal < neil@jammconsulting.com> wrote:
> >
> > Hello:
> >
> > Is there a struts tag to check if a collection is not null
> > and has at least one element?
> >
> > I want to check a collection before printing the table
> > containing the elements using an <s:iterator> tag.
> >
> > Thanks,
> >         Neil
> >
> >
> > --
> > Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
> > FREE! Eliminate junk email and reclaim your inbox.
> > Visit http://www.spammilter.com for details.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd




-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

Re: [Struts 2] If exists tag?

Posted by Musachy Barroso <mu...@gmail.com>.
<s:if test="collection != null && collection.size() > 0">
...
</s:if>

musachy

On 7/18/07, Neil Aggarwal <ne...@jammconsulting.com> wrote:
>
> Hello:
>
> Is there a struts tag to check if a collection is not null
> and has at least one element?
>
> I want to check a collection before printing the table
> containing the elements using an <s:iterator> tag.
>
> Thanks,
>         Neil
>
>
> --
> Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
> FREE! Eliminate junk email and reclaim your inbox.
> Visit http://www.spammilter.com for details.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd