View Javadoc
1   package org.andromda.cartridges.jsf.metafacades;
2   
3   import org.andromda.cartridges.jsf.JSFGlobals;
4   import org.andromda.utils.StringUtilsHelper;
5   
6   /**
7    * MetafacadeLogic implementation for org.andromda.cartridges.jsf.metafacades.JSFEvent.
8    *
9    * @see org.andromda.cartridges.jsf.metafacades.JSFEvent
10   */
11  public class JSFEventLogicImpl
12      extends JSFEventLogic
13  {
14      private static final long serialVersionUID = 34L;
15      /**
16       * @param metaObject
17       * @param context
18       */
19      public JSFEventLogicImpl(Object metaObject, String context)
20      {
21          super(metaObject, context);
22      }
23  
24      /**
25       * @return triggerKey
26       * @see org.andromda.cartridges.jsf.metafacades.JSFEvent#getMessageKey()
27       */
28      protected String handleGetMessageKey()
29      {
30          String triggerKey = StringUtilsHelper.toResourceMessageKey(getName());
31          if (!this.isNormalizeMessages())
32          {
33              final JSFAction action = (JSFAction)this.getAction();
34              if (action != null)
35              {
36                  final JSFView view = (JSFView)action.getInput();
37                  if (view != null)
38                  {
39                      triggerKey = view.getMessageKey() + '.' + triggerKey;
40                  }
41              }
42          }
43          return triggerKey;
44      }
45  
46      /**
47       * @return StringUtilsHelper.toPhrase(this.getName())
48       * @see org.andromda.cartridges.jsf.metafacades.JSFEvent#getMessageValue()
49       */
50      protected String handleGetMessageValue()
51      {
52          return StringUtilsHelper.toPhrase(this.getName());
53      }
54  
55      /**
56       * @return "Reset"
57       * @see org.andromda.cartridges.jsf.metafacades.JSFEvent#getResetMessageValue()
58       */
59      protected String handleGetResetMessageValue()
60      {
61          return "Reset";
62      }
63  
64      /**
65       * @return getMessageKey() + ".reset.message"
66       * @see org.andromda.cartridges.jsf.metafacades.JSFEvent#getResetMessageKey()
67       */
68      protected String handleGetResetMessageKey()
69      {
70          return this.getMessageKey() + ".reset.message";
71      }
72  
73      /**
74       * Indicates whether or not we should normalize messages.
75       * @return normalizeMessages true/false
76       */
77      private boolean isNormalizeMessages()
78      {
79          final String normalizeMessages = (String)getConfiguredProperty(JSFGlobals.NORMALIZE_MESSAGES);
80          return Boolean.valueOf(normalizeMessages).booleanValue();
81      }
82  }