001: /*
002: * Copyright 2006-2007 Luca Garulli (luca.garulli@assetdata.it)
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.romaframework.aspect.flow.impl;
018:
019: import org.romaframework.aspect.flow.FlowAspectAbstract;
020: import org.romaframework.aspect.flow.feature.FlowActionFeatures;
021: import org.romaframework.aspect.session.SessionInfo;
022: import org.romaframework.aspect.view.page.CallerHandler;
023: import org.romaframework.core.flow.Controller;
024: import org.romaframework.core.flow.ObjectContext;
025: import org.romaframework.core.flow.UserObjectEventListener;
026: import org.romaframework.core.schema.SchemaElement;
027: import org.romaframework.core.schema.SchemaField;
028:
029: /**
030: * POJO based implementation of Flow Aspect behavior interface.
031: *
032: * @author Luca Garulli (luca.garulli@assetdata.it)
033: */
034: public class POJOFlow extends FlowAspectAbstract implements
035: UserObjectEventListener {
036:
037: public void forward(Object iCurrentObject,
038: Class<? extends Object> iNextClass, String iPosition,
039: boolean iSetBack) {
040: if (iNextClass != null) {
041: // SEARCH THE FORM INSTANCE BETWEEN USER SESSSION FORMS
042: Object nextObj = Controller.getInstance().getObject(
043: iNextClass, null);
044:
045: forward(iCurrentObject, nextObj, iPosition, iSetBack);
046: }
047: }
048:
049: public void forward(Object iCurrentObject, Object iNextObject,
050: String iPosition, boolean iSetBack) {
051: if (iSetBack && iNextObject instanceof CallerHandler) {
052: ((CallerHandler) iNextObject).setBackObject(iCurrentObject);
053: }
054:
055: // SHOW THE FORM
056: ObjectContext.getInstance().show(iNextObject, iPosition);
057: }
058:
059: public void onAfterActionExecution(Object iContent,
060: SchemaElement iAction) {
061: Class<? extends Object> nextClass = (Class<? extends Object>) iAction
062: .getFeature(FlowAspectAbstract.ASPECT_NAME,
063: FlowActionFeatures.NEXT);
064:
065: if (nextClass != null) {
066: String nextPosition = (String) iAction.getFeature(
067: FlowAspectAbstract.ASPECT_NAME,
068: FlowActionFeatures.POSITION);
069: boolean setBack = (Boolean) iAction.getFeature(
070: FlowAspectAbstract.ASPECT_NAME,
071: FlowActionFeatures.BACK);
072: forward(iContent, nextClass, nextPosition, setBack);
073: }
074: }
075:
076: public boolean onBeforeActionExecution(Object content,
077: SchemaElement action) {
078: return true;
079: }
080:
081: public Object onBeforeFieldRead(Object content, SchemaField field,
082: Object currentValue) {
083: return currentValue;
084: }
085:
086: public void onFieldRefresh(SessionInfo session, Object content,
087: SchemaField field) {
088: }
089:
090: public Object onBeforeFieldWrite(Object content, SchemaField field,
091: Object currentValue) {
092: return currentValue;
093: }
094:
095: public Object onAfterFieldWrite(Object content, SchemaField field,
096: Object currentValue) {
097: return currentValue;
098: }
099:
100: public Object onAfterFieldRead(Object content, SchemaField field,
101: Object currentValue) {
102: return currentValue;
103: }
104: }
|