StrutsEntityAction詳細分析
StrutsEntityAction org.springside.core.web.StrutsEntityAction
第2層パッケージ:単一のEntity CRUD操作を管理するStruts Actionベースクラス.サブクラスは以下のように宣言され、デフォルトのCRUD操作を実行します.
このようなパッケージは1つの方法のみを示しており、現在のパッケージを自分のプロジェクトの習慣に従って再パッケージすることができます.
1.index、list、create、edit、view、save、deleteの7種類のactionのプロセスパッケージ;
2.doListEntity、doGetEntity、doNewEntity、doSaveEntity()、doDeleteEntityの5つのビジネス関数呼び出しは、サブクラスで再ロードできます.
3.initEntity、initFormの2つのFormBeanとビジネスオブジェクトの初期関数とreferenceData、onInitForm、onInitEntityの3つのコールバック関数.
4.savedMessage、deletedMessageの2つのビジネス成功情報は、サブクラスで再ロードできます.
implementsはInitializingBeanクラスを持つため、実現方法:afterPropertiesSet---Initコールバック関数、一連の汎用パラメータを初期化する必要がある.
3つのコールバック関数
public abstract class StrutsEntityAction<T, M extends EntityDao<T>> extends StrutsAction implements InitializingBean {}
第2層パッケージ:単一のEntity CRUD操作を管理するStruts Actionベースクラス.サブクラスは以下のように宣言され、デフォルトのCRUD操作を実行します.
このようなパッケージは1つの方法のみを示しており、現在のパッケージを自分のプロジェクトの習慣に従って再パッケージすることができます.
1.index、list、create、edit、view、save、deleteの7種類のactionのプロセスパッケージ;
2.doListEntity、doGetEntity、doNewEntity、doSaveEntity()、doDeleteEntityの5つのビジネス関数呼び出しは、サブクラスで再ロードできます.
3.initEntity、initFormの2つのFormBeanとビジネスオブジェクトの初期関数とreferenceData、onInitForm、onInitEntityの3つのコールバック関数.
4.savedMessage、deletedMessageの2つのビジネス成功情報は、サブクラスで再ロードできます.
/** url method Action . index Action.*/
@Override
public ActionForward unspecified(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
return index(mapping, form, request, response);
}
implementsはInitializingBeanクラスを持つため、実現方法:afterPropertiesSet---Initコールバック関数、一連の汎用パラメータを初期化する必要がある.
3つのコールバック関数
/**
* form list . categoryList, .
*/
protected void refrenceData(HttpServletRequest request) {
request.setAttribute("disabledField", disabledField);
}
/**
* Form . Form , .
*/
protected void onInitForm(ActionForm form, HttpServletRequest request,T object) {
request.setAttribute(getEntityName(), object);
}
/**
* Form . , .
*/
protected void onInitEntity(ActionForm form, HttpServletRequest request,T object) {}