⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 headerbean.java

📁 HR系统模拟企业对内部职员的管理
💻 JAVA
字号:
/*$Id: HeaderBean.java,v 1.1 2008/07/15 03:38:23 liqi Exp $ *-------------------------------------- * Apusic (Kingdee Middleware) *--------------------------------------- * Copyright By Apusic ,All right Reserved * author   date   comment * chenhongxin  2008-4-14  Created*/package org.operamasks.example.ejb.hr.litebean.module;import java.util.Map;import javax.faces.context.FacesContext;import org.operamasks.example.ejb.hr.constants.ILocalStringsKey;import org.operamasks.example.ejb.hr.constants.IUserConstants;import org.operamasks.example.ejb.hr.entity.User;import org.operamasks.faces.annotation.Action;import org.operamasks.faces.annotation.BeforeRender;import org.operamasks.faces.annotation.Bind;import org.operamasks.faces.annotation.ManagedBean;import org.operamasks.faces.annotation.ManagedBeanScope;/** * 页脚页面的托管Bean * @author chenhongxin */@ManagedBean(name="module.headerBean", scope=ManagedBeanScope.SESSION)public class HeaderBean extends BaseBean {		/**	 * 绑定欢迎标语Text域的值	 */	@Bind(id="welcome", attribute="value")	private String welcome;		/**	 * 绑定header的js脚本回调	 */	@Bind(id="headerScripter", attribute="script")	private String headerScripter;		@BeforeRender	void beforeRender(boolean isPostback) {		if(!isPostback) {			headerScripter = "";//因为该Bean的Scope是Session的,所以要清空上次页面交互留下的脚本信息			FacesContext context = FacesContext.getCurrentInstance();			Map<String, Object> session = context.getExternalContext().getSessionMap();			User user = (User)session.get(IUserConstants.USER_BEAN);			String label = getMessages().get(ILocalStringsKey.WELCOME_LABEL);			if(label != null) {//替换占位符,将登陆用户的名称载如标语				welcome = String.format(label, user.getName());			}		}	}		/**	 * 绑定注销按钮的点击事件	 */	@Action(id="logout")	public void logout() {		FacesContext context = FacesContext.getCurrentInstance();		Map<String, Object> session = context.getExternalContext().getSessionMap();		session.put(IUserConstants.USER_BEAN, null);//清空Session的USER_BEAN记录		headerScripter = "location.href='../login.faces'";//使用js脚本回调执行页面跳转	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -