I had the same problem.  Thanks for your answer.  How do I provide a the key 
name though?  For e.g. suppose I have a map with key names as employeeId, 
employeeLastName, employeeFirstName etc. and I want to print it by calling the 
individual key names, not just arbitrarily any key as I might lose the order in 
that case.

Thanks again,   

-----Original Message-----
From: Wendy Smoak [mailto:[EMAIL PROTECTED]
Sent: Monday, June 27, 2005 4:24 PM
To: Struts Users Mailing List
Subject: Re: iterate on properties of a DynaActionForm


From: "Dewitte Rémi" <[EMAIL PROTECTED]>

> I'm quite new in struts and i'd like to print all properties of my form
with
> their corresponding value. I don't manage to do this with iterate. Could
you
> please suggest me a solution ?
> my bean name is QuestionnaireForm defined in struts-config:
> <form-bean name="QuestionnaireForm"
> type="org.apache.struts.validator.DynaValidatorForm">

Do you just want to see what's in the form, for debugging purposes?

If so, you don't have to iterate, just do:
   <%@ taglib uri="http://java.sun.com/jstl/core"; prefix="c" %>
   <c:out value="${QuestionnaireForm}" />
   (or <bean:write name="QuestionnaireForm" /> )

This just calls the 'toString' method on the form.  In this case,
DynaValidatorForm prints out its internal Map.

If you do need to iterate over the form contents, ask the form for its Map,
then print out the key and value of each MapEntry:

<c:forEach items="${contactForm.map}" var="item" >
  <c:out value="${item.key}" /> - <c:out value="${item.value}" /><br/>
</c:forEach>

If you need help translating to <logic:iterate>, let us know.  (Also, you
might want to make your form name start with a lower-case letter.  Otherwise
it looks like a class name instead of an instance.)

-- 
Wendy Smoak



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


-----------------------------------------
This email transmission and any accompanying attachments may contain CSX
privileged and confidential information intended only for the use of the
intended addressee.  Any dissemination, distribution, copying or action
taken in reliance on the contents of this email by anyone other than the
intended recipient is strictly prohibited.  If you have received this email
in error please immediately delete it and  notify sender at the above CSX
email address.  Sender and CSX accept no liability for any damage caused
directly or indirectly by receipt of this email.


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

Reply via email to