wood burning stoves*
The moose likes Struts and the fly likes Map-backed ActionForm Key value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Map-backed ActionForm Key value" Watch "Map-backed ActionForm Key value" New topic
Author

Map-backed ActionForm Key value

Brian Boyle
Greenhorn

Joined: Nov 17, 2003
Posts: 13
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

Joined: Jan 24, 2004
Posts: 184
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


Srikanth Shenoy
Author of Struts Survival Guide : Basics to Best Practices
Brian Boyle
Greenhorn

Joined: Nov 17, 2003
Posts: 13
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Map-backed ActionForm Key value
 
Similar Threads
Struts 1 -- Wrong data displaying in my JSP page
Input Name Problem
Struts - Variable # of TextField in Form
Mapbacked forms
Problem while using Map in ActionForm