1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    3
    Vote Rating
    0
    pauloallonso is on a distinguished road

      0  

    Question Unanswered: Problem with syncronism

    Unanswered: Problem with syncronism


    I'm having problems with synchronism in my aplication. Only one window can be exist, if any user try to access the same page in other window the system should close this window, restore the first window and show a message like: "Duplicated Instance of ... "
    To do this I used Javascript Native, however, it somes like happening some kind of synchronism problem.
    Sometimes works, sometimes not, I tried to use timers, but doesn't help very much, it is very unstable, like this:

    Timer t = new Timer() {
    @Override
    public void run() {
    if(GXT.isIE) {
    focusWindow();
    } else {
    resizeWindow();
    }

    final MessageBox box;
    box = MessageBox.alert(
    "Duplicated Instance... ",
    "...",
    new Listener<MessageBoxEvent>() {
    @Override
    public void handleEvent(final MessageBoxEvent be) {
    }
    });

    Timer timer = new Timer() {
    @Override
    public void run() {
    box.close();
    return;
    }
    };
    timer.schedule(5000);
    return ;
    }
    };
    t.schedule(300);

    /**
    * Used to focus on the principal window
    * Works only with IE
    */
    public static native void focusWindow() /*-{
    this.focus();
    }-*/;


    /**
    * Resize the principal window
    */
    public static native void resizeWindow() /*-{
    top.window.moveTo(0,0);
    if (document.all) {
    top.window.resizeTo(screen.availWidth,screen.availHeight);
    }
    else if (document.layers || document.getElementById) {
    if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
    top.window.outerHeight = screen.availHeight;
    top.window.outerWidth = screen.availWidth;
    }
    }
    }-*/;

    Does anybody know how can I solve this problem? Preferentially using GWT ?

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,634
    Answers
    107
    Vote Rating
    79
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      0  

    Default


    I'm having a difficult time understanding your code - it appears that you create a message box, but never display it, and you try to focus the window as well as resize it to not allow anything else to be done. These seem to make sense, but browsers are not designed to be able to take over the computer and prevent other apps from being run.

    If you are trying to make sure a single session has only one running window at once, it could make sense to track this on the server, using whatever session is created when logging in. Another idea would be to assign each running app instance an timestamp from when it started, and set a single cookie - perhaps again use your timer to check that cookie, and if it doesnt match the currently running app's timestamp, there is a newer window, so block the user from using the current one.

    The browser offers very little in this department, but your own application might be able to gain more control. For example, if you run IE twice, and log in twice, it will have two different sessions, and there will be no way to have your windows talking back and forth (in contrast Chrome and Firefox have their different tabs/windows share the same session/cookies). If your app launches in a new window from clicking a link, it could be possible to disable that link after it has been clicked once, and close the new page if the starting page is closed.

    Taking over the screen entirely comes with the risk of something going wrong and your app no longer functioning, and also not allowing the user to do anything to fix it - be very sure that this is what you want to do before implementing this.

  3. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    5
    Vote Rating
    0
    Lilliana is on a distinguished road

      0  

    Default


    I think you make some really good points here, and I have found your criticisms very helpful. It seems that I have many of the same misconceptions, and it is great that you have shined some light on that for me. All of this will help me out a great deal as I move forward on the payroll software development project that I'm currently working on. Thanks a lot for your help.

Thread Participants: 2

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar