Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help using indexed property in logic:equal tag 1

Status
Not open for further replies.

vulcand4

Programmer
Jul 29, 2003
76
0
0
US
I am trying to use a "logic:equal" tag in my jsp.
Code:
<logic:equal value="" name="SimpleListSettingsForm" property="totalsIndexed[?]" scope="request">

If I put a hardcoded value in the index (denoted by the "?") it works fine, but I have this code in a loop (logic:iterate)and the index needs to change with each iteration.

My logic:iterate tag specifies a field named "idx" as the index for iteration.

I've used <%= idx.intValue() %>, <%= idx %>, and ${idx} as my indexes for the logic:equal tag, but all of them give me the following:

java.lang.IllegalArgumentException: Invalid indexed property 'totalsIndexed...

Any ideas?

 
Found the answer at: [URL unfurl="true"]http://struts.apache.org/1.x/struts-taglib/indexedprops.html[/url]

The part I used is below:
Dynamic Indexes for Indexed Properties

People often start using indexed properties with enthusiasm, but soon become frustrated by an inconvenient reality. The reality is that the "index" for indexed properties often needs to be a dynamic value, usually from the "indexId" counter in the "<logic:iterate>" tag.

For instance, the following example JSP page using the same "StringBean" bean class uses a dynamic value for the index:

<!-- indexedtest5.jsp -->
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"
%>
<%@ taglib uri="/WEB-INF/struts-logic.tld"
prefix="logic" %>
<html>
<body>
<html:form action="indexedtest5.do">
<logic:iterate name="stringbean" property="stringArray"
id="foo"
indexId="ctr">
<html:text name="stringbean"
property='<%= "labelValue[" + ctr + "].label" %>' />
</logic:iterate>
<html:submit property="submitValue">Submit Changes</html:submit>
</html:form>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top