myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gerhard Petracek <gerhard.petra...@gmail.com>
Subject Re: [CODI] lazy windowId drop script
Date Thu, 19 May 2011 10:08:04 GMT
hi mark,

we should prototype the window-id feature [1] for jsf 2.2 - there we have to
think about such topics.
afterwards we can backport it and it's easy to provide a special codi
WindowHandler for using this window-id provided by jsf 2.2 (or myfaces-core
2.1.x) instead of using the internal window-id.

regards,
gerhard

[1] http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-949

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces



2011/5/19 Mark Struberg <struberg@yahoo.de>

> Hi!
>
> In my project I'm using a small JavaScript which I use to lazily drop the
> windowId if I detect a new window (by checking for an empty window.name).
> This of course also has a few side effects, but works well for almost all
> use cases.
>
> Since CODI is not a component library, we cannot ship this easily.
> What is the best way to provide this script to the community?
> It's really just quick hack which could/should be improved by the community
> since I'm a javascript gimp. Just attach it to our CODI Wiki and explain how
> to use it?
>
> Here's what I have so far:
>
> The javascript file (resources/js/windowId.js)
> -------------------------------------------
> function urlWithoutWindowId(base) {
>    var query = base;
>    var vars = query.split(/&|\?/g);
>    var newQuery = "";
>    var iParam = 0;
>    for (var i=0; vars != null && i < vars.length; i++) {
>        var pair = vars[i].split("=");
>        if (pair.length == 1) {
>            newQuery = pair[0];
>        }
>        else {
>            if (pair[0] != "windowId") {
>                var amp = iParam++ > 0 ? "&" : "?";
>                newQuery =  newQuery + amp + pair[0] + "=" + pair[1];
>            }
>        }
>    }
>    return newQuery;
> }
>
> function assertWindowId() {
>    var freshWindow = window.name.length < 1;
>    if (freshWindow) {
>        url = urlWithoutWindowId(window.location.href);
>        window.name = "window";
>        window.location = url;
>    }
> }
> -------------------------------------------
>
> In my layout.xhmtl facelet I use the following :
>
> -------------------------------------------
> <f:view locale="#{settings.locale}">
>    <h:outputScript name="windowId.js" library="js"/>
>    <script type="text/javascript">
>        assertWindowId()
>    </script>
> ...
> -------------------------------------------
>
> which just reloads the window without the windowId= parameter, thus forcing
> a new windowId from the system.
>
> Just add this to the wiki or can we deliver this script somehow as part of
> CODi?
>
> LieGrue,
> strub
>

Mime
View raw message