You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shale.apache.org by cr...@apache.org on 2006/09/01 21:47:07 UTC
svn commit: r439437 - in /shale/sandbox/shale-dialog2: pom.xml
src/main/java/org/apache/shale/dialog2/faces/Dialog2NavigationHandler.java
src/main/java/org/apache/shale/dialog2/faces/Dialog2PhaseListener.java
Author: craigmcc
Date: Fri Sep 1 12:47:07 2006
New Revision: 439437
URL: http://svn.apache.org/viewvc?rev=439437&view=rev
Log:
Add some basic debug logging that can be enabled to examine the behavior
of the NavigationHandler and PhaseListener implementations.
Modified:
shale/sandbox/shale-dialog2/pom.xml
shale/sandbox/shale-dialog2/src/main/java/org/apache/shale/dialog2/faces/Dialog2NavigationHandler.java
shale/sandbox/shale-dialog2/src/main/java/org/apache/shale/dialog2/faces/Dialog2PhaseListener.java
Modified: shale/sandbox/shale-dialog2/pom.xml
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-dialog2/pom.xml?rev=439437&r1=439436&r2=439437&view=diff
==============================================================================
--- shale/sandbox/shale-dialog2/pom.xml (original)
+++ shale/sandbox/shale-dialog2/pom.xml Fri Sep 1 12:47:07 2006
@@ -34,6 +34,12 @@
<dependencies>
<dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
Modified: shale/sandbox/shale-dialog2/src/main/java/org/apache/shale/dialog2/faces/Dialog2NavigationHandler.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-dialog2/src/main/java/org/apache/shale/dialog2/faces/Dialog2NavigationHandler.java?rev=439437&r1=439436&r2=439437&view=diff
==============================================================================
--- shale/sandbox/shale-dialog2/src/main/java/org/apache/shale/dialog2/faces/Dialog2NavigationHandler.java (original)
+++ shale/sandbox/shale-dialog2/src/main/java/org/apache/shale/dialog2/faces/Dialog2NavigationHandler.java Fri Sep 1 12:47:07 2006
@@ -20,6 +20,8 @@
import javax.faces.application.ViewHandler;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.shale.dialog2.Constants;
import org.apache.shale.dialog2.DialogContext;
import org.apache.shale.dialog2.DialogContextManager;
@@ -45,11 +47,21 @@
* @param original Original NavigationHandler
*/
public Dialog2NavigationHandler(NavigationHandler original) {
+ if (log.isInfoEnabled()) {
+ log.info("Instantiating Dialog2NavigationHandler (wrapping instance '"
+ + original + "')");
+ }
this.original = original;
}
- // ------------------------------------------------------ DialogContext Variables
+ // ------------------------------------------------- DialogContext Variables
+
+
+ /**
+ * <p>The <code>Log</code> instance for this class.</p>
+ */
+ private Log log = LogFactory.getLog(Dialog2NavigationHandler.class);
/**
@@ -90,6 +102,13 @@
public void handleNavigation(FacesContext context, String fromAction,
String outcome) {
+ if (log.isTraceEnabled()) {
+ log.trace("handleNavigation(context='"
+ + context + "', fromAction='"
+ + fromAction + "', outcome='"
+ + outcome + "')");
+ }
+
String viewId = null;
DialogContext dcontext = (DialogContext)
context.getExternalContext().getRequestMap().get(Constants.CONTEXT_BEAN);
@@ -97,12 +116,25 @@
if ((outcome != null) && outcome.startsWith(Constants.DIALOG_PREFIX)) {
dcontext = create(context, outcome.substring(Constants.DIALOG_PREFIX.length()));
viewId = advance(context, dcontext, null);
+ if (log.isDebugEnabled()) {
+ log.debug("Starting dialog '"
+ + outcome.substring(Constants.DIALOG_PREFIX.length())
+ + "' for FacesContext instance '"
+ + context + "' with navigation to viewId '"
+ + viewId + "'");
+ }
} else {
original.handleNavigation(context, fromAction, outcome);
return;
}
} else {
viewId = advance(context, dcontext, outcome);
+ if (log.isDebugEnabled()) {
+ log.debug("Advancing dialog '"
+ + dcontext.getName() + "' for FacesContext '"
+ + context + "' with navigation to viewId '"
+ + viewId + "'");
+ }
}
navigate(context, viewId);
Modified: shale/sandbox/shale-dialog2/src/main/java/org/apache/shale/dialog2/faces/Dialog2PhaseListener.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-dialog2/src/main/java/org/apache/shale/dialog2/faces/Dialog2PhaseListener.java?rev=439437&r1=439436&r2=439437&view=diff
==============================================================================
--- shale/sandbox/shale-dialog2/src/main/java/org/apache/shale/dialog2/faces/Dialog2PhaseListener.java (original)
+++ shale/sandbox/shale-dialog2/src/main/java/org/apache/shale/dialog2/faces/Dialog2PhaseListener.java Fri Sep 1 12:47:07 2006
@@ -21,6 +21,8 @@
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.shale.dialog2.Constants;
import org.apache.shale.dialog2.DialogContext;
import org.apache.shale.dialog2.DialogContextManager;
@@ -34,6 +36,31 @@
public final class Dialog2PhaseListener implements PhaseListener {
+ // ------------------------------------------------------------ Constructors
+
+
+ /**
+ * <p>Creates a new instance of Dialog2PhaseListener.</p>
+ */
+ public Dialog2PhaseListener() {
+ if (log.isInfoEnabled()) {
+ log.info("Instantiating Dialog2PhaseListener()");
+ }
+ }
+
+
+ // ------------------------------------------------------ Instance Variables
+
+
+ /**
+ * <p>The <code>Log</code> instance for this class.</p>
+ */
+ private Log log = LogFactory.getLog(Dialog2PhaseListener.class);
+
+
+ // --------------------------------------------------- PhaseListener Methods
+
+
/**
* <p>Return the phase identifier we are interested in.</p>
*/
@@ -52,6 +79,11 @@
*/
public void afterPhase(PhaseEvent event) {
+ if (log.isTraceEnabled()) {
+ log.trace("afterPhase(phaseId='" + event.getPhaseId()
+ + "',facesContext='" + event.getFacesContext() + "')");
+ }
+
if (PhaseId.RESTORE_VIEW.equals(event.getPhaseId())) {
FacesContext context = event.getFacesContext();
String id = (String)
@@ -69,6 +101,11 @@
if (dcontext == null) {
return;
}
+ if (log.isDebugEnabled()) {
+ log.debug("afterPhase() restoring dialog context with id '"
+ + id + "' for FacesContext instance '"
+ + context + "'");
+ }
context.getExternalContext().getRequestMap().put(Constants.CONTEXT_BEAN, dcontext);
}
@@ -83,14 +120,30 @@
*/
public void beforePhase(PhaseEvent event) {
+ if (log.isTraceEnabled()) {
+ log.trace("beforePhase(phaseId='" + event.getPhaseId()
+ + "',facesContext='" + event.getFacesContext() + "')");
+ }
+
if (PhaseId.RENDER_RESPONSE.equals(event.getPhaseId())) {
FacesContext context = event.getFacesContext();
- DialogContext instance = (DialogContext)
+ DialogContext dcontext = (DialogContext)
context.getExternalContext().getRequestMap().get(Constants.CONTEXT_BEAN);
Map map = context.getViewRoot().getAttributes();
- if ((instance != null) && instance.isActive()) {
- map.put(Constants.CONTEXT_ID_ATTR, instance);
+ if ((dcontext != null) && dcontext.isActive()) {
+ if (log.isDebugEnabled()) {
+ log.debug("beforePhase() saving dialog context id '"
+ + dcontext.getId()
+ + "' for FacesContext instance '"
+ + context + "'");
+ }
+ map.put(Constants.CONTEXT_ID_ATTR, dcontext);
} else {
+ if (log.isTraceEnabled()) {
+ log.trace("beforePhase() erasing dialog context id "
+ + " for FacesContext instance '"
+ + context + "'");
+ }
map.remove(Constants.CONTEXT_ID_ATTR);
}
}