• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts passing data across tiles

 
chris hart
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am using struts with tiles. I have a JSP page and a layout which consists of a header, body and footer. The body is where the user enters some info. The footer contains the submit button. Clicking the submit button is only submitting the footer data and not the body data. How do I submit data from a specified tile or multiple tiles inorder for my FormAction class to see it. Thanks for any help.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Definitely more appropriate for the Struts forum. Moving this there.
bear
 
Junilu Lacar
Bartender
Pie
Posts: 7747
60
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is your html:form tag/endtag located? It would have to be in the layout.jsp that has all your tiles:insert tags. That way, your submit button would be in the same form as the fields it is submitting when the tiles are assembled.
layout.JSP:
<tiles:insert header>
<html:form>
<tiles:insert body>
<tiles:insert footer>
</html:form>

body JSP:
<html:text>
....

footer JSP:
<html:submit>
 
chris hart
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you very much Junilu. I guess I was tring to keep the layout completly generic (with out an knowledge of fields). However using your method the values do get submitted. Thanks again.
 
Junilu Lacar
Bartender
Pie
Posts: 7747
60
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can make the layout more generic.
We do this in our layout:
<%@page import="org.apache.struts.action.ActionMapping" %>
<%
ActionMapping actionMapping = (ActionMapping) request.getAttribute( Action.MAPPING_KEY);
%>
<html:form action="<%= actionMapping.getPath() %>" >
...
</html:form>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic