February 2005
Intermediate to advanced
528 pages
12h 53m
English
You need to reference an Action or JSP page from within one frame to another.
Use the Struts
html:frame
tag to create frame elements with the proper URLs for your Struts
application, as in Example 3-20
(frame_test.jsp).
Example 3-20. Generating a frame set with Struts
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<frameset cols="50%,*">
<html:frame frameName="_frame1"
page="/frame1.jsp"
marginwidth="10"
marginheight="10"
scrolling="auto"
frameborder="1"/>
<html:frame frameName="_frame2"
page="/frame2.jsp"
marginwidth="10"
marginheight="10"
scrolling="auto"
frameborder="1"/>
</frameset>Within the individual frame's source JSP, use the
target attribute on the
html:link and
html:form
tags to refer to the other frame.
The JSP in Example 3-21
(frame1.jsp) demonstrates this approach.
Example 3-21. Frame with link to other frame
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<html>
<head>
<title>Struts Cookbook - Chapter 04: Frame Test</title>
</head>
<body bgcolor="white">
<h2>Frame 1</h2>
<html:link href="frame2.jsp?calledBy=FRAME_1" target="_frame2">
Call Frame2
</html:link>
<p>
Message received:
<c:out value="${FrameForm.map.message}"/>
</body>
</html>Likewise, frame2.jsp shown in Example ...