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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JSP expression not resolving correctly in <html:textarea> tag

Status
Not open for further replies.

vulcand4

Programmer
Jul 29, 2003
76
US
I have an iterate process set up to loop through the values in an ArrayList.

I then want the value of the loop index (specified by the "indexId" attribute) to be used to get an indexed parameter from my ActionForm.

Here's a snippet:
Code:
<logic:iterate id="field" name="Template0Form" property="questions" indexId="idx">
   <div id="q<%=idx+1%>" class="showMe">
      Question <%= idx+1 %>:<br/>
      <html:textarea style="margin-left:10px;" property="questionsIndexed[<%= idx %>]" rows="3" cols="50"></html:textarea>
   </div> 
</logic:iterate>

Here's the problem:

the "<html:textarea>" tag resolves before the jsp expression "<%= idx %>" which results in an error stating that I don't have a property in my ActionForm called "questionsIndexed[<%= idx %>]"

What I want is for the <%= idx %> to resolve to it's integer value before the <html:textarea> tag is resolved.

The two lines above the <html:textarea> tag have the <%= idx+1 %> resolve correctly.

Any Idea where I'm going wrong?
 
How is the the questionsIndexed defined in your ActionForm?

Code:
[blue]
String questionsIndexed[];  [green]//Like this?[/green]
[/blue]


-Ron

typedef map<GiantX,gold, less<std::shortestpathtogold> > AwesomeMap;
 
It's coded as
Code:
String [] questions;

public String[] getQuestionsIndexed(int index) {
   return questions[index];
}

The getter method matches the property field in the <html:textarea> tag. That is done so that I can change the underlying collection without having to change to contract with the JSP.

But the problem is not with the ActionForm, it is with the JSP not resolving the expression within the <%= %> tags at all.

It's as if the <html:textarea... tag is being handled first and that code takes "<%=...%> as a literal instead of a JSP expression.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top