[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

JSP Expression Problem

Posted on 2008-11-07
1
Medium Priority
?
317 Views
Last Modified: 2013-12-02
Hey all.

I am getting a very confusing problem in one of my jsps.
I need to loop through an Arraylist object, and display each object in a table on my page.
Two of the properties must be displayed in dropdown lists(html:select). These need to be accessable from javascript, as when you set the first one to a specific value, the second one must be set to disabled. Seeing as there could be any amount of them, I need to set the Ids as I iterate through the list, with an incrementing number, and the use the <%= %> tags to add it to the end. So the the id for the first html:select is styleId="select<%=i%>", where i is the int that increments. So the ids should be select1, select2, select3 etc... if im not mistaken... which I guess I must be. It is the same for the other select, styleId="hideEmail<%=i%>", and I call the javascript method like so: onchange="checkFields('<%=i%>')".
I tried displaying the value in an alert in the javascript, and it displays <%=i%> in the alert...
It should be showing 1. As far as i can see anyway...

Any assistance or insight would be greatly appreciated.

Thanks in advance.
<% int i=0;%>
<logic:iterate id="companyDetails" name="CompanyDetailsObj">
	<% if( i % 2 == 0) {%><tr class="even"><%}else{%>
	<tr><%} i++;%>
		<td>
		<html:select property="type" styleClass="" styleId="select<%=i%>" name="companyDetails" onchange="checkFields('<%=i%>')">
			<html:options collection="GetNumberTypeObj" property="optionValue" labelProperty="optionText"/>
		</html:select>
		</td>
		<td>
		<html:select property="country" styleClass="" styleId="hideEmail<%=i%>" 	name="companyDetails">
			<html:options collection="GetCountryObj" property="optionValue" labelProperty="optionText"/>
		</html:select>
		</td>
		<td><html:text name="companyDetails" property="number"/></td>
		<td><html:text name="companyDetails" property="defaults"/></td>
	</tr>
</logic:iterate>

Open in new window

0
Comment
Question by:jacoalb
1 Comment
 

Accepted Solution

by:
jacoalb earned 0 total points
ID: 22921659
Turns out struts gets confused by

styleId="hideEmail<%=i%>"

so

<% String selectId="select"+String.valueOf(i); %>
 styleId="<%= selectId %>"

is required.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question