com.opensymphony.xwork2.ActionSupport类源码
version : xwork-2.1.0
/*
* Copyright (c) 2002-2006 by OpenSymphony
* All rights reserved.
*/
package com.opensymphony.xwork2; import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle; import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory; /**
* Provides a default implementation for the most common actions.
* See the documentation for all the interfaces this class implements for more detailed information.
*/
public class ActionSupport implements Action, Validateable, ValidationAware, TextProvider, LocaleProvider, Serializable { protected static Logger LOG = LoggerFactory.getLogger(ActionSupport.class); private final transient TextProvider textProvider = new TextProviderFactory().createInstance(getClass(), this);
private final ValidationAwareSupport validationAware = new ValidationAwareSupport(); public void setActionErrors(Collection errorMessages) {
validationAware.setActionErrors(errorMessages);
} public Collection getActionErrors() {
return validationAware.getActionErrors();
} public void setActionMessages(Collection messages) {
validationAware.setActionMessages(messages);
} public Collection getActionMessages() {
return validationAware.getActionMessages();
} /**
* @deprecated Use {@link #getActionErrors()}.
*/
public Collection getErrorMessages() {
return getActionErrors();
} /**
* @deprecated Use {@link #getFieldErrors()}.
*/
public Map getErrors() {
return getFieldErrors();
} public void setFieldErrors(Map errorMap) {
validationAware.setFieldErrors(errorMap);
} public Map getFieldErrors() {
return validationAware.getFieldErrors();
} public Locale getLocale() {
ActionContext ctx = ActionContext.getContext();
if (ctx != null) {
return ctx.getLocale();
} else {
LOG.debug("Action context not initialized");
return null;
}
} public String getText(String aTextName) {
return textProvider.getText(aTextName);
} public String getText(String aTextName, String defaultValue) {
return textProvider.getText(aTextName, defaultValue);
} public String getText(String aTextName, String defaultValue, String obj) {
return textProvider.getText(aTextName, defaultValue, obj);
} public String getText(String aTextName, List args) {
return textProvider.getText(aTextName, args);
} public String getText(String key, String[] args) {
return textProvider.getText(key, args);
} public String getText(String aTextName, String defaultValue, List args) {
return textProvider.getText(aTextName, defaultValue, args);
} public String getText(String key, String defaultValue, String[] args) {
return textProvider.getText(key, defaultValue, args);
} public String getText(String key, String defaultValue, List args, ValueStack stack) {
return textProvider.getText(key, defaultValue, args, stack);
} public String getText(String key, String defaultValue, String[] args, ValueStack stack) {
return textProvider.getText(key, defaultValue, args, stack);
} public ResourceBundle getTexts() {
return textProvider.getTexts();
} public ResourceBundle getTexts(String aBundleName) {
return textProvider.getTexts(aBundleName);
} public void addActionError(String anErrorMessage) {
validationAware.addActionError(anErrorMessage);
} public void addActionMessage(String aMessage) {
validationAware.addActionMessage(aMessage);
} public void addFieldError(String fieldName, String errorMessage) {
validationAware.addFieldError(fieldName, errorMessage);
} public String input() throws Exception {
return INPUT;
} public String doDefault() throws Exception {
return SUCCESS;
} /**
* A default implementation that does nothing an returns "success".
* <p/>
* Subclasses should override this method to provide their business logic.
* <p/>
* See also {@link com.opensymphony.xwork2.Action#execute()}.
*
* @return returns {@link #SUCCESS}
* @throws Exception can be thrown by subclasses.
*/
public String execute() throws Exception {
return SUCCESS;
} public boolean hasActionErrors() {
return validationAware.hasActionErrors();
} public boolean hasActionMessages() {
return validationAware.hasActionMessages();
} public boolean hasErrors() {
return validationAware.hasErrors();
} public boolean hasFieldErrors() {
return validationAware.hasFieldErrors();
} /**
* Clears field errors. Useful for Continuations and other situations
* where you might want to clear parts of the state on the same action.
*/
public void clearFieldErrors() {
validationAware.clearFieldErrors();
} /**
* Clears action errors. Useful for Continuations and other situations
* where you might want to clear parts of the state on the same action.
*/
public void clearActionErrors() {
validationAware.clearActionErrors();
} /**
* Clears messages. Useful for Continuations and other situations
* where you might want to clear parts of the state on the same action.
*/
public void clearMessages() {
validationAware.clearMessages();
} /**
* Clears all errors. Useful for Continuations and other situations
* where you might want to clear parts of the state on the same action.
*/
public void clearErrors() {
validationAware.clearErrors();
} /**
* Clears all errors and messages. Useful for Continuations and other situations
* where you might want to clear parts of the state on the same action.
*/
public void clearErrorsAndMessages() {
validationAware.clearErrorsAndMessages();
} /**
* A default implementation that validates nothing.
* Subclasses should override this method to provide validations.
*/
public void validate() {
} public Object clone() throws CloneNotSupportedException {
return super.clone();
} /**
* <!-- START SNIPPET: pause-method -->
* Stops the action invocation immediately (by throwing a PauseException) and causes the action invocation to return
* the specified result, such as {@link #SUCCESS}, {@link #INPUT}, etc.
* <p/>
*
* The next time this action is invoked (and using the same continuation ID), the method will resume immediately
* after where this method was called, with the entire call stack in the execute method restored.
* <p/>
*
* Note: this method can <b>only</b> be called within the {@link #execute()} method.
* <!-- END SNIPPET: pause-method -->
*
* @param result the result to return - the same type of return value in the {@link #execute()} method.
*/
public void pause(String result) {
} }
com.opensymphony.xwork2.ActionSupport类源码的更多相关文章
- Java集合---Array类源码解析
Java集合---Array类源码解析 ---转自:牛奶.不加糖 一.Arrays.sort()数组排序 Java Arrays中提供了对所有类型的排序.其中主要分为Prim ...
- Cocos2d-X3.0 刨根问底(六)----- 调度器Scheduler类源码分析
上一章,我们分析Node类的源码,在Node类里面耦合了一个 Scheduler 类的对象,这章我们就来剖析Cocos2d-x的调度器 Scheduler 类的源码,从源码中去了解它的实现与应用方法. ...
- List 接口以及实现类和相关类源码分析
List 接口以及实现类和相关类源码分析 List接口分析 接口描述 用户可以对列表进行随机的读取(get),插入(add),删除(remove),修改(set),也可批量增加(addAll),删除( ...
- Thread类源码剖析
目录 1.引子 2.JVM线程状态 3.Thread常用方法 4.拓展点 一.引子 说来也有些汗颜,搞了几年java,忽然发现竟然没拜读过java.lang.Thread类源码,这次特地拿出来晒一晒. ...
- Java并发编程笔记之Unsafe类和LockSupport类源码分析
一.Unsafe类的源码分析 JDK的rt.jar包中的Unsafe类提供了硬件级别的原子操作,Unsafe里面的方法都是native方法,通过使用JNI的方式来访问本地C++实现库. rt.jar ...
- HTTP Status 500 - com.opensymphony.xwork2.ActionSupport.toAddPage()
使用struts2过程中碰到以下错误 HTTP Status 500 - com.opensymphony.xwork2.ActionSupport.toAddPage() type Exceptio ...
- python附录-builtins.py模块str类源码(含str官方文档链接)
python附录-builtins.py模块str类源码 str官方文档链接:https://docs.python.org/3/library/stdtypes.html#text-sequence ...
- Long类源码浅析
1.Long类和Integer相类似,都是基本类型的包装类,类中的方法大部分都是类似的: 关于Integer类的浅析可以参看:Integer类源码浅析 2.这里主要介绍一下LongCache类,该缓存 ...
- java.lang.Void类源码解析_java - JAVA
文章来源:嗨学网 敏而好学论坛www.piaodoo.com 欢迎大家相互学习 在一次源码查看ThreadGroup的时候,看到一段代码,为以下: /* * @throws NullPointerEx ...
随机推荐
- Java数据库增删改查
数据库为MySQL数据库,Oracle数据库类似: create database db_test;--创建数据库 ';--创建用户 grant all privileges on db_test.* ...
- spring + mybatis 注解式事务不回滚的原因分析 @Transactional
在一个项目中发现spring的事务无法回滚. DEBUG: org.mybatis.spring.SqlSessionUtils - SqlSession [org.apache.ibatis.ses ...
- (1)java虚拟机概念和结构图
java虚拟机解构图一 java虚拟机解构图二 java虚拟机结构图三 [1]类加载系统 --->负责从文件系统或网络中加载class信息,存放至方法区的内存空间[2]java堆 ...
- 其实没那么复杂!探究react-native通信机制
近段时间来Android上最火的框架非react native莫属了,这里我不去评价这个框架的好坏,毕竟只有用过的人才会有深刻的体会.但是我个人有一个习惯,在使用一个开源库之前,一定要看过它的源码,不 ...
- 学习面试题Day05
1.如何理解数组在Java中作为一个类? Java的数组本质上是一个类,该类还保存了数据类型的信息.该类通过成员变量的形式来保存数据,并且通过[]符号,使用下标来访问这些数据.在处理基本类型数据时,数 ...
- LA3942-Remember the Word(Trie)
题意: 有s个不同的单词,给出一个长字符串把这个字符串分解成若干个单词的连接(可重复使用),有多少种分解方法 分析: dp[i]表示i开始的字符串能分解的方法数 dp[i]=sum(dp[i+len( ...
- 黑盒测试用例设计方法&理论结合实际 -> 正交试验法
一. 概念 依据Galois理论,从大量的(实验)数据(测试例)中挑选适量的,有代表性的点(例),从而合理地安排实验(测试)的一种科学实验设计方法.类似的方法有:聚类分析方法,因子方法方法等. 二. ...
- Java中线程顺序执行
现有线程threadone.threadtwo和threadthree,想要的运行顺序为threadone->threadtwo->threadthree,应该如何处理?这里需要用到一个简 ...
- ubuntu 常用软件配置
1. 首先重装系统后需要执行: sudo apt-get install update 2. 然后安装必要的软件: terminator, vim, git,
- Hibernate学习笔记(四)关系映射之一对一关联映射
一. 一对一关联映射 ² 两个对象之间是一对一的关系,如Person-IdCard(人—身份证号) ² 有两种策略可以实现一对一的关联映射 Ø 主键关联:即让 ...