|
I wanted to load navigation rules at run-time rather than
load time for my application.. after downloading the latest nightly build (8th
Aug) , I found that although runtimeConfig was getting the new navigation
rules, somehow they were not getting used. Upon further investigation I found
that NavigationHandlerImpl does not reload the rules if they after modified
after load time. Thus no matter how many changes I did to runtimeConfig, they
were not reflected in the system. In order to rectify this, I added a boolean to
runtimeConfig called changed, and made NavigationHandlerImpl lookup that boolean
to decide whether to reload the rules or not. Now I am able to modify RuntimeConfig,
and the navigation rules get added to the navigation handler. Attached are the patches to the two files:
RuntimeConfig.java and NavigationHandlerImpl.java Please let me know if you do accept them. Rahul |
Index:
C:/home/downloads/myfaces-current/impl/src/java/org/apache/myfaces/application/NavigationHandlerImpl.java
===================================================================
---
C:/home/downloads/myfaces-current/impl/src/java/org/apache/myfaces/application/NavigationHandlerImpl.java
(revision 231142)
+++
C:/home/downloads/myfaces-current/impl/src/java/org/apache/myfaces/application/NavigationHandlerImpl.java
(working copy)
@@ -196,15 +196,16 @@
private Map getNavigationCases(FacesContext facesContext)
{
- if (_navigationCases == null)
+ ExternalContext externalContext = facesContext.getExternalContext();
+ RuntimeConfig runtimeConfig =
RuntimeConfig.getCurrentInstance(externalContext);
+ boolean change = runtimeConfig.isChanged();
+ if (_navigationCases == null || change)
{
synchronized(this)
{
- if (_navigationCases == null)
+ if (_navigationCases == null || change)
{
- ExternalContext externalContext =
facesContext.getExternalContext();
- RuntimeConfig runtimeConfig =
RuntimeConfig.getCurrentInstance(externalContext);
-
+ runtimeConfig.setChanged(false);
Collection rules = runtimeConfig.getNavigationRules();
int rulesSize = rules.size();
Map cases = new
HashMap(HashMapUtils.calcCapacity(rulesSize));
Index:
C:/home/downloads/myfaces-current/impl/src/java/org/apache/myfaces/config/RuntimeConfig.java
===================================================================
---
C:/home/downloads/myfaces-current/impl/src/java/org/apache/myfaces/config/RuntimeConfig.java
(revision 231142)
+++
C:/home/downloads/myfaces-current/impl/src/java/org/apache/myfaces/config/RuntimeConfig.java
(working copy)
@@ -37,8 +37,8 @@
private Collection _navigationRules = new ArrayList();
private Map _managedBeans = new HashMap();
+ private boolean _changed = false;
-
public static RuntimeConfig getCurrentInstance(ExternalContext
externalContext)
{
RuntimeConfig runtimeConfig
@@ -78,4 +78,12 @@
{
_managedBeans.put(name, managedBean);
}
+
+ public boolean isChanged() {
+ return _changed;
+ }
+
+ public void setChanged(boolean _changed) {
+ this._changed = _changed;
+ }
}

