All,

I've got this simple use case:

On compose e-mail page click on some button that shows list of users
in modal window and after user chooses the the user(s), the modal
window closes and compose page updated with the address of choosen
user. Here is the simple html test case:

--compose.html
<html>
<head>
<script>
var UserListRef = null;
function ListUsers()
{
        if(window.showModalDialog) //IE
        {
                window.showModalDialog("listusers.html", document, 
"dialogHeight: 120px; dialogWidth: 400px; help: no; status: no")
                return false;
        }
        else //FF, did not test other browsers due to lack of those
        {
            if(UserListRef == null || UserListRef.closed)
                UserListRef = window.open("listusers.html", document, 
"height=120px, width=400px, help=no, status=no, dialog=yes, modal=yes");
            else
                UserListRef.focus();
        }
}
</script>
</head>

<body>
        <input  id="to_user" type="text" name="touser" title="email" value="" >
        <input type="button" value="..." title="User list" onclick="return 
ListUsers()">
</body>
</html>

--listusers.html
<html>
<script>
</script>
<script language="javascript">
function Close()
{
    if(window.showModalDialog) //IE
    {
        n = dialogArguments.getElementById("to_user");
        n.value = document.getElementById("user").value;
        window.close();
    }
    else //FF
    {
        var o = window.opener.document.getElementById(("to_user"));
        o.value = document.getElementById("user").value;
        window.close();
    }
}
</script>

<body>
        <select id="user">
                <option value="[EMAIL PROTECTED]">
                    user1
                </option>
                <option value="[EMAIL PROTECTED]">
                    user2
                </option>
        </select>
        <input type="button" value="OK" onclick="Close()">
</body>
</html>


Now, with static html files it works as expected, i.e., on "..."
button click we have modal window with list of users.

jsp page with struts action works as expected, too.

I'm having trouble with porting this code into wicket. For the first
time when one clicks the "..." button, modal dialog comes up. For the
following clicks, IE opens up both a new window and the modal dialog
with the same contents.
With FF it works as expected.

I suspect, it has something to do with pagemaps or versioning, but how
could I know, I'm new to wicket world. Please, help me.

Here are relevant wicket code:

--Compose
public class Compose extends MyAuthenticatedPage {
    public Compose() {
        add(new Label("message", "here we will compose a new message"));
        PopupSettings popupSettings = new 
MyPopupSettings(PageMap.forName("popup")).
                        setHeight(500).setWidth(500);
        Link listUsers = new PageLink("listUsers", ListUsers.class);
        listUsers.setPopupSettings(popupSettings);
        add(listUsers);
    }
}
--ListUsers
public class ListUsers extends WebPage {
        public ListUsers() {
        }
}
--MyPopupSettings
public class MyPopupSettings  extends PopupSettings {
... same as in PopupSettings except the following
    public String getPopupJavaScript()
    {
        String windowTitle = windowName;

        if (windowTitle == null)
        {
            windowTitle = "";
        }
        else
        {
            // Fix for IE bug.
            windowTitle = windowTitle.replace(':', '_');
        }

        StringBuffer script =
                new StringBuffer("if(window.showModalDialog) { 
window.showModalDialog(");
        script.append(target).append(", document, ");

        script.append("'dialogHeight:120px; dialogWidth:400px; help:no; 
status:no'); ").append(" return false; }");

        script.append(" else { if(UserListRef == null || UserListRef.closed) 
UserListRef = window.open(");
        script.append(target).append(", document, ");
        script.append("'height=120px, width=400px, help=no, status=no, 
dialog=yes, modal=yes'");
        script.append("); ").append(" else UserListRef.focus();}");
        return script.toString();
    }

}

BTW, in order to make a different javascript code I copy-pasted entire
content of PopupSettings and made a new getPopupSettings function. Is
there other way around?

Thank you.

Regards,
shumbola


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to