You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sean Gollschewsky <se...@ispw.com> on 2001/09/14 10:42:08 UTC

Using indexes in tags

Hi all,

I'm relatively new to struts, but I've managed to get a simple
application going.  I am passing an 'index' request parameter to a
simple jsp

<H3> View a Task </H3><BR>
	<bean:parameter id="index" name="index"/>
	<% int ind = Integer.parseInt(request.getParameter("index")); %>

	Summary: <%= tasks.getTask(ind).getSummary() %>
	<BR>	
	OpenDate: <%= tasks.getTask(ind).getOpenDate() %>
	<BR>
	TargetDate: <%= tasks.getTask(ind).getTargetDate() %>
	<BR>
	Description: <%= tasks.getTask(ind).getDescription() %>

This works fine.  But what I wanted to be able to do was something like

Summary: <bean:write name="tasks" property="task[ind].summary"/>

This fails with a complaint 

Error Message: Invalid indexed property 'task[ind]'
Error Code: 500
Target Servlet: null
Error Stack: 
java.lang.IllegalArgumentException: Invalid indexed property 'task[ind]'


Is there a nice way to use struts tags to do this, rather than the ugly
scriptlets?  Or is there a totally different way to achieve this same
result that is more struts friendly?

Thanks,

Gollo.