You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Wilko Hische <w....@dotmachine.nl> on 2007/08/26 20:34:48 UTC

Dynamically created popup window, IE7 & wicket 1.3

Hi,

For a chat application I would like to display a list of chat requests that
have come in.
This list is updated by making use of an AbstractAjaxTimerBehavior.

When the user clicks a chat request in the list, a popup window will open
containing that particular chat conversation. In FF all works fine.

The unfortunate thing is that whatever I try, in IE7, the window containing
the list will become the active window whenever the timer fires, thus hiding
the popup window.

Even more strange:

- If the popup was started from a static (ie non dynamically updated)
element the popup doesn't lose focus.

- In wicket 1.2.6 it works fine.

I have been trying various approaches, for instance my own little Java
script creating the popup links, but for some reason I just can't get it to
work. I am willing to accept that is another IE7 "feature" , but that
doesn't help me much.

I am not really comfortable with Javascript, so before I dive into the
Javascript differences between Wicket version 1.2.6 and 1.3.x I would like
to ask whether somebody on this list might have some suggestions.

I have attached the Index.html and Index.java for the current 1.3 snapshot.
In 1.2.6 it works (mutatis mutandis).

Regards,

Wilko Hische



----- org.apache.wicket.quickstart.Index.java
----------------------------------------

package org.apache.wicket.quickstart;

import java.util.Date;

import org.apache.wicket.PageParameters;
import org.apache.wicket.ajax.AbstractAjaxTimerBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.util.time.Duration;

/**
 * Basic bookmarkable index page.
 * 
 * NOTE: You can get session properties from QuickStartSession via
 * getQuickStartSession()
 */
public class Index extends QuickStartPage {

	/**
	 * Constructor that is invoked when page is invoked without a session.
	 * 
	 * @param parameters
	 *            Page parameters
	 */
	public Index(final PageParameters parameters)
	{
		WebMarkupContainer timer = new WebMarkupContainer("timer");
		timer.setOutputMarkupId(true);
		
		final Label timeLabel = new Label( "time", new AbstractReadOnlyModel(){
			public Object getObject() {
				return new Date().toString();
			}
		});
		timeLabel.setOutputMarkupId(true);
		timer.add(timeLabel );
		timer.add(
				new AbstractAjaxTimerBehavior(Duration.seconds(2)) {
					protected void onTimer(AjaxRequestTarget target) {
						target.addComponent(timeLabel);
						target.appendJavascript( "addPopupLinkIfNotExists()");
					}					
				}			
		);
		add( timer );
	}
}


----- org.apache.wicket.quickstart.Index.html
----------------------------------------

<html>
<head>
    <title>QuickStart</title>
<script type="text/javascript">	
	function openPopup(e) {
		window.open( 'http://wicket.apache.org' );
	}
	
	function addPopupLinkIfNotExists() {
		var e = document.getElementById( 'popup' );
		if (e != null) {
			return;
		}
		var parent = document.getElementById( 'links' );
		var link = document.createElement('a');
		link.setAttribute( 'id', 'popup' );
		link.setAttribute( 'href', '#' );
		if (link.addEventListener){
			link.addEventListener('click', openPopup, false);
		}
		else {
			link.attachEvent('onclick', openPopup );
		}
		link.appendChild(document.createTextNode("Dynamic popup"));
		parent.appendChild( link );	
		
	}
	
</script>
</head>
<body>
        <h1>QuickStart</h1>
        <p wicket:id="timer">Last refresh: </p>
				<p>
					 # A stable link 
				</p>
				<p id="links">
					
				</p>
</body>
</html>




-- 
View this message in context: http://www.nabble.com/Dynamically-created-popup-window%2C-IE7---wicket-1.3-tf4331823.html#a12337162
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org