Recently, I came across the problem of trying to maintain the frame sizes
as the user likes it in a frameset. The problem stems from the fact that
the relative sizes of the frames in a frameset is hardcoded in a ND
frameset.
For clarity, let me give you a concrete example. Suppose you have a frameset
called frFrameTest that is composed of two frames - frLeft and frRight.
The sizes of the two columns are hardcoded to "50%,50%" in frFrameTest.
If you perform any action that needs to update both the left and right
frames, one would load the whole frameset to reflect the changes. However,
it would go back to "50%,50%" and wiped out any resizing the user has done.
After talking to tech support, the conclusion seems to be that the ND
frameset is not very user friendly in terms of changing the relative
sizes of its frames. Instead, it's easier to work with a HTML page that
sports the frameset tags.
I thought I would share with you my solution, and I welcome suggestions
for improvements or thougts on a totally different solution altogether.
First, I use a ND html page to house the frameset. Let's called this page
"frFrameTest". I have three Static Text fields, two for storing the widths
of the left and right frames and one for storing the session info (we need
to tack on the session info ourself on the pages in the frames since we are not
using ND's frameset.)
--------------------- frFrameTest file -------------------------------------
<HTML>
<HEAD>
<TITLE>frFrameTest </TITLE>
[[SPIDERPAGE NAME=frFrameTest]]
<script>
// this is necessary for MSIE since it did not support dynamic frame targeting
if (parent!=window) {
top.location="frFrameTest?**stSessionInfo**";
}
</script>
</HEAD>
<!-- default value below is 50% each -->
<FRAMESET COLS="**stLeftX**,**stRightX**">
<FRAME name="frLeft" src="pgLeft?**stSessionInfo**">
<FRAME name="frRight" src="pgRight?**stSessionInfo**">
</FRAMESET>
<BR>
**SPIDERSESSION**
[[/SPIDERPAGE]]
</HTML>
--------------------- frFrameTest file -------------------------------------
Next, I use javascript to spit back the new frame widths when they are resized
and pass these values back to ND, so they can be stored in user session vars.
After that, the frameset is reloaded.
--------------------- frLeft file -------------------------------------
<HTML>
<HEAD>
<TITLE>pgLeft</TITLE>
<script>
// determine the type of browser; assume Netscape 4 or MSIE 4 or better
if (document.layers) {
isNav4 = true;
isIE4 = false;
}
else if (document.all) {
isNav4 = false;
isIE4 = true;
}
function sendToServer() {
if (isNav4) {
window.document.pgLeft2.left_x.value = window.innerWidth;
window.document.pgLeft2.right_x.value
=
parent.frRight.window.innerWidth;
}
else if (isIE4) {
window.document.pgLeft2.left_x.value =
window.document.body.clientWidth;
window.document.pgLeft2.right_x.value =
parent.frRight.window.document.body.clientWidth;
}
document.pgLeft2.submit();
return;
}
</script>
</HEAD>
[[SPIDERPAGE NAME=pgLeft]]
<body onResize="sendToServer()">
<font size=+3>Left</font>
<BR>**hrRight**
**SPIDERSESSION**
</form>
<!-- The normal ND form is actually split into two, so resizing won't
affect normal operations -->
<FORM NAME="pgLeft2" METHOD=POST ACTION="pgLeft">
<input type=hidden name="left_x" value="0">
<input type=hidden name="right_x" value="0">
<!-- In ND, a Submit button is added. However, it is commented out because
we want the onWebEvent handler to be triggered when frames are
resized, but we don't want to see the associated button. Instead,
we add a hidden input tag that has the same name as the actual
submit button so it will trigger Submit_onWebEvent when this
form is submitted. -->
<input type=hidden name="Submit_onWebEvent(Submit)" value="submit">
<!--
**Submit**
-->
**SPIDERSESSION**
[[/SPIDERPAGE]]
</BODY>
</HTML>
--------------------- frLeft file -------------------------------------
Some notes on the implementation. As you can see from the above HTML file,
we break the normal ND form into two, so normal ND operations won't be
affected by the resize action. For example, there is a href link called
**hrRight** that changes the right frame page when clicked. Most normal
operations would trigger the first form while only resize action triggers the
second. Here, we use two hidden vars to pass the frame widths info. Plus,
we trick the ND into processing the onWebEvent handler with a hidden input
tag that shares the submit's name.
For completeness, let me give you the code for the relevant event handlers:
--------------------- in frLeft.java file -------------------------------------
public int Submit_onWebEvent(CSpWebEvent event) {
int left_x = CSpider.getWebVar("left_x").intValue();
int right_x = CSpider.getWebVar("right_x").intValue();
CSpider.putUserSessionObject("usLeftX",new CSpInteger(left_x));
CSpider.putUserSessionObject("usRightX",new CSpInteger(right_x));
CSpPage nextPage = (CSpPage) CSpider.getPage("frFrameTest");
// Netscape supports Dynamic Frame targeting so does not need
// the javascript hack on top of the frFrameTest page
if (CSpider.getBrowserCapabilities().isDynamicFramesTargeting()) {
nextPage.sendWindowTargetHttpHeaderIfNeeded("_top",
CSpHtmlFrame.TOP_FRAME_TARGET_TYPE);
}
nextPage.load();
return(STOP);
}
--------------------- in frLeft.java file -------------------------------------
--------------------- in frFrameTest.java file --------------------------------
public int stRightX_onBeforeDisplayEvent(CSpDisplayEvent event) {
CSpStaticText text = (CSpStaticText) event.getSource();
text.setValue(CSpider.getUserSessionObject("usRightX"));
return (PROCEED);
}
public int stLeftX_onBeforeDisplayEvent(CSpDisplayEvent event) {
CSpStaticText text = (CSpStaticText) event.getSource();
text.setValue(CSpider.getUserSessionObject("usLeftX"));
return (PROCEED);
}
public int stSessionInfo_onBeforeDisplayEvent(CSpDisplayEvent event) {
CSpStaticText text = (CSpStaticText) event.getSource();
text.setValue(getPageSessionNvp().getNvp());
return (PROCEED);
}
--------------------- in frFrameTest.java file --------------------------------
Try it out and let me know what you think of it.
Leon Poon
_________________________________________________________________________
For help in using, subscribing, and unsubscribing to the discussion
forums, please go to: http://www.netdynamics.com/support/visitdevfor.html
For dire need help, email: [EMAIL PROTECTED]