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

Populating ActionForm

 
Christian Spiteri
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I'm new to struts so excuse me if this seems like a simple question.
I have a search page (linked to an ActionForm) which returns a jsp with the search results. All the search results have a link, which points to an Action class, passing the id of the search result as a parameter. So far so good.
When I click on any search result, the Action gets the data from the database, populates the ActionForm and forwards to the jsp. It seems that the jsp is not finding the ActionForm data, so the page remains empty. What am I doing wrong?
Cheers,
Kris.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Christian !
Have you sent the ActionForm back to the jsp via setAttribute() ? Like this :

request.setAttribute(mapping.getAttribute(), yourForm);
// Forward to the appropriate View
return (mapping.findForward(target));
I hope it helps...
Cheers !
F�bio
 
Christian Spiteri
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help mate,
It worked fine.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My pleasure
F�bio
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic