[Zope] framed menu refresh?!?

Thomas B. Passin tpassin@mitretek.org
Mon, 13 May 2002 16:37:43 -0400


[Mark A. Robinson]

Ok I have 2 frames in my app. Left frame is my tree'd menu with some
status info, too. Right frame is my data input side. User navigates with
left frame, and it anchors the appropriate page over in the right frame.
Now, here's the problem: if on the right the user selects something that
affects the status of the app, how can I refresh the left frame so that
it will display the change in status?

[Tom P]
It depends what you mean by "refresh the left frame" -

1) Change some displayed value without reloading the frame.
In this case, you have to notify the left frame using javascript executed in
the right frame.  You also have to figure out how you will show the update,
and you have to handle an error condition in case the left frame isn't there
any more or is not ready to handle the instruction.  You also have to decide
how many different browsers to support (in otherwords, how plain vanilla
your javascript will be).

Your code might look like this:

// In the right frame, when the event occurs
parent['left_frame'].update_selection('new_value')

// In head element of the left frame
// Display  the new value in an input element in the left frame
function update_selection(new_value){
    document.form1.input1.value=new_value
}

2)  You reload the left frame from the server.
In this case, you probably will want to send some data to the server so it
knows what to display when the left frame reloads.

To reload the left frame:

// In the right frame
parent['left_frame'].location.replace('the_left_page.html?newselection=new_v
alue')

This replaces the frame without adding to the history list, which is usually
want for reloading frames.

In the Zope page for the left frame, you look for "newselection" in the
REQUEST and do the appropriate thing with it.  Note that you have to handle
the case where "newselection" is missing so that the page can open
successfully the first time, when it will not receive any parameter.

Of course, you can use as many parameters as you like.

These basic methods are completely browser-neutral except that javascript
has to be enabled.  If you do not want that, you will have to modify 2) to
reload the frameset instead of the left frame, and process the passed form
data in the frameset instead of the left frame.

Method 1) avoids a roundtrip to the server and is fast, therefore desirable
for the user.

Cheers,

Tom P