Index: forgon-core/src/main/java/com/forgon/security/action/UserAction.java =================================================================== diff -u -r12331 -r13346 --- forgon-core/src/main/java/com/forgon/security/action/UserAction.java (.../UserAction.java) (revision 12331) +++ forgon-core/src/main/java/com/forgon/security/action/UserAction.java (.../UserAction.java) (revision 13346) @@ -2,14 +2,18 @@ import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + import net.sf.json.JSONArray; +import net.sf.json.JSONObject; import org.apache.commons.lang.StringUtils; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.ParentPackage; import com.forgon.directory.acegi.tools.AcegiHelper; +import com.forgon.directory.vo.LoginUserData; import com.forgon.security.model.User; import com.forgon.security.service.UserManager; import com.forgon.tools.StrutsParamUtils; @@ -66,4 +70,25 @@ iniInfo(); } + public void getLoginUserData() { + JSONObject obj = new JSONObject(); + try { + LoginUserData loginUserData = AcegiHelper.getLoginUser(); + if(loginUserData == null){ + loginUserData = new LoginUserData(); + } + obj.put("loginUserData", loginUserData); + obj.put("success", true); + } catch (Exception e) { + obj.put("success", false); + obj.put("msg", e.getMessage()); + } + HttpServletResponse response = StrutsParamUtils.getResponse(); + try { + response.setCharacterEncoding("utf-8"); + response.getWriter().print(obj.toString()); + } catch (Exception e) { + e.printStackTrace(); + } + } } Index: ssts-web/src/main/webapp/homepage/portalPage.jsp =================================================================== diff -u -r13328 -r13346 --- ssts-web/src/main/webapp/homepage/portalPage.jsp (.../portalPage.jsp) (revision 13328) +++ ssts-web/src/main/webapp/homepage/portalPage.jsp (.../portalPage.jsp) (revision 13346) @@ -218,18 +218,30 @@ // 10秒钟检测一下当前用户是否切换 function detectCurrentUserPeriodically(){ - PortalDWRManager.getLoginUserData(function(user){ - // 如果部门都为空,不刷新 - if(isUndefinedOrNullOrEmpty(user.currentOrgUnitCode) && isUndefinedOrNullOrEmpty(loginUserData.currentOrgUnitCode)){ - return; - } - if(user.currentOrgUnitCode != loginUserData.currentOrgUnitCode || user.userName != loginUserData.userName){ - alert('用户或者部门已更改,当前页面将自动刷新'); - refreshCurrentPage(); - } - }); + //PortalDWRManager.getLoginUserData(function(user){ + //onGetLoginUserData(user); + //}); + // ext 异步请求 + Ext4.Ajax.request({ + url : WWWROOT + '/systemmanage/user/userAction!getLoginUserData.do', + success : function(response, options) { + var result = Ext4.decode(response.responseText); + if(result.success){ + onGetLoginUserData(result.loginUserData); + } + } + }); } - +function onGetLoginUserData(user){ + // 如果部门都为空,不刷新 + if(isUndefinedOrNullOrEmpty(user.currentOrgUnitCode) && isUndefinedOrNullOrEmpty(loginUserData.currentOrgUnitCode)){ + return; + } + if(user.currentOrgUnitCode != loginUserData.currentOrgUnitCode || user.userName != loginUserData.userName){ + alert('用户或者部门已更改,当前页面将自动刷新'); + refreshCurrentPage(); + } +} function refreshCurrentPage(){ if(recyclingWindow != null){ recyclingWindow.close();