That's correct Jim, it's a standard part of all my ActionForms. But, it's a generic function, you can insert it into any class and be off to the races. As I said, if you wanted to make it a helper function that you just pass a class too, that also shouldn't be a problem, and that would deal with the situation where you can't alter the beans' source.


-- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com

Jim Douglas wrote:
Frank,

You're using it from an ActionForm....I have this problem in a class where I am implementing a Tiles Controller, could that be the problem? I had a database connectivity problem in this controller class already and had to resort to JNDI.


Jim



From: [EMAIL PROTECTED]
Reply-To: "Struts Users Mailing List" <user@struts.apache.org>
To: user@struts.apache.org
Subject: Re: JSP bean
Date: Fri, 7 Jan 2005 12:12:17 -0800 (PST)

I always include the following method in all my 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]




---------------------------------------------------------------------
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