Author: pete.muir(a)jboss.org
Date: 2008-05-14 12:56:29 -0400 (Wed, 14 May 2008)
New Revision: 8192
Added:
trunk/src/main/org/jboss/seam/jsf/DelegatingFacesContext.java
Modified:
trunk/src/mail/org/jboss/seam/mail/ui/context/MailFacesContextImpl.java
Log:
factor out a delegating faces context utility class
Modified: trunk/src/mail/org/jboss/seam/mail/ui/context/MailFacesContextImpl.java
===================================================================
--- trunk/src/mail/org/jboss/seam/mail/ui/context/MailFacesContextImpl.java 2008-05-14
14:13:29 UTC (rev 8191)
+++ trunk/src/mail/org/jboss/seam/mail/ui/context/MailFacesContextImpl.java 2008-05-14
16:56:29 UTC (rev 8192)
@@ -1,23 +1,15 @@
package org.jboss.seam.mail.ui.context;
-import java.util.Iterator;
-
-import javax.el.ELContext;
-import javax.faces.application.Application;
-import javax.faces.application.FacesMessage;
-import javax.faces.application.FacesMessage.Severity;
-import javax.faces.component.UIViewRoot;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseStream;
import javax.faces.context.ResponseWriter;
-import javax.faces.render.RenderKit;
+import org.jboss.seam.jsf.DelegatingFacesContext;
-public class MailFacesContextImpl extends FacesContext
+
+public class MailFacesContextImpl extends DelegatingFacesContext
{
- private FacesContext delegate;
private ExternalContext externalContext;
private ResponseWriter responseWriter;
@@ -27,132 +19,31 @@
this(delegate, null);
}
- public MailFacesContextImpl(FacesContext facesContext, String urlBase)
+ public MailFacesContextImpl(FacesContext delegate, String urlBase)
{
- this.delegate = facesContext;
- externalContext = new MailExternalContextImpl(delegate.getExternalContext(),
urlBase);
- responseWriter = new MailResponseWriter(delegate.getResponseWriter(),
delegate.getResponseWriter().getContentType());
+ super(delegate);
+ externalContext = new MailExternalContextImpl(getDelegate().getExternalContext(),
urlBase);
+ responseWriter = new MailResponseWriter(getDelegate().getResponseWriter(),
getDelegate().getResponseWriter().getContentType());
}
@Override
- public void addMessage(String clientId, FacesMessage message)
- {
- delegate.addMessage(clientId, message);
- }
-
- @Override
- public Application getApplication()
- {
- return delegate.getApplication();
- }
-
- @Override
- public Iterator getClientIdsWithMessages()
- {
- return delegate.getClientIdsWithMessages();
- }
-
- @Override
public ExternalContext getExternalContext()
{
return externalContext;
}
@Override
- public Severity getMaximumSeverity()
- {
- return delegate.getMaximumSeverity();
- }
-
- @Override
- public Iterator getMessages()
- {
- return delegate.getMessages();
- }
-
- @Override
- public Iterator getMessages(String clientId)
- {
- return delegate.getMessages(clientId);
- }
-
- @Override
- public RenderKit getRenderKit()
- {
- return delegate.getRenderKit();
- }
-
- @Override
- public boolean getRenderResponse()
- {
- return delegate.getRenderResponse();
- }
-
- @Override
- public boolean getResponseComplete()
- {
- return delegate.getResponseComplete();
- }
-
- @Override
- public ResponseStream getResponseStream()
- {
- return delegate.getResponseStream();
- }
-
- @Override
public ResponseWriter getResponseWriter()
{
return responseWriter;
}
@Override
- public UIViewRoot getViewRoot()
- {
- return delegate.getViewRoot();
- }
-
- @Override
- public void release()
- {
- delegate.release();
- }
-
- @Override
- public void renderResponse()
- {
- delegate.renderResponse();
- }
-
- @Override
- public void responseComplete()
- {
- delegate.responseComplete();
- }
-
- @Override
- public void setResponseStream(ResponseStream responseStream)
- {
- delegate.setResponseStream(responseStream);
- }
-
- @Override
public void setResponseWriter(ResponseWriter responseWriter)
{
this.responseWriter = responseWriter;
}
-
- @Override
- public void setViewRoot(UIViewRoot root)
- {
- delegate.setViewRoot(root);
- }
- public FacesContext getDelegate()
- {
- return delegate;
- }
-
public static void start(String urlBase)
{
FacesContext mailFacesContext = new MailFacesContextImpl(getCurrentInstance(),
urlBase);
@@ -168,12 +59,5 @@
}
}
-
- @Override
- public ELContext getELContext()
- {
- return delegate.getELContext();
- }
-
}
Added: trunk/src/main/org/jboss/seam/jsf/DelegatingFacesContext.java
===================================================================
--- trunk/src/main/org/jboss/seam/jsf/DelegatingFacesContext.java
(rev 0)
+++ trunk/src/main/org/jboss/seam/jsf/DelegatingFacesContext.java 2008-05-14 16:56:29 UTC
(rev 8192)
@@ -0,0 +1,165 @@
+package org.jboss.seam.jsf;
+
+import java.util.Iterator;
+
+import javax.el.ELContext;
+import javax.faces.application.Application;
+import javax.faces.application.FacesMessage;
+import javax.faces.application.FacesMessage.Severity;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseStream;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.RenderKit;
+
+/**
+ * Implementation of FacesContext that delegates all calls.
+ *
+ * Further, it exposes {@link #setCurrentInstance(FacesContext)} as a public
+ * method
+ *
+ * @author Pete Muir
+ *
+ */
+public class DelegatingFacesContext extends FacesContext
+{
+
+ private FacesContext delegate;
+
+ public DelegatingFacesContext(FacesContext delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public void addMessage(String clientId, FacesMessage message)
+ {
+ delegate.addMessage(clientId, message);
+ }
+
+ @Override
+ public Application getApplication()
+ {
+ return delegate.getApplication();
+ }
+
+ @Override
+ public Iterator getClientIdsWithMessages()
+ {
+ return delegate.getClientIdsWithMessages();
+ }
+
+ @Override
+ public ExternalContext getExternalContext()
+ {
+ return delegate.getExternalContext();
+ }
+
+ @Override
+ public Severity getMaximumSeverity()
+ {
+ return delegate.getMaximumSeverity();
+ }
+
+ @Override
+ public Iterator getMessages()
+ {
+ return delegate.getMessages();
+ }
+
+ @Override
+ public Iterator getMessages(String clientId)
+ {
+ return delegate.getMessages(clientId);
+ }
+
+ @Override
+ public RenderKit getRenderKit()
+ {
+ return delegate.getRenderKit();
+ }
+
+ @Override
+ public boolean getRenderResponse()
+ {
+ return delegate.getRenderResponse();
+ }
+
+ @Override
+ public boolean getResponseComplete()
+ {
+ return delegate.getResponseComplete();
+ }
+
+ @Override
+ public ResponseStream getResponseStream()
+ {
+ return delegate.getResponseStream();
+ }
+
+ @Override
+ public ResponseWriter getResponseWriter()
+ {
+ return delegate.getResponseWriter();
+ }
+
+ @Override
+ public UIViewRoot getViewRoot()
+ {
+ return delegate.getViewRoot();
+ }
+
+ @Override
+ public void release()
+ {
+ delegate.release();
+ }
+
+ @Override
+ public void renderResponse()
+ {
+ delegate.renderResponse();
+ }
+
+ @Override
+ public void responseComplete()
+ {
+ delegate.responseComplete();
+ }
+
+ @Override
+ public void setResponseStream(ResponseStream responseStream)
+ {
+ delegate.setResponseStream(responseStream);
+ }
+
+ @Override
+ public void setResponseWriter(ResponseWriter responseWriter)
+ {
+ delegate.setResponseWriter(responseWriter);
+ }
+
+ @Override
+ public void setViewRoot(UIViewRoot root)
+ {
+ delegate.setViewRoot(root);
+ }
+
+ public FacesContext getDelegate()
+ {
+ return delegate;
+ }
+
+ @Override
+ public ELContext getELContext()
+ {
+ return delegate.getELContext();
+ }
+
+ public static void setCurrentInstance(FacesContext context)
+ {
+ FacesContext.setCurrentInstance(context);
+ }
+
+}
Property changes on: trunk/src/main/org/jboss/seam/jsf/DelegatingFacesContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Show replies by date