File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to fetch value from ActionForm given a parameter...

 
frank wa
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey All,

I looked through the faqs but i'm not sure if my question is answered in the faqs. I don't believe it is.

Basically... I have a form extending ActionForm and sent back to a jsp page. seems simple already ;-P

in my controller i do a (for example) form.setDetails( object1 );
object1 is a Map<String, String>

in the action form i also have a

getDetail( String key ) {
return thisDetailMap.get(key);
}

I would like to know how i can pass the parameter in and get the value back... all in the jsp page....

So in the page i'd have something like: {$form.detail('HELLO')} and it would return the value for the key "HELLO"

In my page i'm displaying keys using a forEach loop... but for each key i find, i want to fetch speific details for it... ie: title information or whatnot...

I know i'm close, i just can't seem to get it...

Thanks guys!
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the Heading "Mapped Properties" in this link.
 
frank wa
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello :-)

Thanks for the quick reply.

I had tried this and it doesn't seem to work. This is what my code looks like:

ApplicationForm extends ActionForm
private Map<String, String> appDetailedInfo;
public Object getDetails( String key ) {
return appDetailedInfo.get(key);
}

JSP:
<bean:write name="ApplicationForm" scope="request" property="details(1024_REGION)"/>

I even tried:

<jsp:useBean id="bean" scope="request" class="com.app.ApplicationForm">
<bean:write name="bean" property="details(1024_REGION)"/>
</jsp:useBean>

I keep getting this error:

javax.servlet.jsp.JspException: No getter method for property: "details(1024_REGION)" of bean: "bean"
at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:915)
at org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:234)

Any idea why? :-/
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code looks OK. I don't know what to tell you but that I know this works. I even wrote a small application to test it, and got the results I expected. I'll post my code, and maybe you can figure out what you're doing differently.

Action Form:


struts-config.xml:



jsp:

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic