<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    9910

    單飛

       :: 首頁 :: 聯系 :: 聚合  :: 管理
    參考
    http://gwt-ext.com/forum/viewtopic.php?t=1682


    import com.google.gwt.user.client.rpc.RemoteService;
    import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

    @RemoteServiceRelativePath("sessout")
    public interface MyService extends RemoteService {
        public Integer getUserSessionTimeoutMillis();
    }


    import com.google.gwt.user.client.rpc.AsyncCallback;

    public interface MyServiceAsync {
        void getUserSessionTimeoutMillis(AsyncCallback async);
    }



    import com.google.gwt.user.server.rpc.RemoteServiceServlet;

    @SuppressWarnings("serial")
    public class MyServiceImpl extends RemoteServiceServlet implements MyService {

        public Object getLoggedInUser() {
            return getThreadLocalRequest().getSession().getAttribute(EConstants.USER);
        }

        /**
         * Should be the first RPC call from all UIDef*.onModuleLoad()
         *
         * @return java.lang.Integer (-1 if the user session has already timed out,
         *         otherwise, the number of milliseconds)
         */
        public Integer getUserSessionTimeoutMillis() {
            Integer returnObj = null;
            if (getLoggedInUser() != null) {
                returnObj = new Integer(EduConstants.SESSION_TIMEOUT_MILLIS); // milliseconds
            } else {
                returnObj = new Integer(-1);
            }
            return returnObj;
        }
    }

    public class EConstants {

        public static final String USER = "sessuser";

        public static final int SESSION_TIMEOUT_MILLIS = 1800; // 30 minute
    }


    web.xml

      <servlet>
        <servlet-name>sessServlet</servlet-name>
        <servlet-class>com.chinaedu.edupass.server.MyServiceImpl</servlet-class>
      </servlet>
     
      <servlet-mapping>
        <servlet-name>sessServlet</servlet-name>
        <url-pattern>/ldapmanager/sessout</url-pattern>
      </servlet-mapping>


    public class LManager implements EntryPoint {


        private Timer sessionTimeoutTimer = null;
    private MyServiceAsync service;
    public void onModuleLoad() {

    service = (MyServiceAsync) GWT.create(MyService.class);

            showLogin();
    }

    private void showLogin() {
            final LoginDialog dialog = new LoginDialog() {
                protected void showMainView() {
                    super.showMainView();
                    doShowMainView();
                    // 登錄后開始計時
                    initSessionTimers();
                }

            };
            dialog.setAutoCenter(true);
            dialog.setIsModal(true);
            dialog.setShowHeader(false);
            dialog.setShowToolbar(false);
            dialog.setEdgeSize(10);
            dialog.setWidth(300);
            dialog.setHeight(180);

            dialog.show();
        }


        private void doShowMainView() {


    /**
         * 客戶端在超時后執行跳轉登錄
         *
         * @sessionTimeInMillis Integer
         */
        private void initSessionTimers() {
            // Allow 30 seconds to get the RPC call constructed and called.
            sessionTimeoutTimer = new Timer() {
                public void run() {
                    service.getUserSessionTimeoutMillis(new AsyncCallback() {
                        public void onSuccess(Object result) {
                            int sessionTimeMillis = ((Integer) result).intValue();
                            if (sessionTimeMillis == -1) {
                                // 超時后執行跳轉到登錄窗口
                                displaySessionTimedOut();
                            } else {
                                sessionTimeoutTimer.cancel();
                                initSessionTimers();
                            }
                        }

                        public void onFailure(final Throwable caught) {
                            SC.say(LdapI18N.ldapMessages().failed());
                        }
                    });
                }
            };
            // 31 minutes 服務器端設置為30分鐘超時,如果30分鐘沒有操作
            // 就會返回超時,如果期間有操作,則在等31分鐘后再輪詢
            sessionTimeoutTimer.schedule(31*60*1000);

        }

        private void displaySessionTimedOut() {
            SC.say(LI18N.ldapMessages().sessionTimeOut(), new BooleanCallback() {
                public void execute(Boolean value) {
                    showLogin();
                }
            });
        }
    posted on 2011-08-03 18:18 單飛 閱讀(700) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 77777亚洲午夜久久多人| 亚洲日韩乱码中文无码蜜桃臀 | 亚洲av无码专区在线| 好男人看视频免费2019中文| 另类专区另类专区亚洲| 亚洲国产精品无码中文字| 成人免费大片免费观看网站| 妇女自拍偷自拍亚洲精品| 久久亚洲精品无码| 免费网站看v片在线香蕉| 91视频精品全国免费观看| 亚洲av日韩av综合| 亚洲成AV人在线观看天堂无码| 最近2019中文字幕免费看最新| 9久热这里只有精品免费| 中文字幕在线观看亚洲视频| 亚洲伊人久久成综合人影院| 亚洲视频免费在线播放| 一级黄色免费网站| 亚洲精品国产日韩| 亚洲国产精品VA在线看黑人| 国产美女做a免费视频软件| 精品视频在线免费观看| 偷自拍亚洲视频在线观看99| 亚洲系列国产精品制服丝袜第| mm1313亚洲精品国产| 一个人免费观看视频www| 西西人体免费视频| 国产精品亚洲天堂| 亚洲五月丁香综合视频| 亚洲国产精品va在线播放| 亚洲国产精品13p| 国产麻豆剧传媒精品国产免费| 免费观看美女用震蛋喷水的视频| 国产免费播放一区二区| 亚洲av无码成人精品区一本二本| 亚洲香蕉免费有线视频| 亚洲另类激情综合偷自拍图| 亚洲av无码成人精品区在线播放| 成年女人毛片免费播放人| 亚欧在线精品免费观看一区|