> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Friday, January 07, 2005 1:12 PM
> To: user@struts.apache.org
> Subject: Re: JSP bean
> 
> 
> I always include the following method in all my 

There's a handy plugin called commclipse that I use to create my toStrings, 
equals, hashCodes and compareTo's.  It also requires the commons-lang jar as 
well.
Right click->commonclipse->toString and voila it either creates it or rewrites 
it.
The commons-lang jar has some really cool stuff all by itself, including a 
TostringBuilder. commonclipse just makes it a click away.


> ActionForms... I'm sure you can do the same in whatever bean 
> you have, or adapt it to be able to pass the bean to it if 
> you can't modify the bean itself... This will actually show 
> you all fields AND their values, but you can of course hack 
> it as you need to...
> 
> import java.lang.reflect.Field;
> 
>   public String toString() {
> 
>     String str = null;
>     StringBuffer sb = new StringBuffer(1000);
>     sb.append(this.getClass().getName() + " [" + 
> super.toString() + "] = { ");
>     try {
>       Field[] fields = this.getClass().getDeclaredFields();
>       for (int i = 0; i < fields.length; i++) {
>         if (sb.length() > 0) { sb.append(", "); }
>         sb.append(fields[i].getName() + "=" + fields[i].get(this));
>       }
>       sb.append(" }");
>       str = sb.toString().trim();
>     } catch (Exception e) { }
>     return str;
> 
>   }
> 
> -- 
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> 
> On Fri, January 7, 2005 3:06 pm, Jim Douglas said:
> > To all,
> > I have a bean that's present in a JSP, does anyone know how to loop
> > through
> > a bean and list out the properties available?
> > 
> > Here's the cose I have
> > 
> > <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
> > <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
> > 
> > <html><head><title>form.heading</title></head>
> >   <center><body><h4><bean:message key="form.heading" /></h4>
> >     <logic:present name="forms">
> >       <table border="1">
> >       <logic:iterate id="forms" name="forms">
> >       <tr><td>
> >             <bean:write name="forms" property="formName"/>
> >          </td>
> >          <td>
> >             <bean:write name="forms" property="formDesc"/>
> >          </td>
> >       <td><a href="<bean:write name="forms" 
> property="formLocation"/>.do
> > "/>
> >           <bean:write name="forms" property="formLocation"/></a>
> >          </td>
> >       </tr>
> >       </logic:iterate>
> >     </table>
> > 
> >     </logic:present>
> > 
> >   </body></center>
> > </html>
> > 
> > 
> >   I don't know why but "formDesc" can't be found, but the 
> bean is present
> > in
> > the JSP/
> > 
> >   I'm using IntelliJ.  Does anyone know a good IDE or add 
> in for debugging
> > JSP's?
> > 
> > Thanks,
> > Jim
> > 
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> 
> 

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

Reply via email to