1
package org.hisp.dhis.webwork.interceptor;
3
import java.util.HashMap;
6
import ognl.NoSuchPropertyException;
9
import org.hisp.dhis.options.datadictionary.DataDictionaryModeManager;
11
import com.opensymphony.xwork.Action;
12
import com.opensymphony.xwork.ActionInvocation;
13
import com.opensymphony.xwork.interceptor.AroundInterceptor;
15
public class WebWorkDataDictionaryModeInterceptor
16
extends AroundInterceptor
18
private static final String KEY_DATA_DICTIONARY_MODE = "dataDictionaryMode";
20
// -------------------------------------------------------------------------
22
// -------------------------------------------------------------------------
24
private DataDictionaryModeManager dataDictionaryModeManager;
26
public void setDataDictionaryModeManager( DataDictionaryModeManager dataDictionaryModeManager )
28
this.dataDictionaryModeManager = dataDictionaryModeManager;
31
// -------------------------------------------------------------------------
32
// AroundInterceptor implementation
33
// -------------------------------------------------------------------------
35
protected void before( ActionInvocation invocation )
38
Action action = (Action) invocation.getAction();
40
String currentMode = dataDictionaryModeManager.getCurrentDataDictionaryMode();
42
// ---------------------------------------------------------------------
43
// Make the objects available for web templates
44
// ---------------------------------------------------------------------
46
Map<String, Object> templateMap = new HashMap<String, Object>( 1 );
48
templateMap.put( KEY_DATA_DICTIONARY_MODE, currentMode );
50
invocation.getStack().push( templateMap );
52
// ---------------------------------------------------------------------
53
// Set the objects in the action class if the properties exist
54
// ---------------------------------------------------------------------
56
Map<?, ?> contextMap = invocation.getInvocationContext().getContextMap();
60
Ognl.setValue( KEY_DATA_DICTIONARY_MODE, contextMap, action, currentMode );
62
catch ( NoSuchPropertyException e )
67
protected void after( ActionInvocation invocation, String result )