[prettyfaces] r460 committed - Updated generation of NavigationCase objects

1 view
Skip to first unread message

prett...@googlecode.com

unread,
Oct 25, 2010, 4:43:19 PM10/25/10
to prettyfac...@googlegroups.com
Revision: 460
Author: lincolnbaxter
Date: Mon Oct 25 13:42:08 2010
Log: Updated generation of NavigationCase objects
http://code.google.com/p/prettyfaces/source/detail?r=460

Modified:

/prettyfaces/trunk/impl-jsf2/src/main/java/com/ocpsoft/pretty/faces/application/PrettyNavigationHandler.java

=======================================
---
/prettyfaces/trunk/impl-jsf2/src/main/java/com/ocpsoft/pretty/faces/application/PrettyNavigationHandler.java
Wed Aug 25 23:21:50 2010
+++
/prettyfaces/trunk/impl-jsf2/src/main/java/com/ocpsoft/pretty/faces/application/PrettyNavigationHandler.java
Mon Oct 25 13:42:08 2010
@@ -32,77 +32,82 @@
*/
public class PrettyNavigationHandler extends ConfigurableNavigationHandler
{
- private static final Log log =
LogFactory.getLog(PrettyNavigationHandler.class);
-
- private final ConfigurableNavigationHandler parent;
- private final PrettyRedirector pr = PrettyRedirector.getInstance();
-
- public PrettyNavigationHandler(final ConfigurableNavigationHandler
parent)
- {
- this.parent = parent;
- }
-
- @Override
- public void handleNavigation(final FacesContext context, final String
fromAction, final String outcome)
- {
- log.debug("Navigation requested: fromAction [" + fromAction + "],
outcome [" + outcome + "]");
- if (!pr.redirect(context, outcome))
- {
- log.debug("Not a PrettyFaces navigation string - passing
control to default nav-handler");
- PrettyContext prettyContext =
PrettyContext.getCurrentInstance();
- prettyContext.setInNavigation(true);
-
- String originalViewId = context.getViewRoot().getViewId();
- parent.handleNavigation(context, fromAction, outcome);
- String newViewId = context.getViewRoot().getViewId();
-
- /*
- * Navigation is complete if the viewId has not changed or the
- * response is complete
- */
- if (true == context.getResponseComplete() ||
originalViewId.equals(newViewId))
- {
-
- prettyContext.setInNavigation(false);
- }
- }
-
- }
-
- @Override
- public NavigationCase getNavigationCase(final FacesContext context,
final String fromAction, final String outcome)
- {
- PrettyContext prettyContext = PrettyContext.getCurrentInstance();
- PrettyConfig config = prettyContext.getConfig();
- if (outcome != null &&
outcome.startsWith(PrettyContext.PRETTY_PREFIX) &&
config.isMappingId(outcome))
- {
- /*
- * FIXME this will not work with dynamic view IDs... figure out
- * another solution
- * (<rewrite-view>/faces/views/myview.xhtml</rewrite-view> ?
- * For now. Do not support it.
- */
- String viewId = config.getMappingById(outcome).getViewId();
- String normalizedViewId =
FacesNavigationURLCanonicalizer.normalizeRequestURI(context, viewId);
- NavigationCase navigationCase =
parent.getNavigationCase(context, fromAction, normalizedViewId);
- return navigationCase;
- }
- else
- {
- NavigationCase navigationCase =
parent.getNavigationCase(context, fromAction, outcome);
- return navigationCase;
- }
- }
-
- @Override
- public Map<String, Set<NavigationCase>> getNavigationCases()
- {
- return parent.getNavigationCases();
- }
-
- @Override
- public void performNavigation(final String outcome)
- {
- parent.performNavigation(outcome);
- }
-}
+ private static final Log log =
LogFactory.getLog(PrettyNavigationHandler.class);
+
+ private final ConfigurableNavigationHandler parent;
+ private final PrettyRedirector pr = PrettyRedirector.getInstance();
+
+ public PrettyNavigationHandler(final ConfigurableNavigationHandler
parent)
+ {
+ this.parent = parent;
+ }
+
+ @Override
+ public void handleNavigation(final FacesContext context, final String
fromAction, final String outcome)
+ {
+ log.debug("Navigation requested: fromAction [" + fromAction + "],
outcome [" + outcome + "]");
+ if (!pr.redirect(context, outcome))
+ {
+ log.debug("Not a PrettyFaces navigation string - passing control
to default nav-handler");
+ PrettyContext prettyContext = PrettyContext.getCurrentInstance();
+ prettyContext.setInNavigation(true);
+
+ String originalViewId = context.getViewRoot().getViewId();
+ parent.handleNavigation(context, fromAction, outcome);
+ String newViewId = context.getViewRoot().getViewId();
+
+ /*
+ * Navigation is complete if the viewId has not changed or the
response
+ * is complete
+ */
+ if ((true == context.getResponseComplete()) ||
originalViewId.equals(newViewId))
+ {
+
+ prettyContext.setInNavigation(false);
+ }
+ }
+
+ }
+
+ @Override
+ public NavigationCase getNavigationCase(final FacesContext context,
final String fromAction, final String outcome)
+ {
+ PrettyContext prettyContext = PrettyContext.getCurrentInstance();
+ PrettyConfig config = prettyContext.getConfig();
+ if ((outcome != null) && PrettyContext.PRETTY_PREFIX.equals(outcome))
+ {
+ String viewId = context.getViewRoot().getViewId();
+ NavigationCase navigationCase = parent.getNavigationCase(context,
fromAction, viewId);
+ return navigationCase;
+ }
+ else if ((outcome != null) &&
outcome.startsWith(PrettyContext.PRETTY_PREFIX) &&
config.isMappingId(outcome))
+ {
+ /*
+ * FIXME this will not work with dynamic view IDs... figure out
another
+ * solution
(<rewrite-view>/faces/views/myview.xhtml</rewrite-view> ?
+ * For now. Do not support it.
+ */
+ String viewId = config.getMappingById(outcome).getViewId();
+ String normalizedViewId =
FacesNavigationURLCanonicalizer.normalizeRequestURI(context, viewId);
+ NavigationCase navigationCase = parent.getNavigationCase(context,
fromAction, normalizedViewId);
+ return navigationCase;
+ }
+ else
+ {
+ NavigationCase navigationCase = parent.getNavigationCase(context,
fromAction, outcome);
+ return navigationCase;
+ }
+ }
+
+ @Override
+ public Map<String, Set<NavigationCase>> getNavigationCases()
+ {
+ return parent.getNavigationCases();
+ }
+
+ @Override
+ public void performNavigation(final String outcome)
+ {
+ parent.performNavigation(outcome);
+ }
+}

Reply all
Reply to author
Forward
0 new messages