Re: JSModalWindow Close and Refresh Question
Re: JSModalWindow Close and Refresh Question
- Subject: Re: JSModalWindow Close and Refresh Question
- From: Jonathan Rochkind <email@hidden>
- Date: Wed, 31 Mar 2004 12:39:09 -0600
At 12:18 PM -0600 3/31/04, James Cicenia wrote:
Jonathan! I am almost there... 2/3rd there to be precise because
your trick worked great with the following code:
<SCRIPT
LANGUAGE=Javascript>window.opener.location.reload(1);self.close();return
false;</SCRIPT>
HOWEVER..... JSModalWindow won't popup in Internet Explorer???!!!!!
It does in Safari and Firefox/Netscape...
Any thoughts master?
-James Cicenia
You'd have to debug what Javascript JSModalWindow is providing, and
why that javascript doesn't work in Safari. We do get the source to
JSModalWindow since it's in WOExtensions, so you could change the
code as neccesary, once we figure out what will work in Safari.
[PS: The "return false;" probably doesn't do anything at all when
used in that context.]
I have my own custom JSModalWindow, where I changed the way it worked
a bit, and also added some additonal functionality of my own. Based
on the code Apple gives us for JSModalWindow. I forget exactly what
I changed, and I don't know if it will work better for you, but I'll
include it below (which might make the message too long to get to the
list, but it'll still get to James. If anyone else is seeing this,
then it got to the list).
====
JSModalWindowFixed.java
====
/* This JSModalWindow has several bugs in WO5 I got the source, provided in
/Apple/Developer/Examples/JavaWebObjects/Source/JavaWOExtensions
and provided fixes to it, some suggested by jeff gedeon email@hidden.
Also added some features, including:
* fixed javascript 'opener' to work in new window, regardless of browser.
* added jsFormSubmitName binding, to give the name of a form that should be
submitted, using javascript, when link is clicked.
* added a 'disabled' binding, that functions like WOHyperlink's. If
disabled is true, then only the content is displayed, with no
wrapping hyperlink to open up a new window at all.
Jonathan Rochkind, email@hidden Sep 6 2001 */
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Portions Copyright (c) 2000 Apple Computer, Inc. All Rights
* Reserved. This file contains Original Code and/or Modifications of
* Original Code as defined in and that are subject to the Apple Public
* Source License Version 1.1 (the "License"). You may not use this file
* except in compliance with the License. Please obtain a copy of the
* License at http://www.apple.com/publicsource and read it before using
* this file.
*
* The Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
package com.webobjects.woextensions;
import com.webobjects.appserver.*;
import com.webobjects.foundation.*;
public class JSModalWindowFixed extends JSComponent {
public Boolean disabled;
public JSModalWindowFixed(WOContext aContext) {
super(aContext);
}
public void appendToResponse(WOResponse r, WOContext c) {
disabled = (Boolean) valueForBinding("disabled");
super.appendToResponse(r, c);
}
public String contextComponentActionURL(){
// Return the javascript function to the HREF, getting the
URL for the action
// from the invokeAction setting in the context
//return
"javascript:open('"+context().componentActionURL()+"','"+valueForBinding("windowName")+"','');
return true";
String returnString = "aWindow = window.open('"+
context().componentActionURL()+
"','"+
valueForBinding("windowName")+
"','" + windowInfo()+"');";
returnString += "if (aWindow.opener == null) aWindow.opener = self; ";
if (booleanValueForBinding("bringToFront"))
returnString += " aWindow.focus(); ";
String formName = (String)valueForBinding("jsFormSubmitName");
if (formName != null) {
returnString += " document." + formName + ".submit(); ";
}
returnString += " return false;";
return returnString;
}
public String windowInfo() {
// Generate the javascript window details
/*return "toolbar="+((null!=valueForBinding("showToolbar")) ?
"yes" : "no")+
",location="+((null!=valueForBinding("showLocation")) ? "yes" : "no")+
",status="+((null!=valueForBinding("showStatus")) ? "yes" : "no")+
",menubar="+((null!=valueForBinding("showMenubar")) ? "yes" : "no")+
",resizable="+((null!=valueForBinding("isResizable")) ? "yes" : "no")+
",scrollbars="+((null!=valueForBinding("showScrollbars")) ?
"yes" : "no")+
",width="+valueForBinding("width")+
",height="+valueForBinding("height");*/
return "toolbar="+(booleanValueForBinding("showToolbar") ?
"yes" : "no")+
",location="+(booleanValueForBinding("showLocation") ? "yes" : "no")+
",status="+(booleanValueForBinding("showStatus") ? "yes" : "no")+
",menubar="+(booleanValueForBinding("showMenubar") ? "yes" : "no")+
",resizable="+(booleanValueForBinding("isResizable") ? "yes" : "no")+
",scrollbars="+(booleanValueForBinding("showScrollbars") ?
"yes" : "no")+
",width="+valueForBinding("width")+
",height="+valueForBinding("height");
}
public boolean disabled() {
if ( disabled == null ) {
//default to false, naturally.
return false;
}
else {
return disabled.booleanValue();
}
}
public boolean booleanValueForBinding(String key) {
Boolean value = (Boolean) valueForBinding(key);
if (value == null)
return false;
else
return value.booleanValue();
}
}
====
JSModalWindowFixed.html
====
<WEBOBJECT NAME=Conditional1><WEBOBJECT
NAME=HyperlinkContainer><WEBOBJECT
NAME=Content></WEBOBJECT></WEBOBJECT></WEBOBJECT><WEBOBJECT
NAME=Conditional2><WEBOBJECT NAME=Content2></WEBOBJECT></WEBOBJECT>
====
JSModalWindowFixed.wod
====
Conditional1: WOConditional {
condition = disabled;
negate = true;
}
Conditional2: WOConditional {
condition = disabled;
}
Content: WOComponentContent {
}
Content2: WOComponentContent {
}
HyperlinkContainer: WOGenericContainer {
elementName = "A";
href="javascript: void 0;"; //contextComponentActionURL;
onClick = contextComponentActionURL;
invokeAction = invokeAction;
}
====
JSModalWindowFixed.api
====
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<wodefinitions>
<wo class="JSModalWindowFixed" wocomponentcontent="true">
<binding name="action" defaults="Actions"/>
<binding name="height"/>
<binding name="isResizable" defaults="Boolean"/>
<binding name="showLocation" defaults="Boolean"/>
<binding name="showMenubar" defaults="Boolean"/>
<binding name="showScrollbars" defaults="Boolean"/>
<binding name="showStatus" defaults="Boolean"/>
<binding name="showToolbar" defaults="Boolean"/>
<binding name="width"/>
<binding name="windowName"/>
<binding name="pageName" defaults="Page Names"/>
<binding name="bringToFront" defaults="Boolean"/>
<binding name="jsFormSubmitName"/>
<binding name="disabled" defaults="Boolean"/>
<validation message="'windowName' is a
required binding">
<unbound name="windowName"/>
</validation>
<validation message="'width' is a required binding">
<unbound name="width"/>
</validation>
<validation message="'height' is a required binding">
<unbound name="height"/>
</validation>
<validation message="'action' or
'pageName' must be bound">
<and>
<unbound name="action"/>
<unbound name="pageName"/>
</and>
</validation>
</wo>
</wodefinitions>
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.