com.opensymphony.xwork2.ActionContext Java Examples

The following examples show how to use com.opensymphony.xwork2.ActionContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TeacherAction.java    From SmartEducation with Apache License 2.0 6 votes vote down vote up
/** 添加课程班级 */
public String addCourseClass() throws Exception{
	Teacher teaFind=getCurrentUser().getTeacher();
	//找到班级
	List<Class_> classList= classService.findByIds(classIds);
	//找到课程
	Course courseFind=courseService.findById(courseId);
	for(int i=0;i<classList.size();i++){
		//保存选课表
		classSelectCourseService.save(new ClassSelectCourse(""+classList.get(i).getId()+"-"+teaFind.getTeaNum()+"-"+courseId,
				teaFind.getTeaNum(), classList.get(i), courseFind));
	}
	//准备数据--courseId
	ActionContext.getContext().put("courseId", courseId);
	return "toListCourseClass";
}
 
Example #2
Source File: DepartmentAction.java    From SmartEducation with Apache License 2.0 6 votes vote down vote up
/** 修改页面 */
public String editUI() throws Exception {
	// 准备数据, departmentList
	List<Department> topList = departmentService.findTopList();
	List<Department> departmentList = DepartmentUtils
			.getAllDepartments(topList);
	ActionContext.getContext().put("departmentList", departmentList);

	// 准备回显的数据
	Department department = departmentService.findById(model.getId());
	ActionContext.getContext().getValueStack().push(department);
	if (department.getParent() != null) {
		parentId = department.getParent().getId();
	}
	return "saveUI";
}
 
Example #3
Source File: HomeAction.java    From SmartEducation with Apache License 2.0 6 votes vote down vote up
public String left() throws Exception {
	// 获得初始化容器中的权限对象集合
	@SuppressWarnings("unchecked")
	// List<Privilege> privileges = (List<Privilege>)
	// servletContext.getAttribute("secondPrivilegeList");
	List<Privilege> privileges = (List<Privilege>) ActionContext
			.getContext().getApplication().get("secondPrivilegeList");
	if (parentId == null) {
		// TODO
	} else {
		privilegeList = new ArrayList<Privilege>();
		for (Privilege pri : privileges) {
			if (pri.getParent().getId().equals(parentId)) {
				privilegeList.add(pri);
			}
		}
	}
	// 放到栈顶显示数据
	ActionContext.getContext().put("privilegeList", privilegeList);
	return "left";
}
 
Example #4
Source File: postInterceptor.java    From Mall-Server with MIT License 6 votes vote down vote up
/**
 * 只允许POST访问拦截器
 * @param actionInvocation
 * @return
 * @throws Exception
 */
@Override
public String intercept(ActionInvocation actionInvocation) throws Exception {
    // 解决跨域
    HttpServletResponse res = ServletActionContext.getResponse();
    res.setHeader("Access-Control-Allow-Origin", "*");
    res.setHeader("Access-Control-Allow-Credentials", "true");
    res.setHeader("Access-Control-Allow-Methods", "*");
    res.setHeader("Access-Control-Allow-Headers", "Content-Type,Access-Token");
    res.setHeader("Access-Control-Expose-Headers", "*");

    String method = ServletActionContext.getRequest().getMethod();
    if (method.equals("POST")) {
        actionInvocation.invoke();
        return null;
    } else {
        ActionContext context = ActionContext.getContext();
        Map<String, Object> jsonResult = new HashMap<String, Object>();
        jsonResult.put("rcode", 1);
        jsonResult.put("message", "just allow post method");
        jsonResult.put("result", "");
        ValueStack stack = context.getValueStack();
        stack.set("jsonResult", jsonResult);
        return "success";
    }
}
 
Example #5
Source File: FilteringSelect.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void handlerDataSource() throws JsonParseException, JsonMappingException, IOException {
	if (this.dataMap!=null) {
		return;
	}
	this.dataMap = new LinkedHashMap<String, String>();
	if (StringUtils.isBlank(this.dataSource)) {
		return;
	}
	Object dataSourceObj = ActionContext.getContext().getValueStack().findValue(this.dataSource);
	if (dataSourceObj == null) { // tag 傳過來的資料
		this.dataMap = (Map<String, String>)new ObjectMapper().readValue(this.dataSource, LinkedHashMap.class);
		return;
	}
	if (dataSourceObj instanceof java.lang.String) { // action 傳過來的資料
		this.dataMap = (Map<String, String>)new ObjectMapper().readValue((String)dataSourceObj, LinkedHashMap.class);
	}
	if (dataSourceObj instanceof Map) { // action 傳過來的資料
		this.dataMap = ((Map<String, String>)dataSourceObj);
	}
}
 
Example #6
Source File: OrderAction.java    From S-mall-ssh with GNU General Public License v3.0 6 votes vote down vote up
@Action("buy")
public String buy(){
    cartItems = new ArrayList<>();
    for(Integer ciid:ciids){
        if(ciid == -1){
            //由buyOne跳转而来
            cartItem = (CartItem) ActionContext.getContext().getSession().get("tempCartItem");
        }else{
            //由购物车跳转而来
            cartItem = (CartItem) cartItemService.get(ciid);
        }
        if(cartItem.getUser().getId() == user.getId()){
            totalNum += cartItem.getNumber();
            sum = sum.add(cartItem.getSum());
            cartItems.add(cartItem);
        }
    }
    ActionContext.getContext().getSession().put("cartItems", cartItems);
    return "buyPage";
}
 
Example #7
Source File: WeiboInfoAction.java    From SmartEducation with Apache License 2.0 6 votes vote down vote up
/** 跳转到绑定界面或者网站首页 */
public String bindUserUI() throws Exception {
	WeiboInfo weiboInfo=weiboInfoService.findByIdenfier(model.getIdentifier());
	
	if (weiboInfo != null) { // 如果存在就跳转首页
		if (weiboInfo.getUser() != null) {
			ActionContext.getContext().getSession().put("user", weiboInfo.getUser());
			return "toIndex";
		} else {
			ActionContext.getContext().put("identifier", model.getIdentifier());
			return "bindUserUI";
		}
	} else {
		// 否则保存到qq第三方登录信息表,跳转绑定用户界面,将openId携带过去
		weiboInfoService.save(model);
		return "bindUserUI";
	}
}
 
Example #8
Source File: BaseSupportAction.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
public String getActionMethodProgramId() {
	((BaseSimpleActionInfo)this.baseActionInfoProvide).handlerActionAnnotations();
	Annotation[] annotations = ((BaseSimpleActionInfo)this.baseActionInfoProvide).getActionMethodAnnotations();
	if (annotations==null || annotations.length<1) {
		return "";
	}
	String progId = "";
	for (Annotation annotation : annotations) {
		if (annotation instanceof ControllerMethodAuthority) {
			progId = this.defaultString( ((ControllerMethodAuthority)annotation).programId() );
		}
	}
	if ( StringUtils.isBlank(progId) ) { // 沒有ControllerMethodAuthority , 就找 url 的 prog_id 參數 , 主要是 COMMON FORM 會用到
		progId = this.defaultString( ActionContext.getContext().getValueStack().findString("prog_id") );			
	}
	return progId;
}
 
Example #9
Source File: UserLoginInterceptor.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
/**
 * 取出core-web 登入後產生的cookie, 這個cookie放了 account 與 current-id
 * 拿這兩個去 TB_SYS_USESS 查看有沒有在core-web有登入過
 * 如果有在core-web登入, 產生 AccountVO 與回傳 true
 * 
 * @param actionContext
 * @return
 * @throws Exception
 */
private boolean getUserCurrentCookie(ActionContext actionContext) throws Exception {
	Map<String, String> dataMap = UserCurrentCookie.getCurrentData( (HttpServletRequest)actionContext.get(StrutsStatics.HTTP_REQUEST) );
	String account = StringUtils.defaultString( dataMap.get("account") );
	String currentId = StringUtils.defaultString( dataMap.get("currentId") );
	//String sessionId = StringUtils.defaultString( dataMap.get("sessionId") );
	if (StringUtils.isBlank(account) || currentId.length()!=36 /*|| StringUtils.isBlank(sessionId)*/ ) { 	
		return false;
	}
	// 發現有時 UserCurrentCookie 寫入的 sessionId 與當前 sessionId 會不一樣
	if (this.uSessLogHelper.countByCurrent(account, currentId) >0 ) { // this.uSessLogHelper.countByCurrent(account, currentId, sessionId) >0 		 	
		accountObj = new AccountVO();
		((AccountVO)accountObj).setAccount(account);
		DefaultResult<AccountVO> result = this.accountService.findByUK( ((AccountVO)accountObj) );
		if (result.getValue()==null) {
			accountObj = null;
		} else {
			accountObj = result.getValue();
		}			
	}					
	return ( accountObj!=null && !StringUtils.isBlank(accountObj.getAccount()) );
}
 
Example #10
Source File: TeachProcessAction.java    From SmartEducation with Apache License 2.0 6 votes vote down vote up
/** 添加对应课程教学进程 */
public String add() throws Exception{
	//查找--课程
	Course courseFind=courseService.findById(courseId);
	//查找--教师
	Teacher teaFind=getCurrentUser().getTeacher();
	//查找--教学方式
	DataDict dataDictFind=dataDictService.findById(teachTypeId);
	//设置属性
	model.setCourse(courseFind);
	model.setTeacher(teaFind);
	model.setTeachType(dataDictFind);
	model.setChapter(chapterService.findById(chapterId));
	model.setDepartment(departmentService.findById(departmentId));
	//保存
	teachProcessService.save(model);
	//将courseId携带过去
	ActionContext.getContext().put("courseId", courseId);
	//部门Id携带过去
	ActionContext.getContext().put("departmentId", departmentId);
	return "toList";
}
 
Example #11
Source File: GoodsAction.java    From OnlineAuction with Apache License 2.0 6 votes vote down vote up
/**
 * 添加新拍卖商品
 * */
public String toAddGoods(){
	//1 保存上传的文件
	String targetDirectory = ServletActionContext.getServletContext().getRealPath("/uploadImages");
	String targetFileName = renameImage(fileName);
	File target = new File(targetDirectory,targetFileName);
	try {
		FileUtils.copyFile(goodsImage, target);
	} catch (IOException e) {
		e.printStackTrace();
	}
	// 2 保存新商品描述信息
	goods.setGoodsPic(targetFileName);
	Map<String, Object> session = ActionContext.getContext().getSession();
	Users saler = (Users) session.get("user");
	goods.setSaler(saler);
	goods.setBuyer(saler);
	goods.setGoodsStatus(0);
	
	goodsBiz.addGoods(goods);
	
	return "index";
}
 
Example #12
Source File: FileManagerDaoImpl.java    From scada with MIT License 6 votes vote down vote up
public void delete(Integer id){
	ActionContext actionContext = ActionContext.getContext();
	Map<String, Object> session = actionContext.getSession();
	String select=(String) session.get("select");
	String message=(String) session.get("message");
	
	
	if(!message.equals("")){
	if(select.equals("id")){
		try{
			FileManager fileManager=(FileManager)this.getSessionFactory().openSession().get(FileManager.class, id);
		    this.getHibernateTemplate().delete(fileManager);
		    this.getSessionFactory().openSession().close();
  
		}catch(Exception e){
			System.out.println(e);		
		}
	}
	}
}
 
Example #13
Source File: UserAgentRejectInterceptor.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
@Override
public String intercept(ActionInvocation actionInvocation) throws Exception {		
	HttpServletRequest request=ServletActionContext.getRequest(); 
	String userAgent = SimpleUtils.getStr(request.getHeader("User-Agent")).toUpperCase();
	if (rejectAgent==null) {
		return actionInvocation.invoke();
	}
	for (int i=0; rejectAgent!=null && i<rejectAgent.length; i++) {
		if (rejectAgent[i].trim().equals("")) {
			continue;
		}
		if (userAgent.indexOf(rejectAgent[i])>-1) {
			Map<String, Object> valueStackMap = new HashMap<String, Object>();
			valueStackMap.put("errorMessage", "not supported " + userAgent);
			valueStackMap.put("pageMessage", "not supported " + userAgent);
			ActionContext.getContext().getValueStack().push(valueStackMap);
			logger.warn("reject User-Agent="+userAgent);
			return "rejectUserAgent";
		}
	}
	return actionInvocation.invoke();
}
 
Example #14
Source File: UserLoginInterceptor.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
/**
 * 1. 先用admin登入
 * 2. 登出admin 改用 tester登入
 * 這樣的話 gsbsc-web 的 http-session 還是admin , 所以非core-web用tester登入的session , 要檢查當前CURRENT cookie 中的帳戶是否與 gsbsc-web 一樣
 * 要是不同的話就讓這個 http-session 失效掉
 *  
 * @param actionContext
 * @throws Exception
 */
private void invalidCurrentSessionForDifferentAccount(ActionContext actionContext) throws Exception {
	if (this.accountObj == null) {
		return;
	}
	Map<String, String> dataMap = UserCurrentCookie.getCurrentData( (HttpServletRequest)actionContext.get(StrutsStatics.HTTP_REQUEST) );
	String account = StringUtils.defaultString( dataMap.get("account") );
	if (StringUtils.isBlank(account)) {
		return;
	}
	if (this.accountObj.getAccount().equals(account)) {
		return;
	}
	this.accountObj = null;		
	UserAccountHttpSessionSupport.remove(actionContext.getSession());
	Subject subject = SecurityUtils.getSubject();		
	if (subject.isAuthenticated() && !account.equals(subject.getPrincipal()) ) {
		subject.logout();
	}
}
 
Example #15
Source File: StudentAction.java    From SmartEducation with Apache License 2.0 6 votes vote down vote up
/** 修改页面 */
public String editUI() throws Exception {
	// 准备数据, departmentList
	List<Department> topList = departmentService.findTopList();
	List<Department> departmentList = DepartmentUtils
			.getAllDepartments(topList);
	ActionContext.getContext().put("departmentList", departmentList);
	
	// 准备回显的数据
	Student stuFind=studentService.findById(model.getId());
	ActionContext.getContext().getValueStack().push(stuFind);
	
	// 准备数据, classList==>部门
	List<Class_> classList=classService.findByDept(stuFind.getDepartment());
	ActionContext.getContext().put("classList", classList);
	
	if (stuFind.getDepartment() != null) {
		departmentId = stuFind.getDepartment().getId();
	}
	if(stuFind.getClass_()!=null){
		classId=stuFind.getClass_().getId();
	}

	return "saveUI";
}
 
Example #16
Source File: ActionInfoSupportInterceptor.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
@Override
public String intercept(ActionInvocation actionInvocation) throws Exception {
	/*
	ActionInvocation ai=(ActionInvocation)ActionContext.getContext().get(ActionContext.ACTION_INVOCATION); 
	String action=ai.getProxy().getActionName(); 
	String namespace=ai.getProxy().getNamespace();
	*/
	HttpServletRequest request=ServletActionContext.getRequest(); 
	ActionContext context=actionInvocation.getInvocationContext();	
	String action=actionInvocation.getProxy().getActionName();
	String namespace=actionInvocation.getProxy().getNamespace();
	String remoteAddr=request.getRemoteAddr();
	String referer=request.getHeader("referer");		
	context.getSession().put(Constants.SESS_PAGE_INFO_ACTION_ByInterceptor, action);
	context.getSession().put(Constants.SESS_PAGE_INFO_NAMESPACE_ByInterceptor, namespace);
	context.getSession().put(Constants.SESS_PAGE_INFO_RemoteAddr_ByInterceptor, remoteAddr);
	context.getSession().put(Constants.SESS_PAGE_INFO_Referer_ByInterceptor, referer);	
	return actionInvocation.invoke();
}
 
Example #17
Source File: UserLoginInterceptor.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
@Override
public String intercept(ActionInvocation actionInvocation) throws Exception {
	ActionContext actionContext=actionInvocation.getInvocationContext();  
	Map<String, Object> session=actionContext.getSession();  
	this.accountObj = (AccountObj)session.get(Constants.SESS_ACCOUNT);
	Map<String, String> dataMap = UserCurrentCookie.getCurrentData( (HttpServletRequest)actionContext.get(StrutsStatics.HTTP_REQUEST) );
	String currentId = StringUtils.defaultString( dataMap.get("currentId") );
	String accountId = StringUtils.defaultString( dataMap.get("account") );
	if (accountObj!=null && !StringUtils.isBlank(accountObj.getAccount()) ) {
		if ( StringUtils.isBlank(currentId) ) {
			currentId = "NULL";
		}
		String sessSysCurrentId = (String)session.get(Constants.SESS_SYSCURRENT_ID);
		if ( !currentId.equals(sessSysCurrentId) ) {
			logger.warn( "currentId: " + currentId + " not equals session variable currentId: " + sessSysCurrentId );
			return this.redirectLogin(actionInvocation, session, currentId, accountId);
		}
		if (uSessLogHelper.countByCurrent(accountObj.getAccount(), currentId)<1) {
			return this.redirectLogin(actionInvocation, session, currentId, accountId);
		}						
		return actionInvocation.invoke();
	} 
	return this.redirectLogin(actionInvocation, session, currentId, accountId);
}
 
Example #18
Source File: ClassSelectCourseAction.java    From SmartEducation with Apache License 2.0 6 votes vote down vote up
/** 修改页面 */
public String editUI() throws Exception {
	//准备数据--源对象
	ClassSelectCourse classSelectCourseFind=classSelectCourseService.findById(model.getId());
	ActionContext.getContext().getValueStack().push(classSelectCourseFind);
	// 准备数据--班级
	List<Class_> classList=classService.findAll();
	ActionContext.getContext().put("classList", classList);
	//准备数据--课程
	Teacher teaFind=teacherService.findByTeacherNum(classSelectCourseFind.getTeacherNum());
	List<Course> courseList=new ArrayList<>(teaFind.getCourses());
	ActionContext.getContext().put("courseList", courseList);
	// 准备回显--班级
	classId=classSelectCourseFind.getClass_().getId();
	courseId=classSelectCourseFind.getCourse().getId();
	
	return "saveUI";
}
 
Example #19
Source File: SpiderCourseAction.java    From SmartEducation with Apache License 2.0 6 votes vote down vote up
/** 列表--访问 */
public String show() throws Exception{
	//准备信息--所有课程类型
	ActionContext.getContext().put("professionTypeList", spiderProfessionTypeService.findAll());
	//准备信息--点击的课程类型名
	if(professionId!=null){
		ActionContext.getContext().getValueStack().push(spiderProfessionTypeService.findById(professionId));
		ActionContext.getContext().put("professionId", professionId);
	}
	if(searchInfo!=null){
		ActionContext.getContext().put("searchInfo", searchInfo);
	}
	//分页信息
	new QueryHelper(SpiderCourse.class, "s")//
	.addCondition((professionId!=null), "s.professionType=?", spiderProfessionTypeService.findById(professionId))
	.addCondition((searchInfo!=null), "s.name LIKE ? OR s.info LIKE ?", "%"+searchInfo+"%","%"+searchInfo+"%")
	.preparePageBean(spiderCourseService, pageNum, 12);
	return "show";
}
 
Example #20
Source File: TeacherAction.java    From SmartEducation with Apache License 2.0 6 votes vote down vote up
/** 列表 */
public String list() throws Exception {
	// 准备数据, departmentList
	List<Department> topList = departmentService.findTopList();
	List<Department> departmentList = DepartmentUtils
			.getAllDepartments(topList);
	ActionContext.getContext().put("departmentList", departmentList);
	
	new QueryHelper(Teacher.class, "t")//
	.addCondition((departmentId != null), "t.department.id=?",departmentId)//
			.addCondition((viewType == 0) && (inputTerm.trim().length() > 0),"t.teaName LIKE ?", "%" + inputTerm + "%")//
			.addCondition((viewType == 1) && (inputTerm.trim().length() > 0),"t.teaNum LIKE ?", "%" + inputTerm + "%")//
			.preparePageBean(teacherService, pageNum, pageSize);

	return "list";
}
 
Example #21
Source File: TeachProcessAction.java    From SmartEducation with Apache License 2.0 6 votes vote down vote up
/** 添加对应课程教学进程界面 */
public String addUI() throws Exception{
	
	Teacher teaFind=getCurrentUser().getTeacher();
	Course courseFind=courseService.findById(courseId);
	
	//准备数据--三级部门--且是教的班级的部门
	List<ClassSelectCourse> classSelectList=classSelectCourseService.findByTeacherNumAndCourse(teaFind.getTeaNum(), courseFind);
	List<Department> departmentList=new ArrayList<>();
	for(int i=0;i<classSelectList.size();i++){
		if(!departmentList.contains(classSelectList.get(i).getClass_().getDepartment())){
			departmentList.add(classSelectList.get(i).getClass_().getDepartment());
		}
	}
	ActionContext.getContext().put("departmentList", departmentList);
	//准备数据--课程id
	ActionContext.getContext().put("courseId", courseId);
	//准备数据--教学方式--001
	DataType dataTypeFind=dataTypeService.findByNum("001");
	ActionContext.getContext().put("teachTypeList", dataTypeFind.getDataDicts());
	//准备数据--课程对应章节
	List<Chapter> chapterList=chapterService.findByCourse(courseFind);
	ActionContext.getContext().put("chapterList", chapterList);
	return "saveUI";
}
 
Example #22
Source File: BaseAction.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public BaseAction() {
	super();
	this.request=(Map<String, Object>)ActionContext.getContext().get("request");
	this.session=(Map<String, Object>)ActionContext.getContext().getSession();
	this.application=(Map<String, Object>)ActionContext.getContext().getApplication();	
}
 
Example #23
Source File: TestCommentFrontEndAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void setToken() {
    String token = TokenHelper.generateGUID();
    ActionContext.getContext().setSession(new HashMap<String, Object>());
    String tokenName = "test_tokenName";
    String tokenSessionAttributeName = TokenHelper.buildTokenSessionAttributeName(tokenName);
    ActionContext.getContext().getSession().put(tokenSessionAttributeName, token);
    this.addParameter(TokenHelper.TOKEN_NAME_FIELD, new String[]{tokenName});
    this.addParameter(tokenName, new String[]{token});
}
 
Example #24
Source File: WeiboInfoAction.java    From SmartEducation with Apache License 2.0 5 votes vote down vote up
public void bind(User userFind){
	//如果属性的绑定信息合法,查找到qq信息表信息,设置对应user,更新数据
	WeiboInfo weiboInfo = weiboInfoService.findByIdenfier(model.getIdentifier());
	weiboInfo.setUser(userFind);
	weiboInfoService.update(weiboInfo);
	ActionContext.getContext().getSession().put("user", userFind);
}
 
Example #25
Source File: UserDetailsAction.java    From SmartEducation with Apache License 2.0 5 votes vote down vote up
/** 列表 */
public String list() throws Exception {
	// 准备数据, departmentList
	List<Department> topList = departmentService.findTopList();
	List<Department> departmentList = DepartmentUtils
			.getAllDepartments(topList);
	ActionContext.getContext().put("departmentList", departmentList);
	// 准备数据, roleList
	List<Role> roleList = roleService.findAll();
	ActionContext.getContext().put("roleList", roleList);

	// 没有分页 version-0
	// List<UserDetails> userDetails = userDetailsService.findAll();
	// 准备分页信息version-1
	// PageBean pageBean=userDetailsService.getPageBean(pageNum,pageSize);

	// 准备分页信息version-2
	// String hql="FROM UserDetails";
	// List<Object> parameters=new ArrayList<Object>();
	// parameters=null;
	// PageBean
	// pageBean=userDetailsService.getPageBean(pageNum,pageSize,hql,parameters);
	// ActionContext.getContext().getValueStack().push(pageBean);
	// 准备分页信息version-3
	// roleService.findById(roleId);
	new QueryHelper(UserDetails.class, "u")//
			.addCondition((departmentId != null), "u.department.id=?",
					departmentId)//
			.addCondition(
					(viewType == 0) && (inputTerm.trim().length() > 0),
					"u.userName LIKE ?", "%" + inputTerm + "%")//
			.addCondition(
					(viewType == 1) && (inputTerm.trim().length() > 0),
					"u.userNum LIKE ?", "%" + inputTerm + "%")//
			.preparePageBean(userDetailsService, pageNum, pageSize);
	return "list";
}
 
Example #26
Source File: UserLoginInterceptor.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
private String getProgramId(Annotation[] annotations) {
	String progId = "";
	for (Annotation annotation : annotations) {
		if (annotation instanceof ControllerMethodAuthority) {
			progId = StringUtils.defaultString( ((ControllerMethodAuthority)annotation).programId() );
		}
	}
	if ( StringUtils.isBlank(progId) ) { // 沒有ControllerMethodAuthority , 就找 url 的 prog_id 參數 , 主要是 COMMON FORM 會用到
		progId = StringUtils.defaultString( ActionContext.getContext().getValueStack().findString("prog_id") );			
	}
	return progId;		
}
 
Example #27
Source File: BaseSimpleActionInfo.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
public void handlerActionAnnotations() {
	if (this.actionAnnotations!=null) {
		return;
	}
	ActionInvocation actionInvocation=ActionContext.getContext().getActionInvocation();
	this.actionAnnotations = actionInvocation.getAction().getClass().getAnnotations();
	Method[] methods = actionInvocation.getAction().getClass().getMethods();
	for (Method method : methods) {
		if (this.actionMethodName.equals(method.getName())) {
			this.actionMethodAnnotations = method.getAnnotations();
		}
	}		
}
 
Example #28
Source File: GuiFragmentResult.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Execute this result, using the specified fragment.
 * @param code The code of the fragment
 * @param invocation The invocation
 */
@Override
public void doExecute(String code, ActionInvocation invocation) throws Exception {
	if (null == code) {
		code = conditionalParse(this._code, invocation);
	}
	if (null == code) {
		this.executeDispatcherResult(invocation);
		return;
	}
	ActionContext ctx = invocation.getInvocationContext();
	HttpServletRequest req = (HttpServletRequest) ctx.get(ServletActionContext.HTTP_REQUEST);
	IGuiFragmentManager guiFragmentManager =
			(IGuiFragmentManager) ApsWebApplicationUtils.getBean(SystemConstants.GUI_FRAGMENT_MANAGER, req);
	try {
		GuiFragment guiFragment = guiFragmentManager.getGuiFragment(code);
		String output = (null != guiFragment) ? guiFragment.getCurrentGui() : null;
		if (StringUtils.isBlank(output)) {
			_logger.info("The fragment '{}' is not available - Action '{}' - Namespace '{}'", 
					code, invocation.getProxy().getActionName(), invocation.getProxy().getNamespace());
			boolean execution = this.executeDispatcherResult(invocation);
			if (!execution) {
				output = "The fragment '" + code + "' is not available";
			} else {
				return;
			}
		}
		RequestContext reqCtx = (RequestContext) req.getAttribute(RequestContext.REQCTX);
		ExecutorBeanContainer ebc = (ExecutorBeanContainer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_EXECUTOR_BEAN_CONTAINER);
		Writer writer = this.getWriter();
		Template template = new Template(code, new StringReader(output), ebc.getConfiguration());
		template.process(ebc.getTemplateModel(), writer);
	} catch (Throwable t) {
		_logger.error("Error processing GuiFragment result!", t);
		throw new RuntimeException("Error processing GuiFragment result!", t);
	}
}
 
Example #29
Source File: TeacherAction.java    From SmartEducation with Apache License 2.0 5 votes vote down vote up
/** 删除测试paper */
public String deleteTestPaper() throws Exception{
	testPaperService.delete(testPaperId);
	//携带courseId
	ActionContext.getContext().put("courseId", courseId);
	//携带doInfo
	ActionContext.getContext().put("doInfo", doInfo);
	return "toMyCourseUI";
}
 
Example #30
Source File: PlainTextErrorResult.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void execute( ActionInvocation invocation )
    throws Exception
{
    HttpServletResponse response = (HttpServletResponse) invocation.getInvocationContext().get(
        StrutsStatics.HTTP_RESPONSE );

    response.setContentType( "text/plain; charset=UTF-8" );
    response.setHeader( "Content-Disposition", "inline" );
    response.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );

    ValueStack stack = ActionContext.getContext().getValueStack();
    String finalMessage = parse ? TextParseUtil.translateVariables( message, stack ) : message;

    finalMessage = formatFinalMessage( finalMessage );

    // ---------------------------------------------------------------------
    // Write final message
    // ---------------------------------------------------------------------

    PrintWriter writer = null;

    try
    {
        writer = response.getWriter();
        writer.print( finalMessage );
        writer.flush();
    }
    finally
    {
        if ( writer != null )
        {
            writer.close();
        }
    }
}