File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts passing data across tiles Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts passing data across tiles" Watch "Struts passing data across tiles" New topic
Author

Struts passing data across tiles

chris hart
Greenhorn

Joined: Oct 09, 2003
Posts: 9
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

Joined: Jan 10, 2002
Posts: 60748
    
  65

Definitely more appropriate for the Struts forum. Moving this there.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4442
    
    5

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>


Junilu - [How to Ask Questions] [How to Answer Questions]
chris hart
Greenhorn

Joined: Oct 09, 2003
Posts: 9
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

Joined: Feb 26, 2001
Posts: 4442
    
    5

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>
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts passing data across tiles
 
Similar Threads
Null error in "Menu" Tile
Struts1.3 tiles problem
Struts 2+ Tiles 2
Tiles winding me up.
tiles problem