You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ravi Manthena <ra...@cafesoft.com> on 2001/02/07 22:47:47 UTC
Not sure if this is clear but I wanted to keep it short:
Not sure if this is clear but I wanted to keep it short:
----------------------------------------------------------------------
Working : JSP Source
<jsp:useBean id="wrapper" scope="page"
class="com.arrow.util.StrutsUtil"/>
<h3>Object[] OutPut</h3>
<logic:iterate id="element" name="bean" collection="<%=
wrapper.getDriver() %>" offset="0" length="5">
<br><bean:write name="element"/>
</logic:iterate>
Question :
How can we call a method on the instance of each ArrayObject
Example :
bean.getFirstName()
Any Suggestions will be great.
Ravi Manthena
ravi@cafesoft.com
Re: Not sure if this is clear but I wanted to keep it short:
Posted by "Steven D. Wilkinson" <st...@acm.org>.
Here is one of my examples:
<logic:iterate id="category" type="com.ecs.com.struts.common.Category"
name="<%= Constants.CATEGORIES_ARRAY_KEY %>">
<tr>
<td>
<html:link page="/showCDs.do" name="category" property="mapping">
<bean:write name="category" property="categoryName" filter="true"/>
</html:link>
</td>
</tr>
</logic:iterate>
The Category class is defined as follows:
public class Category implements Serializable {
private int categoryId = 0;
private String categoryName = null;
private HashMap mapping = new HashMap(); //mappings for link parameters
public Category() {
}
public int getCategoryId() {
return categoryId;
}
public void setCategoryId(int categoryId) {
this.categoryId = categoryId;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
/**
* The Mapping HashMap that is passed to the LinkTag in the form
* tag library. The HashMap is a collection of parameters that will
* be used to make a query string and add it to the link.
*/
public void setMapping() {
mapping.put(Constants.CATEGORY_ID, new Integer(categoryId));
mapping.put(Constants.CATEGORY_NAME, categoryName);
}
public Map getMapping() {
return mapping;
}
public String toString() {
StringBuffer sb = new StringBuffer("Category[categoryId=");
sb.append(categoryId);
sb.append(", categoryName=");
sb.append(categoryName);
sb.append("]");
return sb.toString();
}
}
Hope that helps... I'm doing something a little more strange by using the
HashMap for a mapping, but it looked cool!
Steve
Ravi Manthena wrote:
>
> Not sure if this is clear but I wanted to keep it short:
> ----------------------------------------------------------------------
> Working : JSP Source
>
> <jsp:useBean id="wrapper" scope="page"
> class="com.arrow.util.StrutsUtil"/>
>
> <h3>Object[] OutPut</h3>
> <logic:iterate id="element" name="bean" collection="<%=
> wrapper.getDriver() %>" offset="0" length="5">
> <br><bean:write name="element"/>
> </logic:iterate>
>
> Question :
> How can we call a method on the instance of each ArrayObject
>
> Example :
> bean.getFirstName()
>
> Any Suggestions will be great.
>
> Ravi Manthena
> ravi@cafesoft.com
--
-----------------------------------------------------------------
Steven D. Wilkinson, stevendwilkinson@acm.org
Re: Not sure if this is clear but I wanted to keep it short:
Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Ravi Manthena wrote:
> Not sure if this is clear but I wanted to keep it short:
> ----------------------------------------------------------------------
> Working : JSP Source
>
> <jsp:useBean id="wrapper" scope="page"
> class="com.arrow.util.StrutsUtil"/>
>
> <h3>Object[] OutPut</h3>
> <logic:iterate id="element" name="bean" collection="<%=
> wrapper.getDriver() %>" offset="0" length="5">
> <br><bean:write name="element"/>
> </logic:iterate>
>
> Question :
> How can we call a method on the instance of each ArrayObject
>
> Example :
> bean.getFirstName()
>
How about:
<bean:write name="element" property="firstName"/>
?
>
> Any Suggestions will be great.
>
> Ravi Manthena
> ravi@cafesoft.com
Craig McClanahan