To write the size of collection object or array,
you can <bean:size id="size" name="thecollection"/>
and write with <bean:write name="size"/>.

The "size" bean can also be used with the tag
<logic:notEqual name="size" value="0">
...
</logic:notEqual>

In the case of toString, if you don't specify a property
attribute in the tag <bean:write>, the output is the toString
of the object, like the above example.

This may help to avoid scriptlet in the JSP in some
cases.

Fernando


----- Original Message ----- 
From: "c tang" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Thursday, January 17, 2002 10:41 AM
Subject: Re: Is there a better way to write this code?


> Creating a wrapper class may get rid of scriptlet in
> JSP. But that means for every public api (such as
> Collection.size(), Object.toString()) that does not
> fit get/set pattern, a wrapper class has to be created
> in order to avoid scriptlet using struts.  IMHO, that
> is worse than just using scriptlet because it bloats
> the class number significantly.
> 
> ct
> 
> --- Arron Bates <[EMAIL PROTECTED]> wrote:
> > A getter method like...
> > 
> > public int getMyListSize() {
> > return this.myList.getSize();
> > }
> > 
> > with a tag like...
> > <bean:write name="myForm" property="myListSize" />
> > ...maybe?
> > 
> > 
> > Arron.


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to