Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Map-backed ActionForm Key value

 
Brian Boyle
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,
I am using a map-backed ActionForm and so in my JSP code I have a <html:text> tag that looks like this:
<html:text property="value(<%=value.getUserId()%> " readonly="true" size="2" />
The reason I have a scriplet in there is because I have a dynamic form and the value of the key changes all the time. I want the value of the key to be the "id" of the user logged in.
However, this is giving me problems because the value of the key is being taken literally as <%=value.getUserId()%> rather than the value of the userId. The scriplet <%= value.getUserId %> is correct because I have tested it with System.out.println(value.getUserId). So it looks like I cannot put my scriplet in there. Has anyone experienced this before? Or does anyone know why it won't et me do this? Any way to get around this?
I'd appreciate any help. I've been stuck on it for two days now.
Cheers,
B
[ March 07, 2004: Message edited by: Brian Boyle ]
 
Srikanth Shenoy
author
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must be using Tomcat.
Tomcat and many other JSP parsers cannot interpret what you are trying to do !!!
This should work:
<html:text property='<%= "value(" + value.userId + ")" %>' readonly="true" size="2" />
Srikanth Shenoy
Author: Struts Survival Guide - Basics to Best Practices
 
Brian Boyle
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi thanks for your reply. I am using Tomcat! I had already tried thee method you suggested but that didn't work either . However I got an answer from the Struts mailing list.This is what I did and it worked!
<% String propertyName = "value(" + myId + ")"; %>
<html:text title="myinput" property="<%=propertyName%>" readonly="true" size="2" />
Thanks,
B
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic