@Thomas, AYE!  Your example does work best, provided users don't Ctrl
+Click to open in a new Window.

My iframe example was certainly incomplete.  I leave the History
tokens alone {don't inject directional "do not fire" tokens}, until
the user clicks the close button or opens a new link.  THEN, if the
user clicks close {but not open} I add the extra tokens to change the
hash, because #Links won't refire if they are the same.  I used
multiple tokens and internal booleans to record which direction the
user is navigating through history, as well as a static String to make
sure nothing gets opened twice. The user can go ahead and click on it
again to re-open it, or click back/forward to close the current iframe
and open the next/prev target.  If I just insert a single "do nothing"
token, the user has to press back or forward twice to use their
history.   {and I have no way of knowing whether the user has pressed
back or forward unless I use the two token method}.

Problem is, I want to programmatically remove the iframe container
when the user closes it, AND when the user clicks on another valid
link...  I'll just copy n paste...


        private boolean xManual = true,xAuto=false;//Tricky variable for
history magic
        private String xCurHist="";//Records the current history position
        public void onValueChange(ValueChangeEvent<String> event) {//Whenever
it changes
                xCurHist=event.getValue();//Get the current #Token

                if (xCurHist.length()>3){//If that value is longer than three
characters,
                        xLocus.xNotify(xCurHist);//Send notification to any 
listeners {that
build widgets}. This is where iframe is build and added
                        xAuto=false;//Remember that the user caused this action
                }
                else if (xCurHist.equals(xNS.xGO_BACKWARD)&&xManual){//If we are
programaticaly changing history
                        xManual=false;//Reset from manual to auto
                        xAuto=true;//ditto
                        History.back();//Go back once, to the GO_FORWARD item
                        History.back();//Go back AGAIN, to the actual previous 
history item
                        xManual=true;//Change back to auto
                        //This is called because I add extra history tokens, * 
and . to
note user's history direction
                }
                else if (xCurHist.equals(xNS.xGO_FORWARD)&&xManual){//If the 
user
has pressed forward, and there is a GO_FORWARD token
                        xManual=false;//Set to manual
                        xAuto=true;
                        History.forward();//Skip the go back token
                        History.forward();//Go to the actual history item
                        xManual=true;//Back to auto
                }

        }



AND the onUnload of a static Panel called xPop, where the iframe is
added and displayed...  It is removed when the user clicks close or
opens a new link...

protected void onUnload() {//When Widget's removed
try{//Attempt the following; it might fail
                final String xCur = History.getToken();//Get the current history
        if (!xAuto)//If we're on manual settings
        new Timer(){//Hack used in case this widget was detached by clicking
a valid token
        @Override
        public void run() {
                try{
                        if(xPop.isAttached())//xPop is iframe container 
element. If a new
panel is made and attached, a valid token was clicked, and we don't
need the hack
                                return;//Stop, or else we break the history
                if (xCur.length()>0&&xCur.equals(History.getToken())){//If we're
still on a history token
                                History.newItem(xNS.xGO_FORWARD,false);//Insert 
a GO_FORWARD
marker
                                History.newItem(xNS.xGO_BACKWARD,false);//Then 
a GO_BACKWARD.
                                //This is how we tell if the user pressed back 
or forward in the
browser
                        }
                }catch(Exception e){//If something fails
                        xLog.xErrorLog(e, "History Check 2 In 
xContent::xBuildUI");//Save
an error message to server
                }
        }
        }.schedule(300);//Wait 300 milliseconds, in case a new page is
built...
}catch(Exception e){//If something bigger fails
        xLog.xErrorLog(e, "History Check 1 In xContent::xBuildUI");//Save a
different error log
}



Don't mind the comments, this is code I marked up because clients who
knew very little about gwt had to read it.


...And yes, I DO overcomplicate everything.  Mainly because I'm oh-so-
picky.  This was what it took for me to get directional history
support that would prevent two iframes from being opened, prevent
"link-lock" when the iframe was closed without changing the token,
detect which direction the user clicked, and differentiate between
closing the iframe and opening a new one {which also closes the old
window, but doesn't bother playing with the tokens.}

Simple answers are usually the best, but I had to do this because my
client was picky and actually tested everything.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to