JBoss Ajax4JSF SVN: r68 - trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo.
by ajax4jsf-svn-commits@lists.jboss.org
Author: dbiatenia
Date: 2007-04-11 14:21:08 -0400 (Wed, 11 Apr 2007)
New Revision: 68
Added:
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/GenerateTestMojo.java
Log:
mojo modification for tests generation purpose
Added: trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/GenerateTestMojo.java
===================================================================
--- trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/GenerateTestMojo.java (rev 0)
+++ trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/GenerateTestMojo.java 2007-04-11 18:21:08 UTC (rev 68)
@@ -0,0 +1,152 @@
+package org.ajax4jsf.builder.mojo;
+
+import org.ajax4jsf.builder.config.BuilderConfig;
+import org.ajax4jsf.builder.generator.ComponentTestGenerator;
+import org.ajax4jsf.builder.generator.TagTestGenerator;
+import org.ajax4jsf.builder.maven.MavenLogger;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.velocity.Template;
+
+/**
+ *
+ * @author dbiatenia
+ * @goal generate-tests
+ * @requiresDependencyResolution test
+ * @phase generate-test-sources
+ * @execute phase="test-compile"
+ */
+public class GenerateTestMojo extends GenerateMojo{
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ getLog().debug("GenerateTestMojo tests");
+ if (null != executedProject) {
+ Taglib taglib = checkLibraryConfig();
+ // compile goal executed
+ try {
+ // Parse config files.
+ ClassLoader generatiorLoader = createProjectClassLoader(executedProject);
+ BuilderConfig config = createConfig(generatiorLoader);
+ MavenLogger mavenLogger = new MavenLogger(getLog());
+ // TODO - parse sources by qdox for JavaDoc comments ?
+ // GenerateMojo components.
+/*
+ ComponentGenerator compGenerator = new ComponentGenerator(this,
+ mavenLogger);
+ compGenerator.createFiles(config);
+*/
+ // GenerateMojo renderers
+/*
+ RendererGenerator rendererGenerator = new RendererGenerator(
+ this, mavenLogger);
+ rendererGenerator.setSrcDir(templatesDirectory);
+ rendererGenerator.createFiles(config);
+*/
+ // GenerateMojo component test
+ ComponentTestGenerator componentTestGenerator = new ComponentTestGenerator(this, mavenLogger);
+ componentTestGenerator.setDestDir(outputTestsDirectory);
+ componentTestGenerator.createFiles(config);
+
+ // GenerateMojo tags
+/*
+ TagGenerator tagGenerator = new TagGenerator(this, mavenLogger);
+ tagGenerator.createFiles(config);
+*/
+ // GenerateMojo tag test
+ TagTestGenerator tagTestGenerator = new TagTestGenerator(this, mavenLogger);
+ tagTestGenerator.setDestDir(outputTestsDirectory);
+ tagTestGenerator.createFiles(config);
+
+ // GenerateMojo tag handlers
+/*
+ TagHandlerGenerator tagHandlerGenerator = new TagHandlerGenerator(
+ this, mavenLogger);
+ tagHandlerGenerator.createFiles(config);
+ //Generate listeners
+ ListenerGenerator listenerGenerator = new ListenerGenerator(this, mavenLogger);
+ listenerGenerator.createFiles(config);
+*/
+/*
+ JSFGeneratorConfiguration resourcesConfiguration = new JSFGeneratorConfiguration() {
+
+ public ClassLoader getClassLoader() {
+ return createProjectClassLoader(executedProject);
+ }
+
+ public File getDestDir() {
+ return outputResourcesDirectory;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public Template getTemplate(String name) throws GeneratorException {
+ return GenerateTestMojo.this.getTemplate(name);
+ }
+
+ public String getTemplatesPath() {
+ return GenerateTestMojo.this.getTemplatesPath();
+ }
+
+ };
+ // GenerateMojo faces-config
+ FacesConfigGenerator configGenerator = new FacesConfigGenerator(
+ resourcesConfiguration, mavenLogger);
+ configGenerator.setInclude(facesConfigInclude);
+ configGenerator.setFacesconfig(new File(
+ outputResourcesDirectory, "META-INF/faces-config.xml"));
+ RenderKitBean renderKitBean = configGenerator.createRenderKit();
+ renderKitBean.setRenderkitid("HTML_BASIC");
+ configGenerator.createFiles(config);
+ // GenerateMojo JSP taglib
+ if (null != taglib) {
+ TaglibGenerator taglibGenerator = new TaglibGenerator(
+ resourcesConfiguration, mavenLogger);
+ taglibGenerator.setUri(taglib.getUri());
+ taglibGenerator.setShortname(taglib.getShortName());
+ taglibGenerator.setListenerclass(taglib.getListenerClass());
+ taglibGenerator.setDisplayname(taglib.getDisplayName());
+ taglibGenerator.setListenerclass(taglib.getListenerClass());
+ taglibGenerator.setValidatorclass(taglib.getValidatorClass());
+ taglibGenerator.setTlibversion(taglib.getTlibVersion());
+ taglibGenerator.setJspversion(taglib.getJspVersion());
+ taglibGenerator.setInclude(taglibInclude);
+ taglibGenerator.setTaglib(new File(
+ outputResourcesDirectory, "META-INF/"+taglib.getShortName()
+ + ".tld"));
+ taglibGenerator.createFiles(config);
+ // GenerateMojo Facelets taglib
+ FaceletsTaglibGenerator faceletsTaglibGenerator = new FaceletsTaglibGenerator(
+ resourcesConfiguration, mavenLogger);
+ faceletsTaglibGenerator.setUri(taglib.getUri());
+ faceletsTaglibGenerator.setShortname(taglib.getShortName());
+ faceletsTaglibGenerator.setInclude(taglibInclude);
+ faceletsTaglibGenerator.setTaglib(new File(
+ outputResourcesDirectory, "META-INF/"+taglib.getShortName()
+ + ".taglib.xml"));
+ faceletsTaglibGenerator.createFiles(config);
+ }
+ // Generate resources configuration file resources-config.xml
+ // for all images/scripts/css...
+ // Add generated sources and resources to project
+*/
+// project.addCompileSourceRoot(outputJavaDirectory.getPath());
+ project.addTestCompileSourceRoot(outputTestsDirectory.getPath());
+/*
+ Resource resource = new Resource();
+ resource.setDirectory(outputResourcesDirectory.getPath());
+// resource.setTargetPath("META-INF");
+ project.addResource(resource);
+*/
+ } catch (Exception e) {
+ getLog().error("Error on generate component", e);
+ throw new MojoExecutionException(
+ "Error in component generation", e);
+ }
+ }
+
+ }
+
+}
Property changes on: trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/GenerateTestMojo.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
17 years, 8 months
JBoss Ajax4JSF SVN: r66 - in trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet: context and 1 other directories.
by ajax4jsf-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-04-11 12:04:01 -0400 (Wed, 11 Apr 2007)
New Revision: 66
Added:
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/PortletRequestWrapper.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/lifecycle/PortletLifecycle.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/lifecycle/PortletLifecycleFactory.java
Removed:
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/FacesPortlet.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ExternalContextImpl.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/lifecycle/LifecycleFactoryImpl.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/lifecycle/LifecycleImpl.java
Modified:
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/AjaxFacesPortlet.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextAttributesMap.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextConcatentedMap.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextMap.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ELContextImpl.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/EnumerationIterator.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextFactoryImpl.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextImpl.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextWrapper.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/PortletContextImpl.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ServletContextImpl.java
Log:
Continue portlet integration
Modified: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/AjaxFacesPortlet.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/AjaxFacesPortlet.java 2007-04-10 18:26:37 UTC (rev 65)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/AjaxFacesPortlet.java 2007-04-11 16:04:01 UTC (rev 66)
@@ -4,7 +4,6 @@
package org.ajax4jsf.portlet;
import java.io.IOException;
-
import javax.faces.FacesException;
import javax.faces.FactoryFinder;
import javax.faces.context.FacesContext;
@@ -21,7 +20,6 @@
import javax.portlet.PortletResponse;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -30,121 +28,142 @@
*
*/
public class AjaxFacesPortlet extends GenericPortlet {
+ private static final Log log = LogFactory.getLog(AjaxFacesPortlet.class);
- private static final Log log = LogFactory.getLog(AjaxFacesPortlet.class);
- /**
- * Stored portlet config.
- */
- private PortletConfig config;
+ /**
+ * Stored portlet config.
+ */
+ private PortletConfig config;
- private Lifecycle lifecycle;
+ private Lifecycle lifecycle;
- private FacesContextFactory facesContextFactory;
+ private FacesContextFactory facesContextFactory;
- /* (non-Javadoc)
- * @see javax.portlet.GenericPortlet#init(javax.portlet.PortletConfig)
- */
- public void init(PortletConfig config) throws PortletException {
- this.config = config;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Start portlet initialisation for "+config.getPortletName());
- }
- // get faces lifecycle instance
- LifecycleFactory factory = (LifecycleFactory) FactoryFinder
- .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
- String lifecycleId = config.getPortletContext().getInitParameter(
- FacesServlet.LIFECYCLE_ID_ATTR);
- if (null == lifecycleId) {
- lifecycleId = LifecycleFactory.DEFAULT_LIFECYCLE;
- }
- if(log.isDebugEnabled()){
- log.debug("Create instance of a JSF lifecycle "+lifecycleId);
- }
- lifecycle = factory.getLifecycle(lifecycleId);
- // get faces context factory instance
- facesContextFactory = (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
- } catch (FacesException e) {
- throw new PortletException("Initialization error", e);
- }
- super.init(config);
- if (log.isDebugEnabled()) {
- log.debug("Done portlet initialisation for "+config.getPortletName());
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.portlet.GenericPortlet#init(javax.portlet.PortletConfig)
+ */
+ public void init(PortletConfig config) throws PortletException {
+ this.config = config;
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Start portlet initialisation for "
+ + config.getPortletName());
+ }
+ // get faces lifecycle instance
+ LifecycleFactory factory = (LifecycleFactory) FactoryFinder
+ .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+ String lifecycleId = config.getPortletContext().getInitParameter(
+ FacesServlet.LIFECYCLE_ID_ATTR);
+ if (null == lifecycleId) {
+ lifecycleId = LifecycleFactory.DEFAULT_LIFECYCLE;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Create instance of a JSF lifecycle " + lifecycleId);
+ }
+ this.lifecycle = factory.getLifecycle(lifecycleId);
+ // get faces context factory instance
+ this.facesContextFactory = (FacesContextFactory) FactoryFinder
+ .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
+ } catch (FacesException e) {
+ throw new PortletException("Initialization error", e);
}
-
- /* (non-Javadoc)
- * @see javax.portlet.GenericPortlet#destroy()
- */
- public void destroy() {
- if (log.isDebugEnabled()) {
- log.debug("Destroy portlet "+this.config.getPortletName());
- }
- lifecycle = null;
- facesContextFactory = null;
- super.destroy();
+ super.init(config);
+ if (log.isDebugEnabled()) {
+ log.debug("Done portlet initialisation for "
+ + config.getPortletName());
}
+ }
- /* (non-Javadoc)
- * @see javax.portlet.GenericPortlet#processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse)
- */
- public void processAction(ActionRequest arg0, ActionResponse arg1)
- throws PortletException, IOException {
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.portlet.GenericPortlet#destroy()
+ */
+ public void destroy() {
+ if (log.isDebugEnabled()) {
+ log.debug("Destroy portlet " + this.config.getPortletName());
}
+ this.lifecycle = null;
+ this.facesContextFactory = null;
+ super.destroy();
+ }
-
- /* (non-Javadoc)
- * @see javax.portlet.GenericPortlet#doView(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
- */
- protected void doView(RenderRequest arg0, RenderResponse arg1)
- throws PortletException, IOException {
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.portlet.GenericPortlet#processAction(javax.portlet.ActionRequest,
+ * javax.portlet.ActionResponse)
+ */
+ public void processAction(ActionRequest arg0, ActionResponse arg1)
+ throws PortletException, IOException {
+ }
- /* (non-Javadoc)
- * @see javax.portlet.GenericPortlet#doEdit(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
- */
- protected void doEdit(RenderRequest arg0, RenderResponse arg1)
- throws PortletException, IOException {
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.portlet.GenericPortlet#doView(javax.portlet.RenderRequest,
+ * javax.portlet.RenderResponse)
+ */
+ protected void doView(RenderRequest arg0, RenderResponse arg1)
+ throws PortletException, IOException {
+ }
- /* (non-Javadoc)
- * @see javax.portlet.GenericPortlet#doHelp(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
- */
- protected void doHelp(RenderRequest arg0, RenderResponse arg1)
- throws PortletException, IOException {
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.portlet.GenericPortlet#doEdit(javax.portlet.RenderRequest,
+ * javax.portlet.RenderResponse)
+ */
+ protected void doEdit(RenderRequest arg0, RenderResponse arg1)
+ throws PortletException, IOException {
+ }
- /**
- * @return portlet config, stored at init() method.
- */
- protected PortletConfig getConfig() {
- return config;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.portlet.GenericPortlet#doHelp(javax.portlet.RenderRequest,
+ * javax.portlet.RenderResponse)
+ */
+ protected void doHelp(RenderRequest arg0, RenderResponse arg1)
+ throws PortletException, IOException {
+ }
- /**
- * Get currenf JSF lifecycle instance.
- * @return
- */
- protected Lifecycle getLifecycle() {
- return lifecycle;
- }
-
- /**
- * Create new faces context instance.
- * @param request
- * @param response
- * @return new instance of faces context.
- */
- protected FacesContext getFacesContext(PortletRequest request, PortletResponse response){
- return facesContextFactory.getFacesContext(getConfig().getPortletContext(), request, response, getLifecycle());
- }
-
-
- protected void execute(FacesContext context) throws FacesException {
- getLifecycle().execute(context);
- }
+ /**
+ * @return portlet config, stored at init() method.
+ */
+ protected PortletConfig getConfig() {
+ return this.config;
+ }
- protected void render(FacesContext context) throws FacesException {
- getLifecycle().render(context);
- }
+ /**
+ * Get currenf JSF lifecycle instance.
+ *
+ * @return
+ */
+ protected Lifecycle getLifecycle() {
+ return this.lifecycle;
+ }
+
+ /**
+ * Create new faces context instance.
+ *
+ * @param request
+ * @param response
+ * @return new instance of faces context.
+ */
+ protected FacesContext getFacesContext(PortletRequest request,
+ PortletResponse response) {
+ return this.facesContextFactory.getFacesContext(getConfig()
+ .getPortletContext(), request, response, getLifecycle());
+ }
+
+ protected void execute(FacesContext context) throws FacesException {
+ getLifecycle().execute(context);
+ }
+
+ protected void render(FacesContext context) throws FacesException {
+ getLifecycle().render(context);
+ }
}
Deleted: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/FacesPortlet.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/FacesPortlet.java 2007-04-10 18:26:37 UTC (rev 65)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/FacesPortlet.java 2007-04-11 16:04:01 UTC (rev 66)
@@ -1,430 +0,0 @@
-/*
- * CDDL HEADER START
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the License). You may not use this file except in
- * compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://www.sun.com/cddl/cddl.html and legal/CDDLv1.0.txt
- * See the License for the specific language governing
- * permission and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * Header Notice in each file and include the License file
- * at legal/CDDLv1.0.txt.
- * If applicable, add the following below the CDDL Header,
- * with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
- * CDDL HEADER END
- */
-
-package org.ajax4jsf.portlet;
-
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.faces.FacesException;
-import javax.faces.FactoryFinder;
-import javax.faces.application.Application;
-import javax.faces.context.FacesContext;
-import javax.faces.context.FacesContextFactory;
-import javax.faces.lifecycle.Lifecycle;
-import javax.faces.lifecycle.LifecycleFactory;
-import javax.faces.webapp.FacesServlet;
-import javax.portlet.ActionRequest;
-import javax.portlet.ActionResponse;
-import javax.portlet.GenericPortlet;
-import javax.portlet.PortletMode;
-import javax.portlet.PortletConfig;
-import javax.portlet.PortletSession;
-import javax.portlet.PortletException;
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-import javax.portlet.PortletRequest;
-
-
-/**
- * <p><strong>FacesPortlet</strong> is a portlet that manages the request
- * processing lifecycle for web applications that are utilizing JavaServer
- * Faces to construct the user interface in a portlet-based environment.</p>
- */
-
-public class FacesPortlet extends GenericPortlet {
-
- // The Logger instance for this class
- private static Logger logger = Logger.getLogger(FacesPortlet.class.getPackage().getName(), "JSFPLogMessages");
-
- /**
- * <p>The key used to store/retrive the PortletConfig object.</p>
- */
- public static final String PORTLET_CONFIG = "javax.portlet.PortletConfig";
-
- // ------------------------------------------------------ Manifest Constants
-
-
- /**
- * <p>Context initialization parameter name for the lifecycle identifier
- * of the {@link Lifecycle} instance to be utilized.</p>
- */
- private static final String LIFECYCLE_ID_ATTR =
- FacesServlet.LIFECYCLE_ID_ATTR;
-
-
- // ------------------------------------------------------ Instance Variables
-
-
- /**
- * <p>The {@link Application} instance for this web application.</p>
- */
- private Application application = null;
-
-
- /**
- * <p>Factory for {@link FacesContext} instances.</p>
- */
- private FacesContextFactory facesContextFactory = null;
-
-
- /**
- * <p>The {@link Lifecycle} instance to use for request processing.</p>
- */
- private Lifecycle lifecycle = null;
-
-
- /**
- * <p>The <code>PortletConfig</code> instance for this portlet.</p>
- */
- private PortletConfig portletConfig = null;
-
-
- // ---------------------------------------------------------- Public Methods
-
-
- /**
- * <p>Release all resources acquired at startup time.</p>
- */
- public void destroy() {
- logger.finest("PS_CSFP0006");
- application = null;
- facesContextFactory = null;
- lifecycle = null;
- portletConfig = null;
- logger.finest("PS_CSFP0007");
- }
-
-
- /**
- * <p>Acquire the factory instance we will require.</p>
- *
- * @exception PortletException if, for any reason, the startp of
- * this Faces application failed. This includes errors in the
- * config file that is parsed before or during the processing of
- * this <code>init()</code> method.
- */
- public void init(PortletConfig portletConfig) throws PortletException {
-
- logger.finest("PS_CSFP0008");
-
- // Save our PortletConfig instance
- this.portletConfig = portletConfig;
- // Invoke Generic Portlet's init method
- super.init(portletConfig);
-
- logger.finest("PS_CSFP0009");
- }
-
- public FacesContextFactory getFacesContextFactory() throws PortletException{
- if (facesContextFactory != null) {
- return facesContextFactory;
- }
- // Acquire our FacesContextFactory instance
- try {
- facesContextFactory = (FacesContextFactory)
- FactoryFinder.getFactory
- (FactoryFinder.FACES_CONTEXT_FACTORY);
- logger.log(Level.FINEST, "PS_CSFP0010", facesContextFactory);
- } catch (FacesException e) {
- Throwable rootCause = e.getCause();
- if (rootCause == null) {
- throw e;
- } else {
- throw new PortletException(e.getMessage(), rootCause);
- }
- }
- return facesContextFactory;
- }
-
- public Lifecycle getLifecycle() throws PortletException {
- if ( lifecycle != null ) {
- return lifecycle;
- }
- try {
- LifecycleFactory lifecycleFactory = (LifecycleFactory)
- FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
- logger.log(Level.FINEST, "PS_CSFP0011" , lifecycleFactory);
- String lifecycleId =
- portletConfig.getPortletContext().getInitParameter
- (LIFECYCLE_ID_ATTR);
- logger.log(Level.FINE, "PS_CSFP0012", lifecycleId);
- if (lifecycleId == null) {
- lifecycleId = LifecycleFactory.DEFAULT_LIFECYCLE;
- }
- lifecycle = lifecycleFactory.getLifecycle(lifecycleId);
- logger.log(Level.FINEST, "PS_CSFP0013", lifecycle);
- } catch (FacesException e) {
- Throwable rootCause = e.getCause();
- if (rootCause == null) {
- throw e;
- } else {
- throw new PortletException(e.getMessage(), rootCause);
- }
- }
- return lifecycle;
- }
-
- /**
- * <p>Perform the request processing lifecycle for the specified request,
- * up to (but not including) the <em>Render Response</em> phase.</p>
- *
- * @param request The portlet request we are processing
- * @param response The portlet response we are processing
- *
- * @exception IOException if an input/output error occurs
- * @exception PortletException if a portlet processing error occurs
- */
- public void processAction(ActionRequest request, ActionResponse response)
- throws IOException, PortletException {
- logger.finest("PS_CSFP0014");
-
- storeInitParameter(request);
-
- // Acquire the FacesContext instance for this request
- FacesContext context =
- getFacesContextFactory().getFacesContext
- (portletConfig.getPortletContext(),
- request, response, lifecycle);
-
- // Store the PortletConfig in the Application Map
- storePortletConfig(context);
-
- logger.finest("PS_CSFP0015");
-
- // Execute the pre-render request processing lifecycle for this request
- try {
- getLifecycle().execute(context);
- logger.finest("PS_CSFP0016");
- } catch (FacesException e) {
- Throwable t = ((FacesException) e).getCause();
- if (t == null) {
- throw new PortletException(e.getMessage(), e);
- } else {
- if (t instanceof PortletException) {
- throw ((PortletException) t);
- } else if (t instanceof IOException) {
- throw ((IOException) t);
- } else {
- throw new PortletException(t.getMessage(), t);
- }
- }
-
- } finally {
- PortletSession session = (PortletSession)context.getExternalContext().getSession(true);
- PortletMode mode = request.getPortletMode();
- Boolean errorFlag = (Boolean)session.getAttribute(LifecycleImpl.ERROR_FLAG);
- // If any error occured use the same mode
- if(errorFlag != null && errorFlag.equals(Boolean.TRUE)) {
- response.setPortletMode(mode);
- } else {
- // Check if the page is same as the INIT_VIEW page, if yes set the mode to VIEW
- // If the page is not the INIT_VIEW page, it means EDIT/HELP has navigation
- // continue by setting the same mode as the current mode.
- String currentViewId = context.getViewRoot().getViewId();
- String viewId = (String) portletConfig.
- getInitParameter(LifecycleImpl.INIT_VIEW_PARAMETER);
- try {
- if(viewId.equals(currentViewId))
- response.setPortletMode(PortletMode.VIEW);
- else
- response.setPortletMode(mode);
- } catch (IllegalStateException ise) {
- // sendRedirect might have been called
- logger.log(Level.INFO, "PS_CSFP0017", ise.getMessage());
- }
- }
- // Release the FacesContext instance for this request
- context.release();
- }
- logger.finest("PS_CSFP0018");
- }
-
- /**
- * <p>Perform the <em>Render Response</em> phase of the request processing
- * lifecycle for the specified request.</p>
- *
- * <p>This method is invoked to serve up the <code>view</code> portlet mode.</p>
- *
- * @param request The portlet request we are processing
- * @param response The portlet response we are processing
- *
- * @exception IOException if an input/output error occurs
- * @exception PortletException if a portlet processing error occurs
- */
- public void doView(RenderRequest request, RenderResponse response)
- throws PortletException, java.io.IOException {
- renderFaces(request, response);
- }
-
- /**
- * <p>Perform the <em>Render Response</em> phase of the request processing
- * lifecycle for the specified request.</p>
- *
- * <p>This method is invoked to serve up the <code>edit</code> portlet mode.</p>
- *
- * @param request The portlet request we are processing
- * @param response The portlet response we are processing
- *
- * @exception IOException if an input/output error occurs
- * @exception PortletException if a portlet processing error occurs
- */
- public void doEdit(RenderRequest request, RenderResponse response)
- throws PortletException, java.io.IOException {
- renderFaces(request, response);
- }
-
- /**
- * <p>Perform the <em>Render Response</em> phase of the request processing
- * lifecycle for the specified request.</p>
- *
- * <p>This method is invoked to serve up the <code>help</code> portlet mode.</p>
- *
- * @param request The portlet request we are processing
- * @param response The portlet response we are processing
- *
- * @exception IOException if an input/output error occurs
- * @exception PortletException if a portlet processing error occurs
- */
- public void doHelp(RenderRequest request, RenderResponse response)
- throws PortletException, java.io.IOException {
- renderFaces(request, response);
- }
-
- /**
- * <p>Perform the <em>Render Response</em> phase of the request processing
- * lifecycle for the specified request.</p>
- *
- * @param request The portlet request we are processing
- * @param response The portlet response we are processing
- *
- * @exception IOException if an input/output error occurs
- * @exception PortletException if a portlet processing error occurs
- */
- private void renderFaces(RenderRequest request, RenderResponse response)
- throws IOException, PortletException {
- logger.finest("PS_CSFP0019");
-
- // GenericPortlet sets the title before calling this method
-
- // in a portlet environment, the context type of reponse must
- // be set explicitly.
- response.setContentType(request.getResponseContentType());
-
- storeInitParameter(request);
-
- // Acquire the FacesContext instance for this request
- FacesContext context =
- getFacesContextFactory().getFacesContext
- (portletConfig.getPortletContext(),
- request, response, getLifecycle());
-
- // Store the PortletConfig in the Application Map
- storePortletConfig(context);
-
- logger.finest("PS_CSFP0020");
-
- // Execute the render response phase for this request
- try {
- getLifecycle().render(context);
- logger.finest("PS_CSFP0021");
- } catch (FacesException e) {
- Throwable t = ((FacesException) e).getCause();
- if (t == null) {
- throw new PortletException(e.getMessage(), e);
- } else {
- if (t instanceof PortletException) {
- throw ((PortletException) t);
- } else if (t instanceof IOException) {
- throw ((IOException) t);
- } else {
- throw new PortletException(t.getMessage(), t);
- }
- }
- } finally {
-
- // Release the FacesContext instance for this request
- context.release();
-
- }
- logger.finest("PS_CSFP0022");
- }
-
-
- // --------------------------------------------------------- Private Methods
-
- /**
- * Stores the init parameter identifier and the value for that in the request map.
- * The init parameter identifier can be either com.sun.faces.portlet.INIT_VIEW or
- * com.sun.faces.portlet.INIT_EDIT or com.sun.faces.portlet.INIT_HELP. The appropriate
- * identifier based on the Portlet mode is stored. This value is used in LifeCycleImpl
- * to keep the state information for each mode separate.
- * The value for the identifier is used during the RenderResponse Phase to
- * display the initial view.
- *
- * @param request the portlet request, can be ActionRequest or RenderRequest
- * @throws PortletException
- */
- private void storeInitParameter(PortletRequest request) throws PortletException {
- PortletMode mode = request.getPortletMode();
-
- // Get the init parameter identifier based on the mode.
- String initParameterIdentifier = null;
- if (mode.equals(PortletMode.VIEW)) {
- initParameterIdentifier = LifecycleImpl.INIT_VIEW_PARAMETER;
- } else if (mode.equals(PortletMode.EDIT)) {
- initParameterIdentifier = LifecycleImpl.INIT_EDIT_PARAMETER;
- } else if (mode.equals(PortletMode.HELP)) {
- initParameterIdentifier = LifecycleImpl.INIT_HELP_PARAMETER;
- }
- // Check whether the requested mode is allowed
- if(!request.isPortletModeAllowed(mode) || initParameterIdentifier == null) {
- throw new PortletException(mode + " is not allowed");
- }
-
- String initId = (String) portletConfig.getInitParameter(initParameterIdentifier);
- if (initId != null) {
- // store the identifier in the request map. This identifier can be either a
- // INIT_VIEW or INIT_EDIT or INIT_HELP based on the portlet mode. This information
- // is used in LifeCycleImpl to keep the state information for each mode separate.
- request.setAttribute(LifecycleImpl.INIT_PARAMETER, initParameterIdentifier);
- // store the value for the identifier in the requestMap so that it could be used
- // during the RenderResponse Phase to display the initial view.
- request.setAttribute(initParameterIdentifier, initId);
- } else {
- throw new PortletException(initParameterIdentifier + " must be specified");
- }
- }
-
- /**
- * Store the PortletConfig in the Application Map
- */
- private void storePortletConfig(FacesContext context) {
- Map applicationMap = context.getExternalContext().getApplicationMap();
- if(!applicationMap.containsKey(PORTLET_CONFIG) )
- applicationMap.put(PORTLET_CONFIG, portletConfig);
- }
-}
Added: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/PortletRequestWrapper.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/PortletRequestWrapper.java (rev 0)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/PortletRequestWrapper.java 2007-04-11 16:04:01 UTC (rev 66)
@@ -0,0 +1,305 @@
+/**
+ *
+ */
+package org.ajax4jsf.portlet;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.Map;
+import javax.portlet.PortletRequest;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+/**
+ * Wrap portlet request to simulate servlet environment.
+ * @author asmirnov
+ *
+ */
+public class PortletRequestWrapper implements HttpServletRequest {
+
+ private PortletRequest wrapped;
+
+ public PortletRequestWrapper(PortletRequest wrapped) {
+ this.wrapped = wrapped;
+ }
+
+ public String getAuthType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getContextPath() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Cookie[] getCookies() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public long getDateHeader(String arg0) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public String getHeader(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Enumeration getHeaderNames() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Enumeration getHeaders(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getIntHeader(String arg0) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public String getMethod() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getPathInfo() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getPathTranslated() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getQueryString() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getRemoteUser() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getRequestURI() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public StringBuffer getRequestURL() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getRequestedSessionId() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getServletPath() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public HttpSession getSession() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public HttpSession getSession(boolean arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Principal getUserPrincipal() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isRequestedSessionIdFromCookie() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isRequestedSessionIdFromURL() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isRequestedSessionIdFromUrl() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isRequestedSessionIdValid() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isUserInRole(String arg0) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public Object getAttribute(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Enumeration getAttributeNames() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getCharacterEncoding() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getContentLength() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public String getContentType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ServletInputStream getInputStream() throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getLocalAddr() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getLocalName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getLocalPort() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public Locale getLocale() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Enumeration getLocales() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getParameter(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Map getParameterMap() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Enumeration getParameterNames() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String[] getParameterValues(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getProtocol() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public BufferedReader getReader() throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getRealPath(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getRemoteAddr() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getRemoteHost() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getRemotePort() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public RequestDispatcher getRequestDispatcher(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getScheme() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getServerName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getServerPort() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public boolean isSecure() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void removeAttribute(String arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setAttribute(String arg0, Object arg1) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setCharacterEncoding(String arg0) throws UnsupportedEncodingException {
+ // TODO Auto-generated method stub
+
+ }
+
+
+
+}
Modified: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java 2007-04-10 18:26:37 UTC (rev 65)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java 2007-04-11 16:04:01 UTC (rev 66)
@@ -18,7 +18,6 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
/*
* Created on 25.09.2004
@@ -52,44 +51,25 @@
* limitations under the License.
*/
-
package org.ajax4jsf.portlet.context;
import java.io.IOException;
-
import java.io.InputStream;
-
import java.net.MalformedURLException;
-
import java.net.URL;
-
import java.security.Principal;
-
import java.util.Collections;
import java.util.Enumeration;
-
-import java.util.Enumeration;
-
import java.util.Iterator;
-
import java.util.Locale;
-
import java.util.Map;
-
import java.util.Set;
-
import javax.faces.FacesException;
-
import javax.faces.context.ExternalContext;
-
import javax.servlet.RequestDispatcher;
-
import javax.servlet.Servlet;
-
import javax.servlet.ServletContext;
-
import javax.servlet.ServletException;
-
import javax.servlet.ServletResponse;
/**
@@ -113,787 +93,375 @@
*
*
*/
-
public abstract class AbstractExternalContext extends ExternalContext {
+ // TODO - more configurable with sitemap parameters.
+ // TODO - optimization.
+ private Map applicationMap;
- // TODO - more configurable with sitemap parameters.
+ private Map initParameterMap;
- // TODO - optimization.
+ private Map requestHeaderMap = null;
- private Map applicationMap;
+ private Map requestHeaderValues;
- private Map initParameterMap;
+ private Map requestMap;
- private Map requestHeaderMap = null;
+ private Map requestParameterMap;
- private Map requestHeaderValues;
+ private Map requestParameterValuesMap;
- private Map requestMap;
+ private Map sessionMap;
- private Map requestParameterMap;
+ private Object request;
- private Map requestParameterValuesMap;
+ private Object response;
- private Map sessionMap;
+ private boolean http;
- private Object request;
+ private Map actionSettings;
- private Object response;
+ private Object context;
- private boolean http;
+ /**
+ *
+ * @param response
+ *
+ * @param request
+ *
+ * @param context
+ *
+ * @param defaultContext -
+ *
+ * default implementation of <code>ExternalFacesContext</code>.
+ *
+ */
+ public AbstractExternalContext(Object context, Object request,
+ Object response) {
+ super();
+ this.context = context;
+ this.request = request;
+ this.response = response;
+ }
- private Map actionSettings;
+ /*
+ *
+ * (non-Javadoc)
+ *
+ *
+ *
+ * @see javax.faces.context.ExternalContext#dispatch(java.lang.String)
+ *
+ */
+ public Map getApplicationMap() {
+ if (this.applicationMap == null) {
+ this.applicationMap = new ContextAttributesMap() {
+ protected Enumeration getEnumeration() {
+ return getContextAttributeNames();
+ }
- private Object context;
+ protected Object getAttribute(String name) {
+ return getContextAttribute(name);
+ }
- /**
- *
- * @param response
- *
- * @param request
- *
- * @param context
- *
- * @param defaultContext -
- *
- * default implementation of <code>ExternalFacesContext</code>.
- *
- */
+ protected void setAttribute(String name, Object value) {
+ setContextAttribute(name, value);
+ }
- public AbstractExternalContext(
-
- Object context, Object request,
-
- Object response) {
-
- super();
-
- this.context = context;
-
- this.request = request;
-
- this.response = response;
-
+ protected void removeAttribute(String name) {
+ removeContextAttribute(name);
+ }
+ };
}
+ return this.applicationMap;
+ }
+ protected abstract void removeContextAttribute(String name);
+ protected abstract void setContextAttribute(String name, Object value);
+ protected abstract Object getContextAttribute(String name);
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#dispatch(java.lang.String)
- *
- */
+ protected abstract Enumeration getContextAttributeNames();
- public Map getApplicationMap() {
- if (applicationMap == null) {
- applicationMap = new ContextAttributesMap() {
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.context.ExternalContext#getAuthType()
+ */
+ public Object getContext() {
+ return this.context;
+ }
+ /**
+ * @param context
+ */
+ public void setContext(Object context) {
+ this.context = context;
+ }
- protected Enumeration getEnumeration() {
- return getContextAttributeNames();
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.context.ExternalContext#getInitParameter(java.lang.String)
+ */
+ public Map getInitParameterMap() {
+ if (this.initParameterMap == null) {
+ this.initParameterMap = new ContextAttributesMap() {
+ protected Object getAttribute(String name) {
+ return getInitParameter(name);
+ }
-
- protected Object getAttribute(String name) {
- return getContextAttribute(name);
- }
-
- protected void setAttribute(String name, Object value) {
- setContextAttribute(name,value);
- }
-
- };
-
+ protected void setAttribute(String name, Object value) {
+ throw new UnsupportedOperationException();
}
- return applicationMap;
-
+ protected Enumeration getEnumeration() {
+ return getInitParametersNames();
+ }
+ };
}
+ return this.initParameterMap;
+ }
- protected abstract void setContextAttribute(String name, Object value);
- protected abstract Object getContextAttribute(String name);
- protected abstract Enumeration getContextAttributeNames();
+ /**
+ * Hoock method for initialization parameters.
+ *
+ * @return
+ */
+ protected abstract Enumeration getInitParametersNames();
- /*
- * (non-Javadoc)
- * @see javax.faces.context.ExternalContext#getAuthType()
- */
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.context.ExternalContext#getRequest()
+ */
+ public Object getRequest() {
+ return this.request;
+ }
- public Object getContext() {
- return this.context;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.context.ExternalContext#setRequest(java.lang.Object)
+ */
+ public void setRequest(Object request) {
+ this.request = request;
+ }
+ public Map getRequestCookieMap() {
+ // Portlet environment don't have methods to use cookies.
+ return Collections.EMPTY_MAP;
+ }
- /**
- * @param context
- */
- public void setContext(Object context) {
- this.context = context;
- }
+ /*
+ *
+ * (non-Javadoc)
+ *
+ *
+ *
+ * @see javax.faces.context.ExternalContext#getRequestHeaderMap()
+ *
+ */
+ public Map getRequestHeaderMap() {
+ if (this.requestHeaderMap == null) {
+ this.requestHeaderMap = new ContextAttributesMap() {
+ protected Enumeration getEnumeration() {
+ return getRequestHeaderNames();
+ }
- /*
- * (non-Javadoc)
- * @see javax.faces.context.ExternalContext#getInitParameter(java.lang.String)
- */
-
- public Map getInitParameterMap() {
-
-
- if (initParameterMap == null) {
-
- initParameterMap = new ContextAttributesMap() {
-
- protected Object getAttribute(String name) {
- return getInitParameter(name);
- }
-
- protected void setAttribute(String name, Object value) {
- throw new UnsupportedOperationException();
- }
-
- protected Enumeration getEnumeration() {
- return getInitParametersNames();
- }
-
- };
-
+ protected Object getAttribute(String name) {
+ return getRequestHeader(name);
}
- return initParameterMap;
-
+ protected void setAttribute(String name, Object value) {
+ throw new UnsupportedOperationException();
+ }
+ };
}
+ return this.requestHeaderMap;
+ }
+ protected abstract Object getRequestHeader(String name);
- /**
- * Hoock method for initialization parameters.
- * @return
- */
- protected abstract Enumeration getInitParametersNames();
+ protected abstract Enumeration getRequestHeaderNames();
+ public Map getRequestHeaderValuesMap() {
+ //
+ if (this.requestHeaderValues == null) {
+ this.requestHeaderValues = new ContextAttributesMap() {
+ protected Enumeration getEnumeration() {
+ return getRequestHeaderNames();
+ }
+ protected Object getAttribute(String name) {
+ return getRequestHeaderValues(name);
+ }
-
- /* (non-Javadoc)
- * @see javax.faces.context.ExternalContext#getRequest()
- */
- public Object getRequest() {
-
- return request;
-
+ protected void setAttribute(String name, Object value) {
+ throw new UnsupportedOperationException();
+ }
+ };
}
+ return this.requestHeaderValues;
+ }
- /* (non-Javadoc)
- * @see javax.faces.context.ExternalContext#setRequest(java.lang.Object)
- */
- public void setRequest(Object request) {
- this.request = request;
- }
-
- public Map getRequestCookieMap() {
- // Portlet environment don't have methods to use cookies.
- return Collections.EMPTY_MAP;
- }
+ protected abstract Object[] getRequestHeaderValues(String name);
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestHeaderMap()
- *
- */
+ public Map getRequestMap() {
+ if (this.requestMap == null) {
+ this.requestMap = new ContextAttributesMap() {
+ protected Enumeration getEnumeration() {
+ return getRequestAttributeNames();
+ }
- public Map getRequestHeaderMap() {
+ protected Object getAttribute(String name) {
+ return getRequestAttribute(name);
+ }
- // TODO Return values of Http headers, or, may be, addition values from
-
- // Action parameters .
-
- if (requestHeaderMap == null) {
-
- requestHeaderMap = new ContextMap() {
-
- public Object get(Object key) {
-
- // TODO - return configuration parameter from Cocoon
-
- // FacesAction
-
- return getCocoonRequest().getHeader(key.toString());
-
- }
-
- protected Enumeration getEnumeration() {
-
- return getCocoonRequest().getHeaderNames();
-
- }
-
- };
-
+ protected void setAttribute(String name, Object value) {
+ setRequestAttribute(name, value);
}
- return requestHeaderMap;
-
+ protected void removeAttribute(String name) {
+ removeRequestAttribute(name);
+ }
+ };
}
+ return this.requestMap;
+ }
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestHeaderValuesMap()
- *
- */
+ protected abstract void removeRequestAttribute(String name);
- public Map getRequestHeaderValuesMap() {
+ protected abstract void setRequestAttribute(String name, Object value);
- //
+ protected abstract Object getRequestAttribute(String name);
- if (requestHeaderValues == null) {
+ protected abstract Enumeration getRequestAttributeNames();
- requestHeaderValues = new ContextMap() {
+ public Map getRequestParameterMap() {
+ //
+ if (this.requestParameterMap == null) {
+ this.requestParameterMap = new ContextAttributesMap() {
+ protected Enumeration getEnumeration() {
+ return enumerateRequestParameterNames();
+ }
- public Object get(Object key) {
-
- // TODO - return configuration parameter from Cocoon
-
- // FacesAction
-
- return getCocoonRequest().getHeaders(key.toString());
-
- }
-
- protected Enumeration getEnumeration() {
-
- return getCocoonRequest().getHeaderNames();
-
- }
-
- };
-
+ protected Object getAttribute(String name) {
+ return getRequestParameter(name);
}
- return requestHeaderValues;
-
+ protected void setAttribute(String name, Object value) {
+ throw new UnsupportedOperationException();
+ }
+ };
}
+ return this.requestParameterMap;
+ }
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestLocale()
- *
- */
+ protected abstract Object getRequestParameter(String name);
- public Locale getRequestLocale() {
+ protected abstract Enumeration enumerateRequestParameterNames();
- //
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.context.ExternalContext#getRequestParameterNames()
+ *
+ */
+ public Iterator getRequestParameterNames() {
+ return new EnumerationIterator(enumerateRequestParameterNames());
+ }
- return getCocoonRequest().getLocale();
+ /*
+ *
+ * (non-Javadoc)
+ *
+ *
+ *
+ * @see javax.faces.context.ExternalContext#getRequestParameterValuesMap()
+ *
+ */
+ public Map getRequestParameterValuesMap() {
+ //
+ // TODO make Cocoon-specific realization ( interact with sitemap
+ // parameters )
+ if (this.requestParameterValuesMap == null) {
+ this.requestParameterValuesMap = new ContextAttributesMap() {
- }
+ protected Enumeration getEnumeration() {
+ return enumerateRequestParameterNames();
+ }
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestLocales()
- *
- */
-
- public Iterator getRequestLocales() {
-
- //
-
- return new EnumerationIterator(getCocoonRequest().getLocales());
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestMap()
- *
- */
-
- public Map getRequestMap() {
-
- // TODO make Cocoon-specific realization ( interact with sitemap
-
- // parameters )
-
- if (requestMap == null) {
-
- requestMap = new ContextMap() {
-
- public Object get(Object key) {
-
- if (key == null) {
-
- throw new NullPointerException();
-
- }
-
- if ("javax.servlet.include.path_info".equals(key)) {
-
- return getRequestPathInfo();
-
- // return getCocoonRequest().getAttribute(
-
- // FacesAction.ACT_SRC);
-
- }
-
- if ("javax.servlet.include.servlet_path".equals(key)) {
-
- return getRequestServletPath();
-
- // return getCocoonRequest().getAttribute(
-
- // FacesAction.ACT_MAPPING);
-
- }
-
- return getCocoonRequest().getAttribute(key.toString());
-
- }
-
- public Object put(Object key, Object value) {
-
- if (key == null) {
-
- throw new NullPointerException();
-
- }
-
- String keyString = key.toString();
-
- Object result = getCocoonRequest().getAttribute(keyString);
-
- getCocoonRequest().setAttribute(keyString, value);
-
- return (result);
-
- }
-
- public Object remove(Object key) {
-
- if (key == null) {
-
- return null;
-
- }
-
- String keyString = key.toString();
-
- Object result = getCocoonRequest().getAttribute(keyString);
-
- getCocoonRequest().removeAttribute(keyString);
-
- return (result);
-
- }
-
- protected Enumeration getEnumeration() {
-
- return getCocoonRequest().getAttributeNames();
-
- }
-
- };
-
+ protected Object getAttribute(String name) {
+ return getRequestParameterValues(name);
}
- return requestMap;
-
+ protected void setAttribute(String name, Object value) {
+ throw new UnsupportedOperationException();
+ }
+ };
}
+ return this.requestParameterValuesMap;
+ }
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestParameterMap()
- *
- */
+ protected abstract Object getRequestParameterValues(String name);
- public Map getRequestParameterMap() {
+ /*
+ *
+ * (non-Javadoc)
+ *
+ *
+ *
+ * @see javax.faces.context.ExternalContext#getResponse()
+ *
+ */
+ public void setResponse(Object response) {
+ this.response = response;
+ }
- //
+ public Object getResponse() {
+ return this.response;
+ }
- if (requestParameterMap == null) {
+ /*
+ *
+ * (non-Javadoc)
+ *
+ *
+ *
+ * @see javax.faces.context.ExternalContext#getSessionMap()
+ *
+ */
+ public Map getSessionMap() {
+ if (this.sessionMap == null) {
+ this.sessionMap = new ContextAttributesMap() {
- requestParameterMap = new ContextConcatentedMap(
-
- (Map) (getCocoonRequest()
-
- .getAttribute(FacesAction.ACT_PARAMETERS))) {
-
- public Object getBase(Object key) {
-
- //
-
- return getCocoonRequest().getParameter(key.toString());
-
- }
-
- protected Enumeration getEnumeration() {
-
- return getCocoonRequest().getParameterNames();
-
- }
-
- };
-
+ protected Enumeration getEnumeration() {
+ return getSessionAttributeNames();
}
- return requestParameterMap;
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestParameterNames()
- *
- */
-
- public Iterator getRequestParameterNames() {
-
- // TODO Append Cocoon-specific parameters from FacesAction
-
- return this.getRequestParameterMap().entrySet().iterator();
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestParameterValuesMap()
- *
- */
-
- public Map getRequestParameterValuesMap() {
-
- //
-
- // TODO make Cocoon-specific realization ( interact with sitemap
-
- // parameters )
-
- if (requestParameterValuesMap == null) {
-
- requestParameterValuesMap = new ContextMap() {
-
- public Object get(Object key) {
-
- // TODO - return configuration parameter from Cocoon
-
- // FacesAction
-
- return getCocoonRequest()
-
- .getParameterValues(key.toString());
-
- }
-
- protected Enumeration getEnumeration() {
-
- return getCocoonRequest().getParameterNames();
-
- }
-
- };
-
+ protected Object getAttribute(String name) {
+ return getSessionAttribute(name);
}
- return requestParameterValuesMap;
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestPathInfo()
- *
- */
-
- public String getRequestServletPath() {
-
- // TODO return current sitemap path ??? For cocoon, always "/" !
-
- return ""; // path;// ??? "";
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getResource(java.lang.String)
- *
- */
-
- public URL getResource(String path) throws MalformedURLException {
-
- //
-
- return getCocoonContext().getResource(path);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getResourceAsStream(java.lang.String)
- *
- */
-
- public InputStream getResourceAsStream(String path) {
-
- return getCocoonContext().getResourceAsStream(path);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getResourcePaths(java.lang.String)
- *
- */
-
- public Set getResourcePaths(String path) {
-
- // Cocoon Context do not Have such method ...
-
- return null; // getCocoonHttpContext().getResourcePaths(path);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getResponse()
- *
- */
-
- public void setResponse(Object response) {
- this.response = response;
- }
-
-
-
-
- public Object getResponse() {
- return response;
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getSession(boolean)
- *
- */
-
- public Object getSession(boolean create) {
-
- // TODO Convert to HttpSession !!!
-
- return getCocoonRequest().getSession(create);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getSessionMap()
- *
- */
-
- public Map getSessionMap() {
-
- if (sessionMap == null) {
-
- sessionMap = new ContextMap() {
-
- public Object get(Object key) {
-
- if (key == null) {
-
- throw new NullPointerException();
-
- }
-
- return getCocoonSession().getAttribute(key.toString());
-
- }
-
- public Object put(Object key, Object value) {
-
- if (key == null) {
-
- throw new NullPointerException();
-
- }
-
- String keyString = key.toString();
-
- Session session = getCocoonSession();
-
- Object result = session.getAttribute(keyString);
-
- session.setAttribute(keyString, value);
-
- return (result);
-
- }
-
- public Object remove(Object key) {
-
- if (key == null) {
-
- return null;
-
- }
-
- String keyString = key.toString();
-
- Session session = getCocoonSession();
-
- Object result = session.getAttribute(keyString);
-
- session.removeAttribute(keyString);
-
- return (result);
-
- }
-
- protected Enumeration getEnumeration() {
-
- return getCocoonSession().getAttributeNames();
-
- }
-
- private Session getCocoonSession() {
-
- return (Session) getSession(true);
-
- }
-
- };
-
+ protected void setAttribute(String name, Object value) {
+ setSessionAttribute(name, value);
}
+
+ protected void removeAttribute(String name) {
+ removeSessionAttribute(name);
+ }
- return sessionMap;
-
+ };
}
+ return this.sessionMap;
+ }
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getUserPrincipal()
- *
- */
+ protected abstract void removeSessionAttribute(String name);
- public Principal getUserPrincipal() {
+ protected abstract void setSessionAttribute(String name, Object value);
- return getCocoonRequest().getUserPrincipal();
+ protected abstract Object getSessionAttribute(String name);
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#isUserInRole(java.lang.String)
- *
- */
-
- public boolean isUserInRole(String role) {
-
- return getCocoonRequest().isUserInRole(role);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#redirect(java.lang.String)
- *
- */
-
- public void redirect(String url) throws IOException {
-
- // use Redirector Stored In objectModel Map
-
- ActionRedirector redirector = (ActionRedirector) getCocoonRequest()
-
- .getAttribute(FacesAction.ACT_REDIRECTOR);
-
- if (redirector != null) {
-
- try {
-
- redirector.redirect(false, url);
-
- } catch (ProcessingException e) {
-
- throw new IOException(e.getMessage());
-
- }
-
- }
-
- }
-
+ protected abstract Enumeration getSessionAttributeNames();
}
\ No newline at end of file
Modified: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextAttributesMap.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextAttributesMap.java 2007-04-10 18:26:37 UTC (rev 65)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextAttributesMap.java 2007-04-11 16:04:01 UTC (rev 66)
@@ -4,45 +4,45 @@
package org.ajax4jsf.portlet.context;
/**
- * Abstract base class for all attributes/sessions/cookies maps in external contexts.
+ * Abstract base class for all attributes/sessions/cookies maps in external
+ * contexts.
+ *
* @author asmirnov
- *
+ *
*/
public abstract class ContextAttributesMap extends ContextMap {
-
- public Object get(Object key) {
- if(null == key){
- throw new NullPointerException();
- }
- return getAttribute(key.toString());
+ public Object get(Object key) {
+ if (null == key) {
+ throw new NullPointerException();
}
-
- public Object put(Object key, Object value) {
- if(null == key){
- throw new NullPointerException();
- }
- String stringKey = key.toString();
- Object oldValue = getAttribute(stringKey);
- setAttribute(stringKey, value);
- return oldValue;
+ return getAttribute(key.toString());
+ }
+
+ public Object put(Object key, Object value) {
+ if (null == key) {
+ throw new NullPointerException();
}
-
- public Object remove(Object key) {
- if(null == key){
- throw new NullPointerException();
- }
- return removeAttribute(key.toString());
+ String stringKey = key.toString();
+ Object oldValue = getAttribute(stringKey);
+ setAttribute(stringKey, value);
+ return oldValue;
+ }
+
+ public Object remove(Object key) {
+ if (null == key) {
+ throw new NullPointerException();
}
-
-
- protected abstract Object getAttribute(String name);
+ String stringKey = key.toString();
+ Object oldValue = getAttribute(stringKey);
+ removeAttribute(stringKey);
+ return oldValue;
+ }
- protected abstract void setAttribute(String name, Object value);
+ protected abstract Object getAttribute(String name);
- protected Object removeAttribute(String name){
- Object oldValue = getAttribute(name);
- setAttribute(name, null);
- return oldValue;
- }
+ protected abstract void setAttribute(String name, Object value);
+ protected void removeAttribute(String name) {
+ setAttribute(name, null);
+ }
}
Modified: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextConcatentedMap.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextConcatentedMap.java 2007-04-10 18:26:37 UTC (rev 65)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextConcatentedMap.java 2007-04-11 16:04:01 UTC (rev 66)
@@ -18,7 +18,6 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
/*
* Created on 02.07.2005
@@ -29,119 +28,80 @@
* Window - Preferences - Java - Code Style - Code Templates
- */
+ */
+package org.ajax4jsf.portlet.context;
-package org.ajax4jsf.portlet.context;
+import java.util.Map;
+import java.util.Set;
-
+/**
+ *
+ * @author shura
+ *
+ *
+ *
+ * Class for create extended context maps - concatend real parameters map with
+ *
+ * additional from cocoon sitemap ...
+ *
+ */
+abstract class ContextConcatentedMap extends ContextMap {
+ private Map extendMap;
-import java.util.Map;
+ private Set baseSet;
-import java.util.Set;
+ /**
+ *
+ * @param extendedMap
+ *
+ */
+ public ContextConcatentedMap(Map extendedMap) {
+ this.extendMap = extendedMap;
+ }
-
+ /*
+ *
+ * (non-Javadoc)
+ *
+ *
+ *
+ * @see java.util.Map#entrySet() use lasy creation , since used only in
+ *
+ * static collection.
+ *
+ */
+ public Set entrySet() {
+ if (this.baseSet == null) {
+ this.baseSet = super.entrySet();
+ this.baseSet.addAll(this.extendMap.entrySet());
+ }
+ return this.baseSet;
+ }
-/**
+ /*
+ *
+ * (non-Javadoc)
+ *
+ *
+ *
+ * @see java.util.Map#get(java.lang.Object)
+ *
+ */
+ public Object get(Object key) {
+ Object result = this.extendMap.get(key);
+ if (null != result) {
+ return result;
+ } else {
+ return getBase(key);
+ }
+ }
- * @author shura
-
- *
-
- * Class for create extended context maps - concatend real parameters map with
-
- * additional from cocoon sitemap ...
-
- */
-
-abstract class ContextConcatentedMap extends ContextMap {
-
- private Map extendMap;
-
-
-
- private Set baseSet;
-
-
-
- /**
-
- * @param extendedMap
-
- */
-
- public ContextConcatentedMap(Map extendedMap) {
-
- this.extendMap = extendedMap;
-
- }
-
-
-
- /*
-
- * (non-Javadoc)
-
- *
-
- * @see java.util.Map#entrySet() use lasy creation , since used only in
-
- * static collection.
-
- */
-
- public Set entrySet() {
-
- if (baseSet == null) {
-
- baseSet = super.entrySet();
-
- baseSet.addAll(extendMap.entrySet());
-
- }
-
- return baseSet;
-
- }
-
-
-
- /*
-
- * (non-Javadoc)
-
- *
-
- * @see java.util.Map#get(java.lang.Object)
-
- */
-
- public Object get(Object key) {
-
- Object result = extendMap.get(key);
-
- if (null != result) {
-
- return result;
-
- } else {
-
- return getBase(key);
-
- }
-
- }
-
-
-
- /**
-
- * @param key
-
- * @return
-
- */
-
- protected abstract Object getBase(Object key);
-
-}
-
+ /**
+ *
+ * @param key
+ *
+ * @return
+ *
+ */
+ protected abstract Object getBase(Object key);
+}
Modified: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextMap.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextMap.java 2007-04-10 18:26:37 UTC (rev 65)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextMap.java 2007-04-11 16:04:01 UTC (rev 66)
@@ -18,20 +18,15 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
package org.ajax4jsf.portlet.context;
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.Collection;
import java.util.Iterator;
-
import java.util.Enumeration;
-
import java.util.HashSet;
-
import java.util.Map;
-
import java.util.Set;
/**
@@ -47,183 +42,132 @@
*
*
*/
-
abstract class ContextMap extends AbstractMap {
+ private transient volatile Set keySet;
- private transient volatile Set keySet;
+ /*
+ *
+ * (non-Javadoc)
+ *
+ *
+ *
+ * @see java.util.Map#entrySet()
+ *
+ */
+ public Set entrySet() {
+ Set entries = new HashSet();
+ for (Enumeration e = getEnumeration(); e.hasMoreElements();) {
+ String paramName = (String) e.nextElement();
+ entries.add(new Entry(paramName, get(paramName)));
+ }
+ return entries;
+ }
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see java.util.Map#entrySet()
- *
- */
-
- public Set entrySet() {
-
- Set entries = new HashSet();
-
- for (Enumeration e = getEnumeration(); e.hasMoreElements();) {
-
- String paramName = (String) e.nextElement();
-
- entries.add(new Entry(paramName, get(paramName)));
-
+ public Set keySet() {
+ if (this.keySet == null) {
+ this.keySet = new AbstractSet() {
+ public Iterator iterator() {
+ return new EnumerationIterator(getEnumeration());
}
- return entries;
-
+ public int size() {
+ Enumeration enumeration = getEnumeration();
+ int size = 0;
+ while (enumeration.hasMoreElements()) {
+ size++;
+ }
+ ;
+ return size;
+ }
+ };
}
+ return this.keySet;
+ }
- public Set keySet() {
- if (keySet == null) {
- keySet = new AbstractSet(){
+ public Collection values() {
+ return super.values();
+ }
- public Iterator iterator() {
- return new EnumerationIterator(getEnumeration());
- }
- public int size() {
- Enumeration enumeration = getEnumeration();
- int size = 0;
- while (enumeration.hasMoreElements()) {
- size++;
- };
- return size;
- }
- };
- }
- return keySet;
- }
-
- public Collection values() {
- return super.values();
- }
+ /**
+ *
+ *
+ *
+ * Template metod - all maps in ExternalFacesContext creates Set from
+ *
+ * parameters <code>Enumeration</code>
+ *
+ *
+ *
+ * @return enumeration for current map.
+ *
+ */
+ protected abstract Enumeration getEnumeration();
- /**
- *
- *
- *
- * Template metod - all maps in ExternalFacesContext creates Set from
- *
- * parameters <code>Enumeration</code>
- *
- *
- *
- * @return enumeration for current map.
- *
- */
+ // Unsupported by all Maps.
+ public void clear() {
+ throw new UnsupportedOperationException();
+ }
- protected abstract Enumeration getEnumeration();
+ // Unsupported by all Maps.
+ public void putAll(Map t) {
+ throw new UnsupportedOperationException();
+ }
- // Unsupported by all Maps.
+ // Supported by maps if overridden
+ public Object remove(Object key) {
+ throw new UnsupportedOperationException();
+ }
- public void clear() {
+ static class Entry implements Map.Entry {
+ // immutable Entry
+ private final Object key;
- throw new UnsupportedOperationException();
+ private final Object value;
+ Entry(Object key, Object value) {
+ this.key = key;
+ this.value = value;
}
- // Unsupported by all Maps.
+ public Object getKey() {
+ return this.key;
+ }
- public void putAll(Map t) {
-
- throw new UnsupportedOperationException();
-
+ public Object getValue() {
+ return this.value;
}
- // Supported by maps if overridden
-
- public Object remove(Object key) {
-
- throw new UnsupportedOperationException();
-
+ // No support of setting the value
+ public Object setValue(Object value) {
+ throw new UnsupportedOperationException();
}
- static class Entry implements Map.Entry {
-
- // immutable Entry
-
- private final Object key;
-
- private final Object value;
-
- Entry(Object key, Object value) {
-
- this.key = key;
-
- this.value = value;
-
- }
-
- public Object getKey() {
-
- return key;
-
- }
-
- public Object getValue() {
-
- return value;
-
- }
-
- // No support of setting the value
-
- public Object setValue(Object value) {
-
- throw new UnsupportedOperationException();
-
- }
-
- public int hashCode() {
-
- return ((key == null ? 0 : key.hashCode()) ^ (value == null ? 0
-
- : value.hashCode()));
-
- }
-
- public boolean equals(Object obj) {
-
- if (obj == null || !(obj instanceof Map.Entry))
-
- return false;
-
- Map.Entry input = (Map.Entry) obj;
-
- Object inputKey = input.getKey();
-
- Object inputValue = input.getValue();
-
- if (inputKey == key || (inputKey != null && inputKey.equals(key))) {
-
- if (inputValue == value
-
- || (inputValue != null && inputValue.equals(value))) {
-
- return true;
-
- }
-
- }
-
- return false;
-
- }
-
+ public int hashCode() {
+ return ((this.key == null ? 0 : this.key.hashCode()) ^ (this.value == null ? 0
+ : this.value.hashCode()));
}
public boolean equals(Object obj) {
-
- if (obj == null || !(obj instanceof ContextMap))
-
- return false;
-
- return super.equals(obj);
-
+ if ((obj == null) || !(obj instanceof Map.Entry)) {
+ return false;
+ }
+ Map.Entry input = (Map.Entry) obj;
+ Object inputKey = input.getKey();
+ Object inputValue = input.getValue();
+ if ((inputKey == this.key) || ((inputKey != null) && inputKey.equals(this.key))) {
+ if ((inputValue == this.value)
+ || ((inputValue != null) && inputValue.equals(this.value))) {
+ return true;
+ }
+ }
+ return false;
}
+ }
+ public boolean equals(Object obj) {
+ if ((obj == null) || !(obj instanceof ContextMap)) {
+ return false;
+ }
+ return super.equals(obj);
+ }
}
\ No newline at end of file
Modified: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ELContextImpl.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ELContextImpl.java 2007-04-10 18:26:37 UTC (rev 65)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ELContextImpl.java 2007-04-11 16:04:01 UTC (rev 66)
@@ -6,7 +6,6 @@
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
-
import javax.el.ELContext;
import javax.el.ELResolver;
import javax.el.FunctionMapper;
@@ -15,90 +14,93 @@
/**
* @author asmirnov
- *
+ *
*/
public class ELContextImpl extends ELContext {
-
- /**
- * @author asmirnov
- *
- */
- public static final class FunctionMapperImpl extends FunctionMapper {
+ /**
+ * @author asmirnov
+ *
+ */
+ public static final class FunctionMapperImpl extends FunctionMapper {
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.FunctionMapper#resolveFunction(java.lang.String,
+ * java.lang.String)
+ */
+ public Method resolveFunction(String arg0, String arg1) {
+ return null;
+ }
+ }
- /* (non-Javadoc)
- * @see javax.el.FunctionMapper#resolveFunction(java.lang.String, java.lang.String)
- */
- public Method resolveFunction(String arg0, String arg1) {
- return null;
- }
+ /**
+ * @author asmirnov
+ *
+ */
+ public static final class VariableMapperImpl extends VariableMapper {
+ private Map variables = new HashMap();
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.VariableMapper#resolveVariable(java.lang.String)
+ */
+ public ValueExpression resolveVariable(String name) {
+ return (ValueExpression) this.variables.get(name);
}
- /**
- * @author asmirnov
- *
- */
- public static final class VariableMapperImpl extends VariableMapper {
-
- private Map variables = new HashMap();
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.VariableMapper#setVariable(java.lang.String,
+ * javax.el.ValueExpression)
+ */
+ public ValueExpression setVariable(String name, ValueExpression variable) {
+ return (ValueExpression) this.variables.put(name, variable);
+ }
+ }
- /* (non-Javadoc)
- * @see javax.el.VariableMapper#resolveVariable(java.lang.String)
- */
- public ValueExpression resolveVariable(String name) {
- return (ValueExpression) variables.get(name);
- }
+ private ELResolver resolver;
- /* (non-Javadoc)
- * @see javax.el.VariableMapper#setVariable(java.lang.String, javax.el.ValueExpression)
- */
- public ValueExpression setVariable(String name, ValueExpression variable) {
- return (ValueExpression) variables.put(name, variable);
- }
+ private VariableMapper variableMapper = new VariableMapperImpl();
- }
+ private FunctionMapper functionMapper = new FunctionMapperImpl();
- private ELResolver resolver;
-
- private VariableMapper variableMapper = new VariableMapperImpl();
-
- private FunctionMapper functionMapper = new FunctionMapperImpl();
+ public ELContextImpl(ELResolver resolver) {
+ this.resolver = resolver;
+ }
-
- public ELContextImpl(ELResolver resolver) {
- this.resolver = resolver;
- }
+ /**
+ * @return the functionMapper
+ */
+ public FunctionMapper getFunctionMapper() {
+ return this.functionMapper;
+ }
- /**
- * @return the functionMapper
- */
- public FunctionMapper getFunctionMapper() {
- return functionMapper;
- }
+ /**
+ * @param functionMapper
+ * the functionMapper to set
+ */
+ public void setFunctionMapper(FunctionMapper functionMapper) {
+ this.functionMapper = functionMapper;
+ }
- /**
- * @param functionMapper the functionMapper to set
- */
- public void setFunctionMapper(FunctionMapper functionMapper) {
- this.functionMapper = functionMapper;
- }
+ /**
+ * @return the variableMapper
+ */
+ public VariableMapper getVariableMapper() {
+ return this.variableMapper;
+ }
- /**
- * @return the variableMapper
- */
- public VariableMapper getVariableMapper() {
- return variableMapper;
- }
+ /**
+ * @param variableMapper
+ * the variableMapper to set
+ */
+ public void setVariableMapper(VariableMapper variableMapper) {
+ this.variableMapper = variableMapper;
+ }
- /**
- * @param variableMapper the variableMapper to set
- */
- public void setVariableMapper(VariableMapper variableMapper) {
- this.variableMapper = variableMapper;
- }
-
- public ELResolver getELResolver() {
- return resolver;
- }
-
+ public ELResolver getELResolver() {
+ return this.resolver;
+ }
}
Modified: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/EnumerationIterator.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/EnumerationIterator.java 2007-04-10 18:26:37 UTC (rev 65)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/EnumerationIterator.java 2007-04-11 16:04:01 UTC (rev 66)
@@ -7,31 +7,21 @@
import java.util.Iterator;
class EnumerationIterator implements Iterator {
+ public EnumerationIterator(Enumeration enumeration) {
+ this.enumeration = enumeration;
+ }
- public EnumerationIterator(Enumeration enumeration) {
+ private Enumeration enumeration;
- this.enumeration = enumeration;
+ public boolean hasNext() {
+ return this.enumeration.hasMoreElements();
+ }
- }
+ public Object next() {
+ return this.enumeration.nextElement();
+ }
- private Enumeration enumeration;
-
- public boolean hasNext() {
-
- return enumeration.hasMoreElements();
-
- }
-
- public Object next() {
-
- return enumeration.nextElement();
-
- }
-
- public void remove() {
-
- throw new UnsupportedOperationException();
-
- }
-
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
}
\ No newline at end of file
Deleted: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ExternalContextImpl.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ExternalContextImpl.java 2007-04-10 18:26:37 UTC (rev 65)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ExternalContextImpl.java 2007-04-11 16:04:01 UTC (rev 66)
@@ -1,1749 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
-
- * Created on 25.09.2004
-
- *
-
- * Copyright 1999-2004 The Apache Software Foundation.
-
- *
-
- * Licensed under the Apache License, Version 2.0 (the "License");
-
- * you may not use this file except in compliance with the License.
-
- * You may obtain a copy of the License at
-
- *
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- *
-
- * Unless required by applicable law or agreed to in writing, software
-
- * distributed under the License is distributed on an "AS IS" BASIS,
-
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-
- * See the License for the specific language governing permissions and
-
- * limitations under the License.
-
- */
-
-package org.ajax4jsf.portlet.context;
-
-import java.io.IOException;
-
-import java.io.InputStream;
-
-import java.net.MalformedURLException;
-
-import java.net.URL;
-
-import java.security.Principal;
-
-import java.util.Collections;
-
-import java.util.Enumeration;
-
-import java.util.Iterator;
-
-import java.util.Locale;
-
-import java.util.Map;
-
-import java.util.Set;
-
-import javax.faces.FacesException;
-
-import javax.faces.context.ExternalContext;
-
-import javax.servlet.RequestDispatcher;
-
-import javax.servlet.Servlet;
-
-import javax.servlet.ServletContext;
-
-import javax.servlet.ServletException;
-
-import javax.servlet.ServletResponse;
-
-/**
- *
- * @author shura
- *
- *
- *
- * Cocoon specific implementation of <code>ExternalContext</code> Use cocoon
- *
- * <code>Context</code> for Implement JSF Servlet specific functions Do not
- *
- * perform redirect - but tell <code>Action</code> for internal pipeline
- *
- * redirect ? or do normal Cocoon redirect Via Http Environment do not dispanch -
- *
- * use Cocoon generator source parametr, but perform generation Full
- *
- * Cocoon-specific realization ;
- *
- *
- *
- */
-
-public abstract class ExternalContextImpl extends ExternalContext {
-
- // TODO - more configurable with sitemap parameters.
-
- // TODO - optimization.
-
- private Map applicationMap;
-
- private Map initParameterMap;
-
- private Map requestHeaderMap = null;
-
- private Map requestHeaderValues;
-
- private Map requestMap;
-
- private Map requestParameterMap;
-
- private Map requestParameterValuesMap;
-
- private Map sessionMap;
-
- private Object request;
-
- private Object response;
-
- private boolean http;
-
- private Map actionSettings;
-
- private Object context;
-
- /**
- *
- * @param response
- *
- * @param request
- *
- * @param context
- *
- * @param defaultContext -
- *
- * default implementation of <code>ExternalFacesContext</code>.
- *
- */
-
- public ExternalContextImpl(
-
- Object context, Object request,
-
- Object response) {
-
- super();
-
- this.context = context;
-
- this.request = request;
-
- this.response = response;
-
- }
-
-
-
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#dispatch(java.lang.String)
- *
- */
-
- public void dispatch(String path) throws IOException {
-
- // perform Generation in generator, do nothing in Action.
-
- // generator place special Dispatcher to objectModel ...
-
- // May be must set Dispatcher in special method in Context Component ???
-
- String jspPageURL = (String) getCocoonRequest().getAttribute(
-
- JSFGenerator.PAGE_URL_PARAM_NAME);
-
- RequestDispatcher dispatcher = getCocoonHttpContext()
-
- .getNamedDispatcher(getJspServletName());
-
- this.log("Dispatch for page: " + jspPageURL);
-
- // Dispatcher dispatch = getDispatcher();
-
- if (dispatcher == null) {
-
- throw new IOException("NamedDispatcher is null for servlet "
-
- + getJspServletName());
-
- }
-
- try {// Reset jsp Request/Response wrappers - for create on demand
-
- // with new Writer for current XML Consumer.
-
- this.jspRequest = null;
-
- this.jspResponse = null;
-
- dispatcher.include(new JSPServletRequest(getCocoonHttpRequest(),
-
- jspPageURL, null), (ServletResponse) this.getResponse());
-
- } catch (ServletException e) {
-
- //
-
- if (e.getMessage() != null) {
-
- throw new FacesException(e.getMessage(), e);
-
- } else {
-
- throw new FacesException(e);
-
- }
-
- }
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#encodeActionURL(java.lang.String)
- *
- */
-
- public String encodeActionURL(String url) {
-
- //
-
- return getCocoonResponse().encodeURL(url);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#encodeNamespace(java.lang.String)
- *
- */
-
- public String encodeNamespace(String name) {
-
- // HACK - set namespace prefix in Action sitemap parameter.
-
- // return this.getCocoonRequest().getContextPath()+"/"+name;
-
- String namespace = (String) this.getCocoonRequest().getAttribute(
-
- FacesAction.ACT_NAMESPACE);
-
- if (null != namespace) {
-
- return namespace + name;
-
- }
-
- return name;
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#encodeResourceURL(java.lang.String)
- *
- */
-
- public String encodeResourceURL(String url) {
-
- //
-
- return this.getCocoonResponse().encodeURL(url);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getApplicationMap()
- *
- */
-
- public Map getApplicationMap() {
-
- //
-
- if (applicationMap == null) {
-
- applicationMap = new ContextMap() {
-
- public Object get(Object key) {
-
- if (key == null) {
-
- throw new NullPointerException();
-
- }
-
- return getCocoonContext().getAttribute(key.toString());
-
- }
-
- public Object put(Object key, Object value) {
-
- if (key == null) {
-
- throw new NullPointerException();
-
- }
-
- String keyString = key.toString();
-
- Object result = getCocoonContext().getAttribute(keyString);
-
- getCocoonContext().setAttribute(keyString, value);
-
- return (result);
-
- }
-
- public Object remove(Object key) {
-
- if (key == null) {
-
- return null;
-
- }
-
- String keyString = key.toString();
-
- Object result = getCocoonContext().getAttribute(keyString);
-
- getCocoonContext().removeAttribute(keyString);
-
- return (result);
-
- }
-
- protected Enumeration getEnumeration() {
-
- return getCocoonContext().getAttributeNames();
-
- }
-
- };
-
- }
-
- return applicationMap;
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getAuthType()
- *
- */
-
- public String getAuthType() {
-
- //
-
- return this.getCocoonRequest().getAuthType();
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getContext()
- *
- */
-
- public Object getContext() {
-
- // Return special ServletContext decorator for default
-
- // implementation ?
-
- // As I see in JSF RI sources, used only for get Application Parameter ,
-
- // but I
-
- // want to store application parameters in objectModel.
-
- // Correction - in Sun RI used for store application data between
-
- // servelet context listenier
-
- // ( configure JSF ) and to request processing data in Context#Attribute
-
- // !
-
- ServletContext servletContext = new ServletContext() {
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#getContext(java.lang.String)
- *
- */
-
- public ServletContext getContext(String uripath) {
-
- return getCocoonHttpContext().getContext(uripath);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#getMajorVersion()
- *
- */
-
- public int getMajorVersion() {
-
- return getCocoonHttpContext().getMajorVersion();
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#getMinorVersion()
- *
- */
-
- public int getMinorVersion() {
-
- return getCocoonHttpContext().getMinorVersion();
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#getMimeType(java.lang.String)
- *
- */
-
- public String getMimeType(String file) {
-
- return getCocoonHttpContext().getMimeType(file);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#getResourcePaths(java.lang.String)
- *
- */
-
- public Set getResourcePaths(String path) {
-
- return null;
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#getResource(java.lang.String)
- *
- */
-
- public URL getResource(String path) throws MalformedURLException {
-
- return ExternalContextImpl.this.getResource(path);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#getResourceAsStream(java.lang.String)
- *
- */
-
- public InputStream getResourceAsStream(String path) {
-
- return ExternalContextImpl.this.getResourceAsStream(path);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#getRequestDispatcher(java.lang.String)
- *
- */
-
- public RequestDispatcher getRequestDispatcher(String path) {
-
- return getCocoonHttpContext().getRequestDispatcher(path);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#getNamedDispatcher(java.lang.String)
- *
- */
-
- public RequestDispatcher getNamedDispatcher(String name) {
-
- return getCocoonHttpContext().getNamedDispatcher(name);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#getServlet(java.lang.String)
- *
- */
-
- public Servlet getServlet(String name) throws ServletException {
-
- return null;
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#getServlets()
- *
- */
-
- public Enumeration getServlets() {
-
- return null;
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#getServletNames()
- *
- */
-
- public Enumeration getServletNames() {
-
- return null;
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#log(java.lang.String)
- *
- */
-
- public void log(String msg) {
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#log(java.lang.Exception,
- *
- * java.lang.String)
- *
- */
-
- public void log(Exception exception, String msg) {
-
- // TODO Auto-generated method stub
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#log(java.lang.String,
- *
- * java.lang.Throwable)
- *
- */
-
- public void log(String message, Throwable throwable) {
-
- // TODO Auto-generated method stub
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#getRealPath(java.lang.String)
- *
- */
-
- public String getRealPath(String path) {
-
- // TODO Auto-generated method stub
-
- return getCocoonHttpContext().getRealPath(path);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#getServerInfo()
- *
- */
-
- public String getServerInfo() {
-
- // TODO Auto-generated method stub
-
- return null;
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#getInitParameter(java.lang.String)
- *
- */
-
- public String getInitParameter(String name) {
-
- // TODO Auto-generated method stub
-
- return ExternalContextImpl.this.getInitParameter(name);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#getInitParameterNames()
- *
- */
-
- public Enumeration getInitParameterNames() {
-
- // TODO Auto-generated method stub
-
- return null;
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#getAttribute(java.lang.String)
- *
- */
-
- public Object getAttribute(String name) {
-
- // TODO Auto-generated method stub
-
- return getCocoonHttpContext().getAttribute(name);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#getAttributeNames()
- *
- */
-
- public Enumeration getAttributeNames() {
-
- // TODO Auto-generated method stub
-
- return getCocoonHttpContext().getAttributeNames();
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#setAttribute(java.lang.String,
- *
- * java.lang.Object)
- *
- */
-
- public void setAttribute(String name, Object object) {
-
- // TODO Auto-generated method stub
-
- getCocoonHttpContext().setAttribute(name, object);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#removeAttribute(java.lang.String)
- *
- */
-
- public void removeAttribute(String name) {
-
- // TODO Auto-generated method stub
-
- getCocoonHttpContext().removeAttribute(name);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.servlet.ServletContext#getServletContextName()
- *
- */
-
- public String getServletContextName() {
-
- // TODO Auto-generated method stub
-
- return null;
-
- }
-
- };
-
- return servletContext; // .getContext(getRequestContextPath());
-
- // return getCocoonHttpContext();
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getInitParameter(java.lang.String)
- *
- */
-
- public String getInitParameter(String name) {
-
- // HACK - get init parameter from Action configuration instead of
-
- // servlet ...
-
- String ret = (String) getActionSettings().get(name);
-
- if (ret == null) {
-
- ret = this.getCocoonContext().getInitParameter(name);
-
- }
-
- return ret;
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getInitParameterMap()
- *
- */
-
- public Map getInitParameterMap() {
-
- // Combine Servlet InitParameters with Cocoon Action configuration
-
- // parameters ?
-
- if (initParameterMap == null) {
-
- initParameterMap = new ContextConcatentedMap(this
-
- .getActionSettings()) {
-
- public Object getBase(Object key) {
-
- // HACK - return configuration parameter from Cocoon
-
- // FacesAction
-
- return getCocoonContext().getInitParameter(key.toString());
-
- }
-
- protected Enumeration getEnumeration() {
-
- if (http) {
-
- return getCocoonHttpContext().getInitParameterNames();
-
- } else {
-
- return Collections.enumeration(Collections.EMPTY_SET);
-
- }
-
- }
-
- };
-
- }
-
- return initParameterMap;
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRemoteUser()
- *
- */
-
- public String getRemoteUser() {
-
- //
-
- return getCocoonRequest().getRemoteUser();
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequest()
- *
- */
-
- public Object getRequest() {
-
- return request;
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestContextPath()
- *
- */
-
- public String getRequestContextPath() {
-
- // TODO return Cocoon sitemap-specific path ? or configure from sitemap
-
- // parameters of Action.
-
- return getCocoonRequest().getContextPath();
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestCookieMap()
- *
- */
-
- public Map getRequestCookieMap() {
-
- //
-
- return getCocoonRequest().getCookieMap();
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestHeaderMap()
- *
- */
-
- public Map getRequestHeaderMap() {
-
- // TODO Return values of Http headers, or, may be, addition values from
-
- // Action parameters .
-
- if (requestHeaderMap == null) {
-
- requestHeaderMap = new ContextMap() {
-
- public Object get(Object key) {
-
- // TODO - return configuration parameter from Cocoon
-
- // FacesAction
-
- return getCocoonRequest().getHeader(key.toString());
-
- }
-
- protected Enumeration getEnumeration() {
-
- return getCocoonRequest().getHeaderNames();
-
- }
-
- };
-
- }
-
- return requestHeaderMap;
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestHeaderValuesMap()
- *
- */
-
- public Map getRequestHeaderValuesMap() {
-
- //
-
- if (requestHeaderValues == null) {
-
- requestHeaderValues = new ContextMap() {
-
- public Object get(Object key) {
-
- // TODO - return configuration parameter from Cocoon
-
- // FacesAction
-
- return getCocoonRequest().getHeaders(key.toString());
-
- }
-
- protected Enumeration getEnumeration() {
-
- return getCocoonRequest().getHeaderNames();
-
- }
-
- };
-
- }
-
- return requestHeaderValues;
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestLocale()
- *
- */
-
- public Locale getRequestLocale() {
-
- //
-
- return getCocoonRequest().getLocale();
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestLocales()
- *
- */
-
- public Iterator getRequestLocales() {
-
- //
-
- return new EnumerationIterator(getCocoonRequest().getLocales());
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestMap()
- *
- */
-
- public Map getRequestMap() {
-
- // TODO make Cocoon-specific realization ( interact with sitemap
-
- // parameters )
-
- if (requestMap == null) {
-
- requestMap = new ContextMap() {
-
- public Object get(Object key) {
-
- if (key == null) {
-
- throw new NullPointerException();
-
- }
-
- if ("javax.servlet.include.path_info".equals(key)) {
-
- return getRequestPathInfo();
-
- // return getCocoonRequest().getAttribute(
-
- // FacesAction.ACT_SRC);
-
- }
-
- if ("javax.servlet.include.servlet_path".equals(key)) {
-
- return getRequestServletPath();
-
- // return getCocoonRequest().getAttribute(
-
- // FacesAction.ACT_MAPPING);
-
- }
-
- return getCocoonRequest().getAttribute(key.toString());
-
- }
-
- public Object put(Object key, Object value) {
-
- if (key == null) {
-
- throw new NullPointerException();
-
- }
-
- String keyString = key.toString();
-
- Object result = getCocoonRequest().getAttribute(keyString);
-
- getCocoonRequest().setAttribute(keyString, value);
-
- return (result);
-
- }
-
- public Object remove(Object key) {
-
- if (key == null) {
-
- return null;
-
- }
-
- String keyString = key.toString();
-
- Object result = getCocoonRequest().getAttribute(keyString);
-
- getCocoonRequest().removeAttribute(keyString);
-
- return (result);
-
- }
-
- protected Enumeration getEnumeration() {
-
- return getCocoonRequest().getAttributeNames();
-
- }
-
- };
-
- }
-
- return requestMap;
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestParameterMap()
- *
- */
-
- public Map getRequestParameterMap() {
-
- //
-
- if (requestParameterMap == null) {
-
- requestParameterMap = new ContextConcatentedMap(
-
- (Map) (getCocoonRequest()
-
- .getAttribute(FacesAction.ACT_PARAMETERS))) {
-
- public Object getBase(Object key) {
-
- //
-
- return getCocoonRequest().getParameter(key.toString());
-
- }
-
- protected Enumeration getEnumeration() {
-
- return getCocoonRequest().getParameterNames();
-
- }
-
- };
-
- }
-
- return requestParameterMap;
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestParameterNames()
- *
- */
-
- public Iterator getRequestParameterNames() {
-
- // TODO Append Cocoon-specific parameters from FacesAction
-
- return this.getRequestParameterMap().entrySet().iterator();
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestParameterValuesMap()
- *
- */
-
- public Map getRequestParameterValuesMap() {
-
- //
-
- // TODO make Cocoon-specific realization ( interact with sitemap
-
- // parameters )
-
- if (requestParameterValuesMap == null) {
-
- requestParameterValuesMap = new ContextMap() {
-
- public Object get(Object key) {
-
- // TODO - return configuration parameter from Cocoon
-
- // FacesAction
-
- return getCocoonRequest()
-
- .getParameterValues(key.toString());
-
- }
-
- protected Enumeration getEnumeration() {
-
- return getCocoonRequest().getParameterNames();
-
- }
-
- };
-
- }
-
- return requestParameterValuesMap;
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestPathInfo()
- *
- */
-
- public String getRequestPathInfo() {
-
- //
-
- return (String) getCocoonRequest().getAttribute(FacesAction.ACT_SRC);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestServletPath()
- *
- */
-
- public String getRequestServletPath() {
-
- // TODO return current sitemap path ??? For cocoon, always "/" !
-
- return ""; // path;// ??? "";
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getResource(java.lang.String)
- *
- */
-
- public URL getResource(String path) throws MalformedURLException {
-
- //
-
- return getCocoonContext().getResource(path);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getResourceAsStream(java.lang.String)
- *
- */
-
- public InputStream getResourceAsStream(String path) {
-
- return getCocoonContext().getResourceAsStream(path);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getResourcePaths(java.lang.String)
- *
- */
-
- public Set getResourcePaths(String path) {
-
- // Cocoon Context do not Have such method ...
-
- return null; // getCocoonHttpContext().getResourcePaths(path);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getResponse()
- *
- */
-
- public Object getResponse() {
- return response;
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getSession(boolean)
- *
- */
-
- public Object getSession(boolean create) {
-
- // TODO Convert to HttpSession !!!
-
- return getCocoonRequest().getSession(create);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getSessionMap()
- *
- */
-
- public Map getSessionMap() {
-
- if (sessionMap == null) {
-
- sessionMap = new ContextMap() {
-
- public Object get(Object key) {
-
- if (key == null) {
-
- throw new NullPointerException();
-
- }
-
- return getCocoonSession().getAttribute(key.toString());
-
- }
-
- public Object put(Object key, Object value) {
-
- if (key == null) {
-
- throw new NullPointerException();
-
- }
-
- String keyString = key.toString();
-
- Session session = getCocoonSession();
-
- Object result = session.getAttribute(keyString);
-
- session.setAttribute(keyString, value);
-
- return (result);
-
- }
-
- public Object remove(Object key) {
-
- if (key == null) {
-
- return null;
-
- }
-
- String keyString = key.toString();
-
- Session session = getCocoonSession();
-
- Object result = session.getAttribute(keyString);
-
- session.removeAttribute(keyString);
-
- return (result);
-
- }
-
- protected Enumeration getEnumeration() {
-
- return getCocoonSession().getAttributeNames();
-
- }
-
- private Session getCocoonSession() {
-
- return (Session) getSession(true);
-
- }
-
- };
-
- }
-
- return sessionMap;
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getUserPrincipal()
- *
- */
-
- public Principal getUserPrincipal() {
-
- return getCocoonRequest().getUserPrincipal();
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#isUserInRole(java.lang.String)
- *
- */
-
- public boolean isUserInRole(String role) {
-
- return getCocoonRequest().isUserInRole(role);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#redirect(java.lang.String)
- *
- */
-
- public void redirect(String url) throws IOException {
-
- // use Redirector Stored In objectModel Map
-
- ActionRedirector redirector = (ActionRedirector) getCocoonRequest()
-
- .getAttribute(FacesAction.ACT_REDIRECTOR);
-
- if (redirector != null) {
-
- try {
-
- redirector.redirect(false, url);
-
- } catch (ProcessingException e) {
-
- throw new IOException(e.getMessage());
-
- }
-
- }
-
- }
-
- // Private methods - for Cocoon Context Interaction.
-
- // TODO - rewrite as lazy creation, but need reset with change Context ?
-
- // private Map getObjectModel() {
-
- // return ContextHelper.getObjectModel(getCocoonContext());
-
- // }
-
- private Request getCocoonRequest() {
-
- return request;
-
- }
-
- private Response getCocoonResponse() {
-
- return response;
-
- }
-
- private org.apache.cocoon.environment.Context getCocoonContext() {
-
- return context;
-
- }
-
- /**
- *
- * @return
- *
- */
-
- private HttpContext getCocoonHttpContext() {
-
- //
-
- return http ? (HttpContext) context : null;
-
- }
-
- /**
- *
- * @return
- *
- */
-
- private HttpRequest getCocoonHttpRequest() {
-
- // TODO Auto-generated method stub
-
- return http ? (HttpRequest) this.request : null;
-
- }
-
- /**
- *
- * @return
- *
- */
-
- private HttpResponse getCocoonHttpResponse() {
-
- // TODO Auto-generated method stub
-
- return http ? (HttpResponse) this.response : null;
-
- }
-
- // Private classes for Maps
-
- private class EnumerationIterator implements Iterator {
-
- public EnumerationIterator(Enumeration locales) {
-
- this.locales = locales;
-
- }
-
- private Enumeration locales;
-
- public boolean hasNext() {
-
- return locales.hasMoreElements();
-
- }
-
- public Object next() {
-
- return locales.nextElement();
-
- }
-
- public void remove() {
-
- throw new UnsupportedOperationException();
-
- }
-
- }
-
- /**
- *
- * @return Returns the actionSettings.
- *
- */
-
- private Map getActionSettings() {
-
- if (actionSettings == null) {
-
- actionSettings = (Map) this.getCocoonRequest().getAttribute(
-
- FacesAction.ACT_CONFIGURATION);
-
- if (null == actionSettings) {
-
- actionSettings = Collections.EMPTY_MAP;
-
- }
-
- }
-
- return actionSettings;
-
- }
-
-}
\ No newline at end of file
Modified: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextFactoryImpl.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextFactoryImpl.java 2007-04-10 18:26:37 UTC (rev 65)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextFactoryImpl.java 2007-04-11 16:04:01 UTC (rev 66)
@@ -18,7 +18,6 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
/*
* Created on 25.09.2004
@@ -52,18 +51,12 @@
* limitations under the License.
*/
-
package org.ajax4jsf.portlet.context;
-import java.util.Map;
-
import javax.faces.FacesException;
-
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
-
import javax.faces.context.FacesContextFactory;
-
import javax.faces.lifecycle.Lifecycle;
import javax.portlet.PortletContext;
import javax.portlet.PortletRequest;
@@ -86,65 +79,63 @@
*
*
*/
-
public class FacesContextFactoryImpl extends FacesContextFactory {
+ /**
+ *
+ * Hold <code>FacesContextFactory</code> from default implementation.
+ *
+ */
+ private FacesContextFactory defaultFacesContextFactory;
- /**
- *
- * Hold <code>FacesContextFactory</code> from default implementation.
- *
- */
+ public static final String FACES_CONTEXT_KEY = "COCOON_FACES_CONTEXT";
- private FacesContextFactory defaultFacesContextFactory;
-
- public static final String FACES_CONTEXT_KEY = "COCOON_FACES_CONTEXT";
-
- /**
- *
- * Create instance of Faces context factory, based on implementation.
- *
- * @param defaultFactory -
- *
- * Factory from JSF implementation.
- *
- */
-
- public FacesContextFactoryImpl(FacesContextFactory defaultFactory) {
- super();
- if (this.defaultFacesContextFactory == null) {
- this.defaultFacesContextFactory = defaultFactory;
- }
+ /**
+ *
+ * Create instance of Faces context factory, based on implementation.
+ *
+ * @param defaultFactory -
+ *
+ * Factory from JSF implementation.
+ *
+ */
+ public FacesContextFactoryImpl(FacesContextFactory defaultFactory) {
+ super();
+ if (this.defaultFacesContextFactory == null) {
+ this.defaultFacesContextFactory = defaultFactory;
}
+ }
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.FacesContextFactory#getFacesContext(java.lang.Object,
- *
- * java.lang.Object, java.lang.Object, javax.faces.lifecycle.Lifecycle)
- *
- */
-
- public FacesContext getFacesContext(Object context, Object request,
- Object response, Lifecycle lifecycle) throws FacesException {
- if(null == context || null == request || null == response || null == lifecycle){
- throw new NullPointerException("One or more parameters for a faces context instantiation is null");
- }
- ExternalContext externalContext;
- if(context instanceof PortletContext && request instanceof PortletRequest && response instanceof PortletResponse){
- externalContext = new PortletContextImpl( context,
- request,
- response);
- } else if(context instanceof ServletContext && request instanceof HttpServletRequest && response instanceof HttpServletResponse) {
- externalContext = new ServletContextImpl( context,
- request,
- response);
- }
- return new FacesContextImpl(externalContext,lifecycle);
-
+ /*
+ *
+ * (non-Javadoc)
+ *
+ *
+ *
+ * @see javax.faces.context.FacesContextFactory#getFacesContext(java.lang.Object,
+ *
+ * java.lang.Object, java.lang.Object, javax.faces.lifecycle.Lifecycle)
+ *
+ */
+ public FacesContext getFacesContext(Object context, Object request,
+ Object response, Lifecycle lifecycle) throws FacesException {
+ if ((null == context) || (null == request) || (null == response)
+ || (null == lifecycle)) {
+ throw new NullPointerException(
+ "One or more parameters for a faces context instantiation is null");
}
-
+ ExternalContext externalContext;
+ if ((context instanceof PortletContext)
+ && (request instanceof PortletRequest)
+ && (response instanceof PortletResponse)) {
+ externalContext = new PortletContextImpl(context, request, response);
+ } else if ((context instanceof ServletContext)
+ && (request instanceof HttpServletRequest)
+ && (response instanceof HttpServletResponse)) {
+ externalContext = new ServletContextImpl(context, request, response);
+ } else {
+ throw new FacesException(
+ "Unsupported environment. Only servlet or portlet is allowed");
+ }
+ return new FacesContextImpl(externalContext, lifecycle);
+ }
}
\ No newline at end of file
Modified: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextImpl.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextImpl.java 2007-04-10 18:26:37 UTC (rev 65)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextImpl.java 2007-04-11 16:04:01 UTC (rev 66)
@@ -18,7 +18,6 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
/*
* Created on 25.09.2004
@@ -52,45 +51,27 @@
* limitations under the License.
*/
-
package org.ajax4jsf.portlet.context;
import java.util.ArrayList;
import java.util.HashMap;
-
import java.util.Collections;
-
import java.util.Iterator;
-
import java.util.List;
-
import java.util.Map;
-
import javax.el.ELContext;
import javax.faces.FactoryFinder;
-
import javax.faces.application.Application;
-
import javax.faces.application.ApplicationFactory;
-
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.lifecycle.Lifecycle;
-
import javax.faces.render.RenderKit;
-
import javax.faces.render.RenderKitFactory;
/**
@@ -118,404 +99,288 @@
*
*
*/
-
public class FacesContextImpl extends FacesContext {
+ private boolean released = true;
- private boolean released = true;
+ private boolean renderResponse;
- private boolean renderResponse;
+ private boolean responseComplete;
- private boolean responseComplete;
+ private Application application;
- private Application application;
+ private UIViewRoot viewRoot;
- private UIViewRoot viewRoot;
+ private Map messages;
- private Map messages;
+ private ExternalContext externalContext;
- private ExternalContext externalContext;
+ private Lifecycle lifecycle;
- private Lifecycle lifecycle;
+ private ResponseWriter responseWriter;
- private ResponseWriter responseWriter;
+ private ResponseStream responseStream;
- private ResponseStream responseStream;
+ private ELContext elContext;
- private ELContext elContext;
+ public FacesContextImpl(ExternalContext externalContext, Lifecycle lifecycle) {
+ super();
+ setCurrentInstance(this);
+ this.externalContext = externalContext;
+ this.lifecycle = lifecycle;
+ }
- public FacesContextImpl(ExternalContext externalContext,
- Lifecycle lifecycle) {
- super();
- setCurrentInstance(this);
- this.externalContext = externalContext;
- this.lifecycle = lifecycle;
- }
+ /*
+ *
+ * (non-Javadoc)
+ *
+ *
+ *
+ * @see org.apache.cocoon.components.faces.context.CocoonFacesContext#getLifecycle()
+ *
+ */
+ public Lifecycle getLifecycle() {
+ return this.lifecycle;
+ }
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see org.apache.cocoon.components.faces.context.CocoonFacesContext#getLifecycle()
- *
- */
-
- public Lifecycle getLifecycle() {
-
- return lifecycle;
-
+ public ELContext getELContext() {
+ checkReleased();
+ if (this.elContext == null) {
+ this.elContext = new ELContextImpl(getApplication().getELResolver());
+ this.elContext.putContext(FacesContext.class, this);
+ UIViewRoot root = getViewRoot();
+ if (null != root) {
+ this.elContext.setLocale(root.getLocale());
+ }
}
+ return this.elContext;
+ }
+ /*
+ *
+ * (non-Javadoc)
+ *
+ *
+ *
+ * @see javax.faces.context.FacesContext#getExternalContext()
+ *
+ */
+ public ExternalContext getExternalContext() {
+ checkReleased();
+ return this.externalContext;
+ }
- public ELContext getELContext() {
- checkReleased();
- if (elContext == null) {
- elContext = new ELContextImpl(getApplication().getELResolver());
- elContext.putContext(FacesContext.class, this);
- UIViewRoot root = getViewRoot();
- if (null!=root) {
- elContext.setLocale(root.getLocale());
- }
- }
+ /**
+ *
+ * @param externalContext
+ *
+ * The externalContext to set.
+ *
+ */
+ // public void setExternalContext(ExternalContext externalContext) {
+ // this.externalContext = externalContext;
+ // }
+ /*
+ *
+ * (non-Javadoc)
+ *
+ *
+ *
+ * @see javax.faces.context.FacesContext#getResponseStream()
+ *
+ */
+ public ResponseStream getResponseStream() {
+ return this.responseStream;
+ }
- return elContext;
- }
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.FacesContext#getExternalContext()
- *
- */
+ /*
+ *
+ * (non-Javadoc)
+ *
+ *
+ *
+ * @see javax.faces.context.FacesContext#setResponseStream(javax.faces.context.ResponseStream)
+ *
+ */
+ public void setResponseStream(ResponseStream responseStream) {
+ this.responseStream = responseStream;
+ }
- public ExternalContext getExternalContext() {
- checkReleased();
- return externalContext;
- }
+ /*
+ *
+ * (non-Javadoc)
+ *
+ *
+ *
+ * @see javax.faces.context.FacesContext#getResponseWriter()
+ *
+ */
+ public ResponseWriter getResponseWriter() {
+ checkReleased();
+ return this.responseWriter;
+ }
- /**
- *
- * @param externalContext
- *
- * The externalContext to set.
- *
- */
+ /*
+ *
+ * (non-Javadoc)
+ *
+ *
+ *
+ * @see javax.faces.context.FacesContext#setResponseWriter(javax.faces.context.ResponseWriter)
+ *
+ */
+ public void setResponseWriter(ResponseWriter responseWriter) {
+ checkReleased();
+ this.responseWriter = responseWriter;
+ }
- // public void setExternalContext(ExternalContext externalContext) {
- // this.externalContext = externalContext;
- // }
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.FacesContext#getResponseStream()
- *
- */
+ /*
+ *
+ * (non-Javadoc)
+ *
+ *
+ *
+ * @see javax.faces.context.FacesContext#release()
+ *
+ */
+ public void release() {
+ // Release this and default instances...
+ this.released = true;
+ FacesContext.setCurrentInstance(null);
+ // defaultContext = null;
+ this.lifecycle = null;
+ this.externalContext = null;
+ this.responseWriter = null;
+ this.application = null;
+ this.viewRoot = null;
+ this.messages = null;
+ this.responseWriter = null;
+ }
- public ResponseStream getResponseStream() {
- return this.responseStream;
+ public Application getApplication() {
+ checkReleased();
+ if (this.application == null) {
+ ApplicationFactory aFactory = (ApplicationFactory) FactoryFinder
+ .getFactory(FactoryFinder.APPLICATION_FACTORY);
+ this.application = aFactory.getApplication();
}
+ return this.application;
+ }
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.FacesContext#setResponseStream(javax.faces.context.ResponseStream)
- *
- */
-
- public void setResponseStream(ResponseStream responseStream) {
- this.responseStream = responseStream;
+ public Iterator getClientIdsWithMessages() {
+ checkReleased();
+ if (this.messages == null) {
+ return Collections.EMPTY_LIST.iterator();
+ } else {
+ return this.messages.keySet().iterator();
}
+ }
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.FacesContext#getResponseWriter()
- *
- */
-
- public ResponseWriter getResponseWriter() {
- checkReleased();
- return responseWriter;
+ public Severity getMaximumSeverity() {
+ checkReleased();
+ Severity max = null;
+ Iterator messages = getMessages();
+ while (messages.hasNext()) {
+ FacesMessage msg = (FacesMessage) messages.next();
+ Severity severity = msg.getSeverity();
+ if ((null == max) || (max.getOrdinal() < severity.getOrdinal())) {
+ max = severity;
+ }
}
+ return max;
+ }
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.FacesContext#setResponseWriter(javax.faces.context.ResponseWriter)
- *
- */
-
- public void setResponseWriter(ResponseWriter responseWriter) {
- checkReleased();
- this.responseWriter = responseWriter;
+ public Iterator getMessages() {
+ checkReleased();
+ if (this.messages == null) {
+ return Collections.EMPTY_LIST.iterator();
}
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.FacesContext#release()
- *
- */
-
- public void release() {
-
- // Release this and default instances...
-
- this.released = true;
-
- FacesContext.setCurrentInstance(null);
-
- // defaultContext = null;
-
- this.lifecycle = null;
-
- this.externalContext = null;
-
- this.responseWriter = null;
-
- this.application = null;
-
- this.viewRoot = null;
-
- this.messages = null;
-
- this.responseWriter = null;
-
+ List messages = new ArrayList();
+ for (Iterator i = this.messages.values().iterator(); i.hasNext();) {
+ final List list = (List) i.next();
+ messages.addAll(list);
}
-
-
- public Application getApplication() {
-
- checkReleased();
-
- if (application == null) {
-
- ApplicationFactory aFactory = (ApplicationFactory) FactoryFinder
-
- .getFactory(FactoryFinder.APPLICATION_FACTORY);
-
- this.application = aFactory.getApplication();
-
- }
-
- return this.application;
-
+ if (messages.size() > 0) {
+ return messages.iterator();
}
+ return Collections.EMPTY_LIST.iterator();
+ }
- public Iterator getClientIdsWithMessages() {
-
- checkReleased();
-
- if (this.messages == null) {
-
- return Collections.EMPTY_LIST.iterator();
-
- } else {
-
- return this.messages.keySet().iterator();
-
- }
-
+ public Iterator getMessages(String clientID) {
+ checkReleased();
+ if (this.messages != null) {
+ final List list = (List) this.messages.get(clientID);
+ if (list != null) {
+ return list.iterator();
+ }
}
+ return Collections.EMPTY_LIST.iterator();
+ }
- public Severity getMaximumSeverity() {
- checkReleased();
- Severity max = null;
- Iterator messages = getMessages();
- while (messages.hasNext()) {
- FacesMessage msg = (FacesMessage) messages.next();
- Severity severity = msg.getSeverity();
- if(null == max || max.getOrdinal() < severity.getOrdinal()){
- max=severity;
- }
- }
- return max;
+ public RenderKit getRenderKit() {
+ checkReleased();
+ UIViewRoot viewRoot = getViewRoot();
+ if (viewRoot == null) {
+ return null;
}
-
- public Iterator getMessages() {
-
- checkReleased();
-
- if (this.messages == null) {
-
- return Collections.EMPTY_LIST.iterator();
-
- }
-
- List messages = new ArrayList();
-
- for (Iterator i = this.messages.values().iterator(); i.hasNext();) {
-
- final List list = (List) i.next();
-
- messages.addAll(list);
-
- }
-
- if (messages.size() > 0) {
-
- return messages.iterator();
-
- }
-
- return Collections.EMPTY_LIST.iterator();
-
+ String renderKitId = viewRoot.getRenderKitId();
+ if (renderKitId == null) {
+ return null;
+ } else {
+ RenderKitFactory rkFactory = (RenderKitFactory) FactoryFinder
+ .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ return rkFactory.getRenderKit(this, renderKitId);
}
+ }
- public Iterator getMessages(String clientID) {
+ public boolean getRenderResponse() {
+ checkReleased();
+ return this.renderResponse;
+ }
- checkReleased();
+ public boolean getResponseComplete() {
+ checkReleased();
+ return this.responseComplete;
+ }
- if (this.messages != null) {
+ public UIViewRoot getViewRoot() {
+ checkReleased();
+ return this.viewRoot;
+ }
- final List list = (List) this.messages.get(clientID);
+ public void setViewRoot(UIViewRoot viewRoot) {
+ checkReleased();
+ this.viewRoot = viewRoot;
+ }
- if (list != null) {
-
- return list.iterator();
-
- }
-
- }
-
- return Collections.EMPTY_LIST.iterator();
-
+ public void addMessage(String clientID, FacesMessage message) {
+ checkReleased();
+ if (message == null) {
+ throw new NullPointerException("Message can't be null");
}
-
- public RenderKit getRenderKit() {
-
- checkReleased();
-
- UIViewRoot viewRoot = getViewRoot();
-
- if (viewRoot == null) {
-
- return null;
-
- }
-
- String renderKitId = viewRoot.getRenderKitId();
-
- if (renderKitId == null) {
-
- return null;
-
- } else {
-
- RenderKitFactory rkFactory = (RenderKitFactory) FactoryFinder
-
- .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
-
- return rkFactory.getRenderKit(this, renderKitId);
-
- }
-
+ if (this.messages == null) {
+ this.messages = new HashMap();
}
-
- public boolean getRenderResponse() {
-
- checkReleased();
-
- return this.renderResponse;
-
+ List list = (List) this.messages.get(clientID);
+ if (list == null) {
+ list = new ArrayList();
+ this.messages.put(clientID, list);
}
+ list.add(message);
+ }
- public boolean getResponseComplete() {
+ public void renderResponse() {
+ checkReleased();
+ this.renderResponse = true;
+ }
- checkReleased();
+ public void responseComplete() {
+ checkReleased();
+ this.responseComplete = true;
+ }
- return this.responseComplete;
-
+ private void checkReleased() {
+ if (this.released) {
+ throw new IllegalStateException("Context is released.");
}
-
- public UIViewRoot getViewRoot() {
-
- checkReleased();
-
- return this.viewRoot;
-
- }
-
- public void setViewRoot(UIViewRoot viewRoot) {
-
- checkReleased();
-
- this.viewRoot = viewRoot;
-
- }
-
- public void addMessage(String clientID, FacesMessage message) {
-
- checkReleased();
-
- if (message == null) {
-
- throw new NullPointerException("Message can't be null");
-
- }
-
- if (messages == null) {
-
- messages = new HashMap();
-
- }
-
- List list = (List) messages.get(clientID);
-
- if (list == null) {
-
- list = new ArrayList();
-
- messages.put(clientID, list);
-
- }
-
- list.add(message);
-
- }
-
- public void renderResponse() {
-
- checkReleased();
-
- this.renderResponse = true;
-
- }
-
- public void responseComplete() {
-
- checkReleased();
-
- this.responseComplete = true;
-
- }
-
- private void checkReleased() {
-
- if (released) {
-
- throw new IllegalStateException("Context is released.");
-
- }
-
- }
-
+ }
}
\ No newline at end of file
Modified: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextWrapper.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextWrapper.java 2007-04-10 18:26:37 UTC (rev 65)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextWrapper.java 2007-04-11 16:04:01 UTC (rev 66)
@@ -4,7 +4,6 @@
package org.ajax4jsf.portlet.context;
import java.util.Iterator;
-
import javax.el.ELContext;
import javax.faces.application.Application;
import javax.faces.application.FacesMessage;
@@ -18,179 +17,178 @@
/**
* @author asmirnov
- *
+ *
*/
public class FacesContextWrapper extends FacesContext {
-
- private FacesContext _wrapped;
+ private FacesContext _wrapped;
- public FacesContextWrapper(FacesContext _wrapped) {
- super();
- this._wrapped = _wrapped;
- setCurrentInstance(this);
- }
+ public FacesContextWrapper(FacesContext _wrapped) {
+ super();
+ this._wrapped = _wrapped;
+ setCurrentInstance(this);
+ }
- /**
- * @param clientId
- * @param message
- * @see javax.faces.context.FacesContext#addMessage(java.lang.String, javax.faces.application.FacesMessage)
- */
- public void addMessage(String clientId, FacesMessage message) {
- _wrapped.addMessage(clientId, message);
- }
+ /**
+ * @param clientId
+ * @param message
+ * @see javax.faces.context.FacesContext#addMessage(java.lang.String,
+ * javax.faces.application.FacesMessage)
+ */
+ public void addMessage(String clientId, FacesMessage message) {
+ this._wrapped.addMessage(clientId, message);
+ }
- /**
- * @return
- * @see javax.faces.context.FacesContext#getApplication()
- */
- public Application getApplication() {
- return _wrapped.getApplication();
- }
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getApplication()
+ */
+ public Application getApplication() {
+ return this._wrapped.getApplication();
+ }
- /**
- * @return
- * @see javax.faces.context.FacesContext#getClientIdsWithMessages()
- */
- public Iterator getClientIdsWithMessages() {
- return _wrapped.getClientIdsWithMessages();
- }
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getClientIdsWithMessages()
+ */
+ public Iterator getClientIdsWithMessages() {
+ return this._wrapped.getClientIdsWithMessages();
+ }
- /**
- * @return
- * @see javax.faces.context.FacesContext#getELContext()
- */
- public ELContext getELContext() {
- return _wrapped.getELContext();
- }
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getELContext()
+ */
+ public ELContext getELContext() {
+ return this._wrapped.getELContext();
+ }
- /**
- * @return
- * @see javax.faces.context.FacesContext#getExternalContext()
- */
- public ExternalContext getExternalContext() {
- return _wrapped.getExternalContext();
- }
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getExternalContext()
+ */
+ public ExternalContext getExternalContext() {
+ return this._wrapped.getExternalContext();
+ }
- /**
- * @return
- * @see javax.faces.context.FacesContext#getMaximumSeverity()
- */
- public Severity getMaximumSeverity() {
- return _wrapped.getMaximumSeverity();
- }
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getMaximumSeverity()
+ */
+ public Severity getMaximumSeverity() {
+ return this._wrapped.getMaximumSeverity();
+ }
- /**
- * @return
- * @see javax.faces.context.FacesContext#getMessages()
- */
- public Iterator getMessages() {
- return _wrapped.getMessages();
- }
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getMessages()
+ */
+ public Iterator getMessages() {
+ return this._wrapped.getMessages();
+ }
- /**
- * @param clientId
- * @return
- * @see javax.faces.context.FacesContext#getMessages(java.lang.String)
- */
- public Iterator getMessages(String clientId) {
- return _wrapped.getMessages(clientId);
- }
+ /**
+ * @param clientId
+ * @return
+ * @see javax.faces.context.FacesContext#getMessages(java.lang.String)
+ */
+ public Iterator getMessages(String clientId) {
+ return this._wrapped.getMessages(clientId);
+ }
- /**
- * @return
- * @see javax.faces.context.FacesContext#getRenderKit()
- */
- public RenderKit getRenderKit() {
- return _wrapped.getRenderKit();
- }
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getRenderKit()
+ */
+ public RenderKit getRenderKit() {
+ return this._wrapped.getRenderKit();
+ }
- /**
- * @return
- * @see javax.faces.context.FacesContext#getRenderResponse()
- */
- public boolean getRenderResponse() {
- return _wrapped.getRenderResponse();
- }
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getRenderResponse()
+ */
+ public boolean getRenderResponse() {
+ return this._wrapped.getRenderResponse();
+ }
- /**
- * @return
- * @see javax.faces.context.FacesContext#getResponseComplete()
- */
- public boolean getResponseComplete() {
- return _wrapped.getResponseComplete();
- }
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getResponseComplete()
+ */
+ public boolean getResponseComplete() {
+ return this._wrapped.getResponseComplete();
+ }
- /**
- * @return
- * @see javax.faces.context.FacesContext#getResponseStream()
- */
- public ResponseStream getResponseStream() {
- return _wrapped.getResponseStream();
- }
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getResponseStream()
+ */
+ public ResponseStream getResponseStream() {
+ return this._wrapped.getResponseStream();
+ }
- /**
- * @return
- * @see javax.faces.context.FacesContext#getResponseWriter()
- */
- public ResponseWriter getResponseWriter() {
- return _wrapped.getResponseWriter();
- }
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getResponseWriter()
+ */
+ public ResponseWriter getResponseWriter() {
+ return this._wrapped.getResponseWriter();
+ }
- /**
- * @return
- * @see javax.faces.context.FacesContext#getViewRoot()
- */
- public UIViewRoot getViewRoot() {
- return _wrapped.getViewRoot();
- }
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getViewRoot()
+ */
+ public UIViewRoot getViewRoot() {
+ return this._wrapped.getViewRoot();
+ }
- /**
- *
- * @see javax.faces.context.FacesContext#release()
- */
- public void release() {
- _wrapped.release();
- _wrapped = null;
- }
+ /**
+ *
+ * @see javax.faces.context.FacesContext#release()
+ */
+ public void release() {
+ this._wrapped.release();
+ this._wrapped = null;
+ }
- /**
- *
- * @see javax.faces.context.FacesContext#renderResponse()
- */
- public void renderResponse() {
- _wrapped.renderResponse();
- }
+ /**
+ *
+ * @see javax.faces.context.FacesContext#renderResponse()
+ */
+ public void renderResponse() {
+ this._wrapped.renderResponse();
+ }
- /**
- *
- * @see javax.faces.context.FacesContext#responseComplete()
- */
- public void responseComplete() {
- _wrapped.responseComplete();
- }
+ /**
+ *
+ * @see javax.faces.context.FacesContext#responseComplete()
+ */
+ public void responseComplete() {
+ this._wrapped.responseComplete();
+ }
- /**
- * @param responseStream
- * @see javax.faces.context.FacesContext#setResponseStream(javax.faces.context.ResponseStream)
- */
- public void setResponseStream(ResponseStream responseStream) {
- _wrapped.setResponseStream(responseStream);
- }
+ /**
+ * @param responseStream
+ * @see javax.faces.context.FacesContext#setResponseStream(javax.faces.context.ResponseStream)
+ */
+ public void setResponseStream(ResponseStream responseStream) {
+ this._wrapped.setResponseStream(responseStream);
+ }
- /**
- * @param responseWriter
- * @see javax.faces.context.FacesContext#setResponseWriter(javax.faces.context.ResponseWriter)
- */
- public void setResponseWriter(ResponseWriter responseWriter) {
- _wrapped.setResponseWriter(responseWriter);
- }
+ /**
+ * @param responseWriter
+ * @see javax.faces.context.FacesContext#setResponseWriter(javax.faces.context.ResponseWriter)
+ */
+ public void setResponseWriter(ResponseWriter responseWriter) {
+ this._wrapped.setResponseWriter(responseWriter);
+ }
- /**
- * @param root
- * @see javax.faces.context.FacesContext#setViewRoot(javax.faces.component.UIViewRoot)
- */
- public void setViewRoot(UIViewRoot root) {
- _wrapped.setViewRoot(root);
- }
-
+ /**
+ * @param root
+ * @see javax.faces.context.FacesContext#setViewRoot(javax.faces.component.UIViewRoot)
+ */
+ public void setViewRoot(UIViewRoot root) {
+ this._wrapped.setViewRoot(root);
+ }
}
Modified: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/PortletContextImpl.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/PortletContextImpl.java 2007-04-10 18:26:37 UTC (rev 65)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/PortletContextImpl.java 2007-04-11 16:04:01 UTC (rev 66)
@@ -3,39 +3,244 @@
*/
package org.ajax4jsf.portlet.context;
+import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import java.security.Principal;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
import java.util.Set;
+import javax.faces.FacesException;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.PortletResponse;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
/**
* @author asmirnov
- *
+ *
*/
public class PortletContextImpl extends AbstractExternalContext {
+ public PortletContextImpl(Object context, Object request, Object response) {
+ super(context, request, response);
+ }
+
+ private PortletContext getPortletContext(){
+ return (PortletContext) getContext();
+ }
+
+ private PortletRequest getPortletRequest(){
+ return (PortletRequest) getRequest();
+ }
+
+ private PortletResponse getPortletResponse(){
+ return (PortletResponse) getResponse();
+ }
- public PortletContextImpl(Object context, Object request, Object response) {
- super(context, request, response);
- }
+ public String getInitParameter(String name) {
+ return getPortletContext().getInitParameter(name);
+ }
- public String getInitParameter(String name) {
- // TODO Auto-generated method stub
- return null;
- }
+ public URL getResource(String path) throws MalformedURLException {
+ return getPortletContext().getResource(path);
+ }
- public URL getResource(String path) throws MalformedURLException {
- // TODO Auto-generated method stub
- return null;
+ public InputStream getResourceAsStream(String path) {
+ return getPortletContext().getResourceAsStream(path);
+ }
+
+ public Set getResourcePaths(String path) {
+ return getPortletContext().getResourcePaths(path);
+ }
+
+ protected Enumeration enumerateRequestParameterNames() {
+ return getPortletRequest().getParameterNames();
+ }
+
+ protected Object getContextAttribute(String name) {
+ return getPortletContext().getAttribute(name);
+ }
+
+ protected Enumeration getContextAttributeNames() {
+ return getPortletContext().getAttributeNames();
+ }
+
+ protected Enumeration getInitParametersNames() {
+ return getPortletContext().getInitParameterNames();
+ }
+
+ protected Object getRequestAttribute(String name) {
+ return getPortletRequest().getAttribute(name);
+ }
+
+ protected Enumeration getRequestAttributeNames() {
+ return getPortletRequest().getAttributeNames();
+ }
+
+ public Map getRequestParameterValuesMap() {
+ return getPortletRequest().getParameterMap();
+ }
+
+ protected Object getRequestParameterValues(String name) {
+ return getPortletRequest().getParameterValues(name);
+ }
+
+ protected Object getRequestHeader(String name) {
+ return null;
+ }
+
+ protected Enumeration getRequestHeaderNames() {
+ return Collections.enumeration(Collections.EMPTY_LIST);
+ }
+
+ protected Object[] getRequestHeaderValues(String name) {
+ return null;
+ }
+
+ protected Object getRequestParameter(String name) {
+ return getPortletRequest().getParameter(name);
+ }
+
+ protected Object getSessionAttribute(String name) {
+ return getPortletRequest().getPortletSession(true).getAttribute(name);
+ }
+
+ protected Enumeration getSessionAttributeNames() {
+ return getPortletRequest().getPortletSession(true).getAttributeNames();
+ }
+
+ protected void removeContextAttribute(String name) {
+ getPortletContext().removeAttribute(name);
+ }
+
+ protected void removeRequestAttribute(String name) {
+ getPortletRequest().removeAttribute(name);
+ }
+
+ protected void removeSessionAttribute(String name) {
+ getPortletRequest().getPortletSession(true).removeAttribute(name);
+ }
+
+ protected void setContextAttribute(String name, Object value) {
+ getPortletContext().setAttribute(name, value);
+ }
+
+ protected void setRequestAttribute(String name, Object value) {
+ getPortletRequest().setAttribute(name, value);
+ }
+
+ protected void setSessionAttribute(String name, Object value) {
+ getPortletRequest().getPortletSession(true).setAttribute(name, value);
+ }
+
+ public void dispatch(String path) throws IOException {
+ if(null==path){
+ throw new NullPointerException("Path to new view is null");
}
+ if(!(getRequest() instanceof RenderRequest && getResponse() instanceof RenderResponse)){
+ throw new IllegalStateException("Dispatch to new view not at render phase");
+ }
+ PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher(path);
+ if(null == dispatcher){
+ throw new IllegalStateException("Dispatcher for render request is not created");
+ }
+ try {
+ dispatcher.include((RenderRequest)getRequest(), (RenderResponse)getResponse());
+ } catch (PortletException e) {
+ throw new FacesException(e);
+ }
+
+ }
- public InputStream getResourceAsStream(String path) {
- // TODO Auto-generated method stub
- return null;
+ public String encodeActionURL(String url) {
+ if (null == url) {
+ throw new NullPointerException();
+ }
+ return url;
+ }
+
+ public String encodeNamespace(String name) {
+ Object response = getResponse();
+ if (response instanceof RenderResponse) {
+ RenderResponse renderResponse = (RenderResponse) response;
+ return renderResponse.getNamespace()+name;
+ } else {
+ throw new IllegalStateException("Namespace requested not in render portlet phase");
}
+ }
- public Set getResourcePaths(String path) {
- // TODO Auto-generated method stub
- return null;
+ public String encodeResourceURL(String url) {
+ return getPortletResponse().encodeURL(url);
+ }
+
+ public String getAuthType() {
+ return getPortletRequest().getAuthType();
+ }
+
+ public String getRemoteUser() {
+ return getPortletRequest().getRemoteUser();
+ }
+
+ public String getRequestContextPath() {
+ return getPortletRequest().getContextPath();
+ }
+
+ public Locale getRequestLocale() {
+ return getPortletRequest().getLocale();
+ }
+
+ public Iterator getRequestLocales() {
+ return new EnumerationIterator(getPortletRequest().getLocales());
+ }
+
+ public String getRequestPathInfo() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getRequestServletPath() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object getSession(boolean create) {
+ return getPortletRequest().getPortletSession();
+ }
+
+ public Principal getUserPrincipal() {
+ return getPortletRequest().getUserPrincipal();
+ }
+
+ public boolean isUserInRole(String role) {
+ return getPortletRequest().isUserInRole(role);
+ }
+
+ public void log(String message) {
+ getPortletContext().log(message);
+ }
+
+ public void log(String message, Throwable exception) {
+ getPortletContext().log(message, exception);
+
+ }
+
+ public void redirect(String url) throws IOException {
+ if(null==url){
+ throw new NullPointerException("Path to redirect is null");
}
-
+ if(!(getRequest() instanceof ActionRequest && getResponse() instanceof ActionResponse)){
+ throw new IllegalStateException("Redirect to new url not at action phase");
+ }
+ ((ActionResponse)getResponse()).sendRedirect(url);
+ }
}
Modified: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ServletContextImpl.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ServletContextImpl.java 2007-04-10 18:26:37 UTC (rev 65)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ServletContextImpl.java 2007-04-11 16:04:01 UTC (rev 66)
@@ -3,110 +3,249 @@
*/
package org.ajax4jsf.portlet.context;
+import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
-
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @author asmirnov
- *
+ *
*/
public class ServletContextImpl extends AbstractExternalContext {
+ /**
+ * @param context
+ * @param request
+ * @param response
+ */
+ public ServletContextImpl(Object context, Object request, Object response) {
+ super(context, request, response);
+ }
- /**
- * @param context
- * @param request
- * @param response
- */
- public ServletContextImpl(Object context, Object request, Object response) {
- super(context, request, response);
- }
-
- private HttpServletRequest getHttpRequest(){
- return (HttpServletRequest) getRequest();
- }
-
- private ServletContext getServletContext(){
- return (ServletContext) getContext();
- }
+ private HttpServletRequest getHttpRequest() {
+ return (HttpServletRequest) getRequest();
+ }
- private HttpServletResponse getHttpResponse(){
- return (HttpServletResponse) getResponse();
- }
- /* (non-Javadoc)
- * @see javax.faces.context.ExternalContext#getInitParameter(java.lang.String)
- */
- public String getInitParameter(String name) {
- return getServletContext().getInitParameter(name);
- }
-
- protected Enumeration getInitParametersNames() {
- return getServletContext().getInitParameterNames();
- }
+ private ServletContext getServletContext() {
+ return (ServletContext) getContext();
+ }
- /* (non-Javadoc)
- * @see javax.faces.context.ExternalContext#getResource(java.lang.String)
- */
- public URL getResource(String path) throws MalformedURLException {
- return getServletContext().getResource(path);
- }
+ private HttpServletResponse getHttpResponse() {
+ return (HttpServletResponse) getResponse();
+ }
- /* (non-Javadoc)
- * @see javax.faces.context.ExternalContext#getResourceAsStream(java.lang.String)
- */
- public InputStream getResourceAsStream(String path) {
- return getServletContext().getResourceAsStream(path);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.context.ExternalContext#getInitParameter(java.lang.String)
+ */
+ public String getInitParameter(String name) {
+ return getServletContext().getInitParameter(name);
+ }
- /* (non-Javadoc)
- * @see javax.faces.context.ExternalContext#getResourcePaths(java.lang.String)
- */
- public Set getResourcePaths(String path) {
- // TODO Auto-generated method stub
- return getServletContext().getResourcePaths(path);
- }
+ protected Enumeration getInitParametersNames() {
+ return getServletContext().getInitParameterNames();
+ }
- protected Object getContextAttribute(String name) {
- return getServletContext().getAttribute(name);
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.context.ExternalContext#getResource(java.lang.String)
+ */
+ public URL getResource(String path) throws MalformedURLException {
+ return getServletContext().getResource(path);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.context.ExternalContext#getResourceAsStream(java.lang.String)
+ */
+ public InputStream getResourceAsStream(String path) {
+ return getServletContext().getResourceAsStream(path);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.context.ExternalContext#getResourcePaths(java.lang.String)
+ */
+ public Set getResourcePaths(String path) {
+ return getServletContext().getResourcePaths(path);
+ }
+
+ protected Object getContextAttribute(String name) {
+ return getServletContext().getAttribute(name);
+ }
+
+ protected Enumeration getContextAttributeNames() {
+ return getServletContext().getAttributeNames();
+ }
+
+ protected void setContextAttribute(String name, Object value) {
+ getServletContext().setAttribute(name, value);
+ }
+
+ public String getAuthType() {
+ return getHttpRequest().getAuthType();
+ }
+
+ public String getRemoteUser() {
+ return getHttpRequest().getRemoteUser();
+ }
+
+ public String getRequestContextPath() {
+ return getHttpRequest().getContextPath();
+ }
+
+ public String getRequestPathInfo() {
+ return getHttpRequest().getPathInfo();
+ }
+
+ public String getRequestServletPath() {
+ return getHttpRequest().getServletPath();
+ }
+
+ protected Enumeration enumerateRequestParameterNames() {
+ return getHttpRequest().getParameterNames();
+ }
+
+ protected Object getRequestAttribute(String name) {
+ return getHttpRequest().getAttribute(name);
+ }
+
+ protected Enumeration getRequestAttributeNames() {
+ return getHttpRequest().getAttributeNames();
+ }
+
+ protected Object getRequestParameterValues(String name) {
+ return getHttpRequest().getParameterValues(name);
+ }
+
+ protected Object getRequestHeader(String name) {
+ return getHttpRequest().getHeader(name);
+ }
+
+ protected Enumeration getRequestHeaderNames() {
+ return getHttpRequest().getHeaderNames();
+ }
+
+ protected Object[] getRequestHeaderValues(String name) {
+ Enumeration values = getHttpRequest().getHeaders(name);
+ ArrayList valuesList = new ArrayList();
+ while (values.hasMoreElements()) {
+ valuesList.add(values.nextElement());
}
-
- protected Enumeration getContextAttributeNames() {
- return getServletContext().getAttributeNames();
- }
-
- protected void setContextAttribute(String name, Object value) {
- getServletContext().setAttribute(name, value);
- }
-
- public String getAuthType() {
- return getHttpRequest().getAuthType();
- }
-
- public String getRemoteUser() {
- return getHttpRequest().getRemoteUser();
- }
+ return valuesList.toArray();
+ }
- public String getRequestContextPath() {
- return getHttpRequest().getContextPath();
- }
-
- public String getRequestPathInfo() {
- return getHttpRequest().getPathInfo();
- }
-
- public String getRequestServletPath() {
- return getHttpRequest().getServletPath();
- }
-
- public Map getRequestCookieMap() {
- // TODO Auto-generated method stub
- return getHttpRequest().;
- }
+ protected Object getRequestParameter(String name) {
+ return getHttpRequest().getParameter(name);
+ }
+
+ protected Object getSessionAttribute(String name) {
+ return getHttpRequest().getSession(true).getAttribute(name);
+ }
+
+ protected Enumeration getSessionAttributeNames() {
+ return getHttpRequest().getSession(true).getAttributeNames();
+ }
+
+ protected void removeContextAttribute(String name) {
+ getHttpRequest().getSession(true).removeAttribute(name);
+ }
+
+ protected void removeRequestAttribute(String name) {
+ getHttpRequest().removeAttribute(name);
+ }
+
+ protected void removeSessionAttribute(String name) {
+ getHttpRequest().getSession(true).removeAttribute(name);
+ }
+
+ protected void setRequestAttribute(String name, Object value) {
+ getHttpRequest().setAttribute(name, value);
+ }
+
+ protected void setSessionAttribute(String name, Object value) {
+ getHttpRequest().getSession(true).setAttribute(name, value);
+ }
+
+ public void dispatch(String path) throws IOException {
+ RequestDispatcher requestDispatcher = getHttpRequest().getRequestDispatcher(path);
+ if (requestDispatcher == null) {
+ (getHttpResponse()).
+ sendError(HttpServletResponse.SC_NOT_FOUND);
+ return;
+ }
+ try {
+ requestDispatcher.forward(getHttpRequest(), getHttpResponse());
+ } catch (IOException ioe) {
+ throw ioe;
+ } catch (ServletException se) {
+ throw new FacesException(se);
+ }
+
+ }
+
+ public String encodeActionURL(String url) {
+ return getHttpResponse().encodeURL(url);
+ }
+
+ public String encodeNamespace(String name) {
+ return name;
+ }
+
+ public String encodeResourceURL(String url) {
+ return getHttpResponse().encodeURL(url);
+ }
+
+ public Locale getRequestLocale() {
+ return getHttpRequest().getLocale();
+ }
+
+ public Iterator getRequestLocales() {
+ return new EnumerationIterator(getHttpRequest().getLocales());
+ }
+
+ public Object getSession(boolean create) {
+ return getHttpRequest().getSession(create);
+ }
+
+ public Principal getUserPrincipal() {
+ return getHttpRequest().getUserPrincipal();
+ }
+
+ public boolean isUserInRole(String role) {
+ return getHttpRequest().isUserInRole(role);
+ }
+
+ public void log(String message) {
+ getServletContext().log(message);
+ }
+
+ public void log(String message, Throwable exception) {
+ getServletContext().log(message, exception);
+ }
+
+ public void redirect(String url) throws IOException {
+ getHttpResponse().sendRedirect(url);
+ FacesContext.getCurrentInstance().responseComplete();
+ }
}
Deleted: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/lifecycle/LifecycleFactoryImpl.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/lifecycle/LifecycleFactoryImpl.java 2007-04-10 18:26:37 UTC (rev 65)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/lifecycle/LifecycleFactoryImpl.java 2007-04-11 16:04:01 UTC (rev 66)
@@ -1,111 +0,0 @@
-/*
- * CDDL HEADER START
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the License). You may not use this file except in
- * compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://www.sun.com/cddl/cddl.html and legal/CDDLv1.0.txt
- * See the License for the specific language governing
- * permission and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * Header Notice in each file and include the License file
- * at legal/CDDLv1.0.txt.
- * If applicable, add the following below the CDDL Header,
- * with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
- * CDDL HEADER END
- */
-
-package org.ajax4jsf.portlet.lifecycle;
-
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.faces.lifecycle.Lifecycle;
-import javax.faces.lifecycle.LifecycleFactory;
-
-
-/**
- * <p>Custom implementation of <code>LifecycleFactory</code> that
- * provides the portlet-specific <code>Lifecycle</code> by default.</p>
- */
-
-public final class LifecycleFactoryImpl extends LifecycleFactory {
-
- // The Logger instance for this class
- private static Logger logger = Logger.getLogger(LifecycleFactoryImpl.class.getPackage().getName(), "JSFPLogMessages");
-
- // ------------------------------------------------------------ Constructors
-
-
- public LifecycleFactoryImpl() {
- logger.log(Level.FINE, "PS_CSFP0023", this);
- addLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE, new LifecycleImpl());
- }
-
-
- // ------------------------------------------------------ Instance Variables
-
-
- // Registered Lifecycle instances, keyed by lifecycle identifier
- private Map lifecycles = new HashMap();
-
-
- // ---------------------------------------------------------- Public Methods
-
-
- public void addLifecycle(String lifecycleId, Lifecycle lifecycle) {
-
- if ((lifecycleId == null) || (lifecycle == null)) {
- throw new NullPointerException();
- }
- synchronized (lifecycles) {
- if (lifecycles.containsKey(lifecycleId)) {
- throw new IllegalArgumentException(lifecycleId);
- }
- lifecycles.put(lifecycleId, lifecycle);
- }
- logger.log(Level.FINER, "PS_CSFP0024", lifecycleId);
- }
-
-
- public Lifecycle getLifecycle(String lifecycleId) {
-
- if (lifecycleId == null) {
- throw new NullPointerException();
- }
- synchronized (lifecycles) {
- Lifecycle lifecycle = (Lifecycle) lifecycles.get(lifecycleId);
- if (lifecycle != null) {
- if(logger.isLoggable(Level.FINER)){
- logger.log(Level.FINER, "PS_CSFP0025", new Object[] { lifecycle, lifecycleId});
- }
- return (lifecycle);
- } else {
- throw new IllegalArgumentException(lifecycleId);
- }
- }
-
- }
-
-
- public Iterator getLifecycleIds() {
-
- synchronized (lifecycles) {
- return (lifecycles.keySet().iterator());
- }
-
- }
-
-
-}
Deleted: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/lifecycle/LifecycleImpl.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/lifecycle/LifecycleImpl.java 2007-04-10 18:26:37 UTC (rev 65)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/lifecycle/LifecycleImpl.java 2007-04-11 16:04:01 UTC (rev 66)
@@ -1,752 +0,0 @@
-/*
- * CDDL HEADER START
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the License). You may not use this file except in
- * compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://www.sun.com/cddl/cddl.html and legal/CDDLv1.0.txt
- * See the License for the specific language governing
- * permission and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * Header Notice in each file and include the License file
- * at legal/CDDLv1.0.txt.
- * If applicable, add the following below the CDDL Header,
- * with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
- * CDDL HEADER END
- */
-
-package org.ajax4jsf.portlet.lifecycle;
-
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-
-import javax.faces.FacesException;
-import javax.faces.application.FacesMessage;
-import javax.faces.application.ViewHandler;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-import javax.faces.event.PhaseEvent;
-import javax.faces.event.PhaseId;
-import javax.faces.event.PhaseListener;
-import javax.faces.lifecycle.Lifecycle;
-import javax.faces.render.RenderKitFactory;
-
-import javax.portlet.PortletSession;
-
-
-
-/**
- * <p>Custom implementation of <code>Lifecycle</code> that implements a
- * portlet-specific <code>Lifecycle</code>.</p>
- */
-
-public final class LifecycleImpl extends Lifecycle {
-
-
- // -------------------------------------------------------- Static Variables
-
-
- // The Logger instance for this class
- private static Logger logger = Logger.getLogger(LifecycleImpl.class.getPackage().getName(), "JSFPLogMessages");
-
- /**
- * <p>Portlet initialization parameter which holds the value of one of
- * initial mode identifier. i.e either INIT_VIEW_PARAMETER or
- * INIT_EDIT_PARAMETER or INIT_HELP_PARAMETER</p>
- */
- public static final String INIT_PARAMETER =
- "com.sun.faces.portlet.INIT";
-
- /**
- * <p>Portlet initialization parameter under which the application
- * may specify an initial view mode identifier to be displayed.</p>
- */
- public static final String INIT_VIEW_PARAMETER =
- "com.sun.faces.portlet.INIT_VIEW";
-
- /**
- * <p>Portlet initialization parameter under which the application
- * may specify an initial edit mode identifier to be displayed.</p>
- */
- public static final String INIT_EDIT_PARAMETER =
- "com.sun.faces.portlet.INIT_EDIT";
-
- /**
- * <p>Portlet initialization parameter under which the application
- * may specify an initial help mode identifier to be displayed.</p>
- */
- public static final String INIT_HELP_PARAMETER =
- "com.sun.faces.portlet.INIT_HELP";
-
- /**
- * <p>Portlet session attribute (in portlet scope) under which we will
- * save the window state identifer. i.e one of the WINDOW_STATE_ATTR_* values.</p>
- */
- private static final String PREVIOUS_WINDOW_STATE =
- "com.sun.faces.portlet.PREVIOUS_WINDOW_STATE";
-
- /**
- * <p>Portlet session attribute (in portlet scope) under which we will
- * save state information for VIEW for the current window.</p>
- */
- private static final String WINDOW_STATE_ATTR_VIEW =
- "com.sun.faces.portlet.WINDOW_STATE_VIEW";
-
- /**
- * <p>Portlet session attribute (in portlet scope) under which we will
- * save state information for EDIT for the current window.</p>
- */
- private static final String WINDOW_STATE_ATTR_EDIT =
- "com.sun.faces.portlet.WINDOW_STATE_EDIT";
-
- /**
- * <p>Portlet session attribute (in portlet scope) under which we will
- * save state information for HELP for the current window.</p>
- */
- private static final String WINDOW_STATE_ATTR_HELP =
- "com.sun.faces.portlet.WINDOW_STATE_HELP";
-
-
- /**
- * <p>Portlet session attribute (in portlet scope) under which we will
- * save a Boolean TRUE or FALSE for the current window.</p>
- */
- public static final String ERROR_FLAG =
- "com.sun.faces.portlet.ERROR_FLAG";
-
-
- // ------------------------------------------------------ Instance Variables
-
-
- /**
- * <p>The set of <code>PhaseListener</code>s registered with this
- * <code>Lifecycle</code> instance, in order of registration.</p>
- */
- private List listeners = new ArrayList();
-
-
- /**
- * <p>The set of {@link Phase} instances that are to be
- * executed by the <code>execute()</code> method, in order by the
- * ordinal property of each phase.</p>
- */
- private Phase phases[] = {
- null, // ANY_PHASE holder
- new RestoreViewPhase(),
- new ApplyRequestValuesPhase(),
- new ProcessValidationsPhase(),
- new UpdateModelValuesPhase(),
- new InvokeApplicationPhase()
- };
-
-
- /**
- * <p>The {@link Phase} instance to process Render Response phase.</p>
- */
- private Phase response = new RenderResponsePhase();
-
-
- // ------------------------------------------------------------ Constructors
-
-
- /**
- * <p>Construct a new <code>LifecycleImpl</code> instance.</p>
- */
- public LifecycleImpl() {
- super();
- logger.log(Level.FINEST, "PS_CSFP0026", this);
- }
-
-
- // ------------------------------------------------------- Lifecycle Methods
-
-
- // Add a new PhaseListener to the set of registered listeners
- public void addPhaseListener(PhaseListener listener) {
-
- if (listener == null) {
- throw new NullPointerException();
- }
- if (logger.isLoggable(Level.FINER)) {
- logger.log(Level.FINER, "PS_CSFP0027", new Object[]{ listener.getPhaseId(), listener});
- }
- synchronized (listeners) {
- listeners.add(listener);
- }
-
- }
-
-
- // Execute the phases up to but not including Render Response
- public void execute(FacesContext context) throws FacesException {
-
- if (context == null) {
- throw new NullPointerException();
- }
-
- logger.log(Level.FINEST, "PS_CSFP0028", context);
-
- restore(context, true);
-
- setErrorFlag(context, Boolean.FALSE);
-
- for (int i = 1; i < phases.length; i++) {
- PhaseId phaseId = (PhaseId) PhaseId.VALUES.get(i);
- if (context.getRenderResponse() ||
- context.getResponseComplete()) {
- /*
- (a) If there are any validation/conversion errors, then its an error.
- (b) If there are no validation/conversion errors, it means either
- immediate=true is specified or FacesContext.renderResponse() has been
- called.
- */
- Iterator itr = context.getMessages();
- if(itr.hasNext()) {
- setErrorFlag(context, Boolean.TRUE);
- }
- break;
- }
- phase(phaseId, phases[i], context);
- }
-
- save(context, true);
-
- }
-
-
- // Return the set of PhaseListeners that have been registered
- public PhaseListener[] getPhaseListeners() {
-
- synchronized (listeners) {
- PhaseListener results[] = new PhaseListener[listeners.size()];
- return ((PhaseListener[]) listeners.toArray(results));
- }
-
- }
-
-
- // Execute the Render Response phase
- public void render(FacesContext context) throws FacesException {
- if (context == null) {
- throw new NullPointerException();
- }
-
- logger.log(Level.FINEST, "PS_CSFP0029" , context);
-
- restore(context, false);
-
- setErrorFlag(context, Boolean.FALSE);
-
- if (!context.getResponseComplete()) {
- phase(PhaseId.RENDER_RESPONSE, response, context);
- }
-
- save(context, false);
- }
-
-
- // Remove a registered PhaseListener from the set of registered listeners
- public void removePhaseListener(PhaseListener listener) {
-
- if (listener == null) {
- throw new NullPointerException();
- }
- if (logger.isLoggable(Level.FINER)) {
- logger.log(Level.FINER, "PS_CSFP0030", new Object[] { listener.getPhaseId(),listener});
- }
- synchronized (listeners) {
- listeners.remove(listener);
- }
-
- }
-
-
- // --------------------------------------------------------- Private Methods
-
-
- /**
- * <p>Execute the specified phase instance for the current request.</p>
- *
- * @param phaseId Phase identifier of the current phase
- * @param phase {@link Phase} instance to execute
- * @param context <code>FacesContext</code> for the current request
- *
- * @exception FacesException if thrown by the phase execution
- */
- private void phase(PhaseId phaseId, Phase phase, FacesContext context)
- throws FacesException {
-
- boolean exceptionThrownInRender = false;
- Exception tempException = null;
-
- if (logger.isLoggable(Level.FINEST)) {
- logger.log(Level.FINEST, "PS_CSFP0031", new Object[] {phaseId, context});
- }
-
- // Acquire (once) the list of interested phase listeners
- // Clone it so that we are independent of changes during the
- // execution of this phase
- PhaseListener listeners[] = getPhaseListeners();
-
- try {
-
- // Notify the "beforePhase" method of interested listeners
- if (listeners.length > 0) {
- PhaseEvent event = new PhaseEvent(context, phaseId, this);
- for (int i = 0; i < listeners.length; i++) {
- if (phaseId.equals(listeners[i].getPhaseId()) ||
- PhaseId.ANY_PHASE.equals(listeners[i].getPhaseId())) {
- listeners[i].beforePhase(event);
- }
- }
- }
-
- } catch (Exception e) {
-
- // Log the problem, but continue
- if (logger.isLoggable(Level.INFO)) {
- LogRecord logRecord = new LogRecord(Level.INFO, "PS_CSFP0032");
- logRecord.setParameters(new Object[] { phaseId, context});
- logRecord.setThrown(e);
- logger.log(logRecord);
- }
-
- }
-
- try {
-
- try {
-
- // Execute this phase itself
- phase.execute(context);
-
- } catch (Exception e) {
-
- // Log the problem, but continue
- if (logger.isLoggable(Level.INFO)) {
- LogRecord logRecord = new LogRecord(Level.INFO, "PS_CSFP0033");
- logRecord.setParameters(new Object[] { phaseId, context});
- logRecord.setThrown(e);
- }
-
- // Don't rethrow as it will break the jsf lifecycle execution
- // If exception is thrown in the render phase, hold a reference to the exception
- if(phaseId.compareTo(PhaseId.RENDER_RESPONSE) == 0) {
- exceptionThrownInRender = true;
- tempException = e;
- }
- }
-
- // Notify the "afterPhase" method of interested listeners
- if (listeners.length > 0) {
- PhaseEvent event = new PhaseEvent(context, phaseId, this);
- for (int i = listeners.length - 1; i >= 0; i--) {
- if (phaseId.equals(listeners[i].getPhaseId()) ||
- PhaseId.ANY_PHASE.equals(listeners[i].getPhaseId())) {
- listeners[i].afterPhase(event);
- }
- }
- }
-
- } catch (Exception e) {
-
- // Log the problem, but continue
- if (logger.isLoggable(Level.INFO)) {
- LogRecord logRecord = new LogRecord(Level.INFO, "PS_CSFP0034");
- logRecord.setParameters(new Object[] { phaseId, context});
- logRecord.setThrown(e);
- }
- }
-
- if(exceptionThrownInRender)
- throw new FacesException(tempException);
- }
-
-
- /**
- * <p>Restore state information for the current window into the
- * specified <code>FacesContext</code> instance.</p>
- *
- * @param context <code>FacesContext</code> for this request
- * @param action Flag indicating this is action mode (true)
- * or render mode (false)
- */
- private void restore(FacesContext context, boolean action) {
- if (logger.isLoggable(Level.FINEST)) {
- logger.log(Level.FINEST, "PS_CSFP0035", new Object[] { context,action});
- }
-
- // Retrieve the cached state information (if any)
- String windowStateIdentifier = getWindowStateIdentifier((String) context.getExternalContext().
- getRequestMap().get(INIT_PARAMETER));
-
- PortletSession session = (PortletSession)context.getExternalContext().getSession(true);
-
- String previousWindowStateIndentifier = (String)session.getAttribute(PREVIOUS_WINDOW_STATE);
-
- FacesPortletState state = null;
- // This will ensure that the state information saved for INIT_VIEW will be restored
- // only for INIT_VIEW and so on..
- if(previousWindowStateIndentifier != null
- && previousWindowStateIndentifier.equals(windowStateIdentifier)) {
- state = (FacesPortletState)session.getAttribute(windowStateIdentifier);
-
- }
-
- if (state == null) {
- setViewId(context);
- return;
- }
-
- // Restore the cached state information
- if (!action) {
- Iterator messages;
- Iterator clientIds = state.getClientIds();
- while (clientIds.hasNext()) {
- String clientId = (String) clientIds.next();
- messages = state.getMessages(clientId);
- while (messages.hasNext()) {
- context.addMessage(clientId, (FacesMessage) messages.next());
- }
- }
- }
- context.setViewRoot(state.getViewRoot());
-
- // Remove the cached state information
- session.removeAttribute(windowStateIdentifier);
-
- logger.finest("PS_CSFP0036");
- }
-
-
- /**
- * <p>Save state information for the current window from the
- * specified <code>FacesContext</code> instance.</p>
- *
- * @param context <code>FacesContext</code> for this request
- * @param action Flag indicating this is action mode (true)
- * or render mode (false)
- */
- private void save(FacesContext context, boolean action) {
- if (logger.isLoggable(Level.FINEST)) {
- logger.log(Level.FINEST, "PS_CSFP0037", new Object[] { context, action });
- }
- // Save state information from this FacesContext
- FacesPortletState state = new FacesPortletState();
- Iterator messages;
- Iterator clientIds = context.getClientIdsWithMessages();
- while (clientIds.hasNext()) {
- String clientId = (String) clientIds.next();
- messages = context.getMessages(clientId);
- while (messages.hasNext()) {
- state.addMessage(clientId, (FacesMessage) messages.next());
- }
- // Log the message
- if (logger.isLoggable(Level.INFO)) {
- logger.log(Level.INFO, "PS_CSFP0038", clientId + state.getMessagesBuffer(clientId));
- }
- }
- state.setViewRoot(context.getViewRoot());
-
- // Cache the state information in a session in portlet scope
- String windowStateIdentifier = getWindowStateIdentifier((String) context.getExternalContext().
- getRequestMap().get(INIT_PARAMETER));
-
- PortletSession session = (PortletSession)context.getExternalContext().getSession(true);
- // Save the window state identifier in a session in portlet scope
- // This information is used during restore to restore the cached information for the
- // appropriate window state. This will ensure that the state information saved for
- // INIT_VIEW will be restored only for INIT_VIEW and so on..
- session.setAttribute(PREVIOUS_WINDOW_STATE, windowStateIdentifier);
-
- session.setAttribute(windowStateIdentifier, state);
- }
-
-
- /**
- * <p>Get the view identifier to a default page specified in a
- * portlet init parameter.</p>
- *
- * @param context <code>FacesContext</code> for the current request
- */
- private String getInitViewId(FacesContext context) {
- Map requestMap = context.getExternalContext().getRequestMap();
- String initParameterIdentifier = (String) requestMap.get(INIT_PARAMETER);
- String viewId = (String) requestMap.get(initParameterIdentifier);
- return viewId;
- }
-
- /**
- * <p>Set the view identifier to a default page specified in a
- * portlet init parameter.</p>
- *
- * @param context <code>FacesContext</code> for the current request
- */
- private void setViewId(FacesContext context) {
- String viewId = getInitViewId(context);
-
- if (context.getViewRoot() == null) {
- context.setViewRoot(context.getApplication().getViewHandler().createView(context, viewId));
- if (logger.isLoggable(Level.FINER)) {
- logger.log(Level.FINER, "PS_CSFP0039", context.getViewRoot().getViewId());
- }
- } else {
- context.getViewRoot().setViewId(viewId);
- if (logger.isLoggable(Level.FINER)) {
- logger.log(Level.FINER, "PS_CSFP0040", viewId);
- }
- }
-
- context.getViewRoot().setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
- }
-
- /**
- * Returns the window state attribute identifier based on the
- * init parameter identifier.
- *
- * @param initParameterIdentifier the initialization parameter identifier
- * @return window state attribute identifier
- */
- private String getWindowStateIdentifier(String initParameterIdentifier) {
- if(initParameterIdentifier.equals(INIT_VIEW_PARAMETER))
- return WINDOW_STATE_ATTR_VIEW;
- else if(initParameterIdentifier.equals(INIT_EDIT_PARAMETER))
- return WINDOW_STATE_ATTR_EDIT;
- else if(initParameterIdentifier.equals(INIT_HELP_PARAMETER))
- return WINDOW_STATE_ATTR_HELP;
- else
- return null;
-
- }
-
- private void setErrorFlag(FacesContext context, Boolean value) {
- PortletSession session = (PortletSession)context.getExternalContext().getSession(true);
- session.setAttribute(ERROR_FLAG, value);
- }
-
-// ------------------------------------------------------- Phase Implementations
-
-
- interface Phase {
-
- public void execute(FacesContext context)
- throws FacesException;
-
- }
-
-
- final class RestoreViewPhase implements Phase {
-
- public void execute(FacesContext context) throws FacesException {
- logger.finest("PS_CSFP0041");
- // get the viewId from the context
- String viewId = context.getViewRoot().getViewId();
- if (viewId == null) {
- logger.info("PS_CSFP0042");
- throw new FacesException // PENDING - i18n
- ("No view identifier in this request");
- }
-
- // Try to restore the view
- ViewHandler vh = context.getApplication().getViewHandler();
- UIViewRoot viewRoot = vh.restoreView(context, viewId);
- if (viewRoot == null) {
- logger.log(Level.FINEST, "PS_CSFP0043", viewId);
- viewRoot = vh.createView(context, viewId);
- context.renderResponse();
- } else {
- logger.log(Level.FINEST, "PS_CSFP0044", viewId);
- }
- context.setViewRoot(viewRoot);
- doPerComponentActions(context, viewRoot);
- logger.finest("PS_CSFP0045");
- }
-
-
- // Do the per-component actions needed during restore
- private void doPerComponentActions
- (FacesContext context, UIComponent component) {
-
- Iterator kids = component.getFacetsAndChildren();
- while (kids.hasNext()) {
- doPerComponentActions(context, (UIComponent) kids.next());
- }
- ValueBinding vb = component.getValueBinding("binding");
- if (vb != null) {
- vb.setValue(context, component);
- }
- }
-
-
- }
-
-
- final class ApplyRequestValuesPhase implements Phase {
-
- public void execute(FacesContext context) throws FacesException {
- logger.finest("PS_CSFP0046");
- UIViewRoot viewRoot = context.getViewRoot();
- try {
- viewRoot.processDecodes(context);
- } catch (FacesException e) {
- throw e;
- } catch (RuntimeException e) {
- throw new FacesException(e);
- }
- logger.finest("PS_CSFP0047");
- }
- }
-
-
- final class ProcessValidationsPhase implements Phase {
-
- public void execute(FacesContext context) throws FacesException {
- logger.finest("PS_CSFP0048");
- UIViewRoot viewRoot = context.getViewRoot();
- try {
- viewRoot.processValidators(context);
- } catch (FacesException e) {
- throw e;
- } catch (RuntimeException e) {
- throw new FacesException(e);
- }
- logger.finest("PS_CSFP0049");
- }
-
- }
-
-
- final class UpdateModelValuesPhase implements Phase {
-
- public void execute(FacesContext context) throws FacesException {
- logger.finest("PS_CSFP0050");
- UIViewRoot viewRoot = context.getViewRoot();
- try {
- viewRoot.processUpdates(context);
- } catch (FacesException e) {
- throw e;
- } catch (RuntimeException e) {
- throw new FacesException(e);
- }
- logger.finest("PS_CSFP0051");
- }
-
- }
-
-
- final class InvokeApplicationPhase implements Phase {
-
- public void execute(FacesContext context) throws FacesException {
- logger.finest("PS_CSFP0052");
- UIViewRoot viewRoot = context.getViewRoot();
- try {
- viewRoot.processApplication(context);
- } catch (FacesException e) {
- throw e;
- } catch (RuntimeException e) {
- throw new FacesException(e);
- }
- logger.finest("PS_CSFP0053");
- }
-
- }
-
-
- final class RenderResponsePhase implements Phase {
-
- public void execute(FacesContext context) throws FacesException {
- logger.finest("PS_CSFP0054");
- String requestURI = context.getViewRoot().getViewId();
- logger.log(Level.INFO, "PS_CSFP0055", requestURI);
- try {
- context.getApplication().getViewHandler().
- renderView(context, context.getViewRoot());
- } catch (FacesException e) {
- throw e;
- } catch (IOException e) {
- throw new FacesException(e);
- }
- logger.finest("PS_CSFP0056");
- }
-
- }
-
-
-}
-
-
-// ------------------------------------------------------------- Private Classes
-
-
-/**
- * <p>Private class to represent the JavaServer Faces specific information
- * that is saved and restored for a particular window.
- */
-
-final class FacesPortletState {
-
-
- // Methods Saving and Restoring Messages
- private Map messages = new HashMap(); // key=clientId, value=List of FacesMessage
- public void addMessage(String clientId, FacesMessage message) {
- List list = (List) messages.get(clientId);
- if (list == null) {
- list = new ArrayList();
- messages.put(clientId, list);
- }
- list.add(message);
- }
- public Iterator getMessages(String clientId) {
- List list = (List) messages.get(clientId);
- if (list != null) {
- return (list.iterator());
- } else {
- return (Collections.EMPTY_LIST.iterator());
- }
- }
-
- public StringBuffer getMessagesBuffer(String clientId) {
- List list = (List) messages.get(clientId);
- StringBuffer buffer = new StringBuffer();
- if (list != null) {
- Iterator messages = list.iterator();
- FacesMessage message;
- while (messages.hasNext()) {
- message = (FacesMessage) messages.next();
- buffer.append(" ");
- buffer.append(message.getDetail());
- }
- }
- return buffer;
- }
-
- // Iterate over the client ids in this view
- public Iterator getClientIds() {
- return (messages.keySet().iterator());
- }
-
- // The UIViewRoot that is the root of our component tree
- private UIViewRoot viewRoot;
- public UIViewRoot getViewRoot() { return this.viewRoot; }
- public void setViewRoot(UIViewRoot viewRoot) {
- this.viewRoot = viewRoot; }
-
-}
Added: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/lifecycle/PortletLifecycle.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/lifecycle/PortletLifecycle.java (rev 0)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/lifecycle/PortletLifecycle.java 2007-04-11 16:04:01 UTC (rev 66)
@@ -0,0 +1,90 @@
+/**
+ *
+ */
+package org.ajax4jsf.portlet.lifecycle;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseListener;
+import javax.faces.lifecycle.Lifecycle;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class PortletLifecycle {
+
+ private Lifecycle _defaultLifecycle;
+
+ public PortletLifecycle(Lifecycle lifecycle) {
+ _defaultLifecycle = lifecycle;
+ }
+
+ /**
+ * @param listener
+ * @see javax.faces.lifecycle.Lifecycle#addPhaseListener(javax.faces.event.PhaseListener)
+ */
+ public void addPhaseListener(PhaseListener listener) {
+ _defaultLifecycle.addPhaseListener(listener);
+ }
+
+ /**
+ * @param obj
+ * @return
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ return _defaultLifecycle.equals(obj);
+ }
+
+ /**
+ * @param context
+ * @throws FacesException
+ * @see javax.faces.lifecycle.Lifecycle#execute(javax.faces.context.FacesContext)
+ */
+ public void execute(FacesContext context) throws FacesException {
+ _defaultLifecycle.execute(context);
+ }
+
+ /**
+ * @return
+ * @see javax.faces.lifecycle.Lifecycle#getPhaseListeners()
+ */
+ public PhaseListener[] getPhaseListeners() {
+ return _defaultLifecycle.getPhaseListeners();
+ }
+
+ /**
+ * @return
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return _defaultLifecycle.hashCode();
+ }
+
+ /**
+ * @param listener
+ * @see javax.faces.lifecycle.Lifecycle#removePhaseListener(javax.faces.event.PhaseListener)
+ */
+ public void removePhaseListener(PhaseListener listener) {
+ _defaultLifecycle.removePhaseListener(listener);
+ }
+
+ /**
+ * @param context
+ * @throws FacesException
+ * @see javax.faces.lifecycle.Lifecycle#render(javax.faces.context.FacesContext)
+ */
+ public void render(FacesContext context) throws FacesException {
+ _defaultLifecycle.render(context);
+ }
+
+ /**
+ * @return
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return _defaultLifecycle.toString();
+ }
+
+}
Added: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/lifecycle/PortletLifecycleFactory.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/lifecycle/PortletLifecycleFactory.java (rev 0)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/lifecycle/PortletLifecycleFactory.java 2007-04-11 16:04:01 UTC (rev 66)
@@ -0,0 +1,83 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.portlet.lifecycle;
+
+import java.util.Iterator;
+
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.lifecycle.LifecycleFactory;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:12 $
+ *
+ */
+public class PortletLifecycleFactory extends LifecycleFactory {
+
+ private LifecycleFactory _defaultFactory;
+
+ private PortletLifecycle _defaultLifecycle ;
+
+// private Map _lifecycles = new HashMap();
+
+ /**
+ * @return the debugLifecycle
+ */
+ private PortletLifecycle getDefaultLifecycle() {
+ if (_defaultLifecycle == null) {
+ _defaultLifecycle = new PortletLifecycle(_defaultFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE));
+ }
+ return _defaultLifecycle;
+ }
+
+ /**
+ * @param defaultFactory
+ */
+ public PortletLifecycleFactory(LifecycleFactory defaultFactory) {
+ super();
+ this._defaultFactory = defaultFactory;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.lifecycle.LifecycleFactory#addLifecycle(java.lang.String, javax.faces.lifecycle.Lifecycle)
+ */
+ public void addLifecycle(String arg0, Lifecycle arg1) {
+ this._defaultFactory.addLifecycle(arg0, arg1);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.lifecycle.LifecycleFactory#getLifecycle(java.lang.String)
+ */
+ public Lifecycle getLifecycle(String lifecycleId) {
+ Lifecycle life;
+ life = this._defaultFactory.getLifecycle(lifecycleId);
+ return life;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.lifecycle.LifecycleFactory#getLifecycleIds()
+ */
+ public Iterator getLifecycleIds() {
+ return this._defaultFactory.getLifecycleIds();
+ }
+
+}
17 years, 8 months
JBoss Ajax4JSF SVN: r65 - in trunk/cdk: maven-archetype-jsfwebapp/src/main/resources/archetype-resources and 1 other directory.
by ajax4jsf-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-04-10 14:26:37 -0400 (Tue, 10 Apr 2007)
New Revision: 65
Modified:
trunk/cdk/maven-archetype-jsf-component/src/main/resources/archetype-resources/pom.xml
trunk/cdk/maven-archetype-jsfwebapp/src/main/resources/archetype-resources/pom.xml
Log:
Component & WebApp archetypes cleaned: extra dependencies removed, version tags removed
Modified: trunk/cdk/maven-archetype-jsf-component/src/main/resources/archetype-resources/pom.xml
===================================================================
--- trunk/cdk/maven-archetype-jsf-component/src/main/resources/archetype-resources/pom.xml 2007-04-10 18:25:26 UTC (rev 64)
+++ trunk/cdk/maven-archetype-jsf-component/src/main/resources/archetype-resources/pom.xml 2007-04-10 18:26:37 UTC (rev 65)
@@ -3,7 +3,6 @@
<modelVersion>4.0.0</modelVersion>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
- <version>${version}</version>
<name>${artifactId}</name>
<build>
<plugins>
@@ -30,17 +29,4 @@
</plugin>
</plugins>
</build>
-<dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ajax4jsf</groupId>
- <artifactId>ajax4jsf</artifactId>
- <version>1.1.1-SNAPSHOT</version>
- </dependency>
- </dependencies>
</project>
Modified: trunk/cdk/maven-archetype-jsfwebapp/src/main/resources/archetype-resources/pom.xml
===================================================================
--- trunk/cdk/maven-archetype-jsfwebapp/src/main/resources/archetype-resources/pom.xml 2007-04-10 18:25:26 UTC (rev 64)
+++ trunk/cdk/maven-archetype-jsfwebapp/src/main/resources/archetype-resources/pom.xml 2007-04-10 18:26:37 UTC (rev 65)
@@ -2,59 +2,13 @@
<modelVersion>4.0.0</modelVersion>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
- <version>${version}</version>
<packaging>war</packaging>
- <name>JSF Maven Webapp</name>
- <properties>
- <jsfVersion>1.1</jsfVersion>
- </properties>
+ <name>${artifactId} Maven Webapp</name>
<build>
- <plugins>
- <plugin>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-plugin</artifactId>
- <version>6.1.1</version>
- <configuration>
- <scanIntervalSeconds>10</scanIntervalSeconds>
- <connectors>
- <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
- <port>8080</port>
- <maxIdleTime>60000</maxIdleTime>
- </connector>
- </connectors>
- </configuration>
- </plugin>
- </plugins>
- <finalName>webapp</finalName>
+ <finalName>${artifactId}</finalName>
</build>
- <pluginRepositories>
- <!-- Repository to get the jetty plugin -->
- <pluginRepository>
- <id>mortbay-repo</id>
- <name>mortbay-repo</name>
- <url>http://www.mortbay.org/maven2/snapshot</url>
- </pluginRepository>
- <!-- Repository to get the Ajax4jsf CDK plugin -->
- <pluginRepository>
- <id>repository.jboss.com</id>
- <name>Jboss Repository for Maven Artifacts</name>
- <url>http://repository.jboss.com/maven2</url>
- </pluginRepository>
- </pluginRepositories>
-
<dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ajax4jsf</groupId>
- <artifactId>ajax4jsf</artifactId>
- <version>1.1.1-SNAPSHOT</version>
- </dependency>
#if(${facelets})
<dependency>
<groupId>com.sun.facelets</groupId>
@@ -73,133 +27,5 @@
<scope>runtime</scope>
</dependency>
#end
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jstl</artifactId>
- <version>1.0</version>
- <scope>runtime</scope>
- </dependency>
</dependencies>
-<!--
- <profiles>
- <profile>
- <id>jsf1_1</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- <property>
- <name>jsfVersion</name>
- <value>1.1</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.4</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jsp-api</artifactId>
- <version>2.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jstl</artifactId>
- <version>1.0</version>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>jsf12</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0</version>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet.jsp</groupId>
- <artifactId>jsp-api</artifactId>
- <version>2.1</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-api</artifactId>
- <version>1.2_04</version>
- </dependency>
- <dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-impl</artifactId>
- <version>1.2_04</version>
- <scope>runtime</scope>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>myfaces</id>
- <properties>
- <myfaces>1.1.5</myfaces>
- <tomahawk>1.1.5</tomahawk>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.ajax4jsf</groupId>
- <artifactId>ajax4jsf</artifactId>
- <version>1.1.1-SNAPSHOT</version>
- <exclusions>
- <exclusion>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-impl</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.myfaces.core</groupId>
- <artifactId>myfaces-api</artifactId>
- <version>${myfaces}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.myfaces.core</groupId>
- <artifactId>myfaces-impl</artifactId>
- <version>${myfaces}</version>
- <scope>runtime</scope>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
-
--->
</project>
17 years, 8 months
JBoss Ajax4JSF SVN: r64 - in trunk: cdk/generator and 4 other directories.
by ajax4jsf-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-04-10 14:25:26 -0400 (Tue, 10 Apr 2007)
New Revision: 64
Modified:
trunk/cdk/compiler/
trunk/cdk/generator/
trunk/cdk/maven-archetype-jsf-component/
trunk/cdk/maven-archetype-jsfwebapp/
trunk/cdk/maven-cdk-plugin/
trunk/framework/
Log:
Eclipse service files added to svn:ignore
Property changes on: trunk/cdk/compiler
___________________________________________________________________
Name: svn:ignore
- target
+ target
.classpath
.project
.settings
Property changes on: trunk/cdk/generator
___________________________________________________________________
Name: svn:ignore
- target
+ target
.classpath
.project
.settings
Property changes on: trunk/cdk/maven-archetype-jsf-component
___________________________________________________________________
Name: svn:ignore
- target
+ target
.classpath
.project
.settings
Property changes on: trunk/cdk/maven-archetype-jsfwebapp
___________________________________________________________________
Name: svn:ignore
- target
+ target
.classpath
.project
.settings
Property changes on: trunk/cdk/maven-cdk-plugin
___________________________________________________________________
Name: svn:ignore
- target
+ target
.classpath
.project
.settings
Property changes on: trunk/framework
___________________________________________________________________
Name: svn:ignore
- target
+ target
.classpath
.project
.settings
17 years, 8 months
JBoss Ajax4JSF SVN: r62 - trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context.
by ajax4jsf-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-04-10 13:48:21 -0400 (Tue, 10 Apr 2007)
New Revision: 62
Added:
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextAttributesMap.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/EnumerationIterator.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextWrapper.java
Log:
Continue work for portlet integration
Added: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextAttributesMap.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextAttributesMap.java (rev 0)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextAttributesMap.java 2007-04-10 17:48:21 UTC (rev 62)
@@ -0,0 +1,48 @@
+/**
+ *
+ */
+package org.ajax4jsf.portlet.context;
+
+/**
+ * Abstract base class for all attributes/sessions/cookies maps in external contexts.
+ * @author asmirnov
+ *
+ */
+public abstract class ContextAttributesMap extends ContextMap {
+
+ public Object get(Object key) {
+ if(null == key){
+ throw new NullPointerException();
+ }
+ return getAttribute(key.toString());
+ }
+
+ public Object put(Object key, Object value) {
+ if(null == key){
+ throw new NullPointerException();
+ }
+ String stringKey = key.toString();
+ Object oldValue = getAttribute(stringKey);
+ setAttribute(stringKey, value);
+ return oldValue;
+ }
+
+ public Object remove(Object key) {
+ if(null == key){
+ throw new NullPointerException();
+ }
+ return removeAttribute(key.toString());
+ }
+
+
+ protected abstract Object getAttribute(String name);
+
+ protected abstract void setAttribute(String name, Object value);
+
+ protected Object removeAttribute(String name){
+ Object oldValue = getAttribute(name);
+ setAttribute(name, null);
+ return oldValue;
+ }
+
+}
Added: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/EnumerationIterator.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/EnumerationIterator.java (rev 0)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/EnumerationIterator.java 2007-04-10 17:48:21 UTC (rev 62)
@@ -0,0 +1,37 @@
+/**
+ *
+ */
+package org.ajax4jsf.portlet.context;
+
+import java.util.Enumeration;
+import java.util.Iterator;
+
+class EnumerationIterator implements Iterator {
+
+ public EnumerationIterator(Enumeration enumeration) {
+
+ this.enumeration = enumeration;
+
+ }
+
+ private Enumeration enumeration;
+
+ public boolean hasNext() {
+
+ return enumeration.hasMoreElements();
+
+ }
+
+ public Object next() {
+
+ return enumeration.nextElement();
+
+ }
+
+ public void remove() {
+
+ throw new UnsupportedOperationException();
+
+ }
+
+}
\ No newline at end of file
Added: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextWrapper.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextWrapper.java (rev 0)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextWrapper.java 2007-04-10 17:48:21 UTC (rev 62)
@@ -0,0 +1,196 @@
+/**
+ *
+ */
+package org.ajax4jsf.portlet.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;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class FacesContextWrapper extends FacesContext {
+
+ private FacesContext _wrapped;
+
+ public FacesContextWrapper(FacesContext _wrapped) {
+ super();
+ this._wrapped = _wrapped;
+ setCurrentInstance(this);
+ }
+
+ /**
+ * @param clientId
+ * @param message
+ * @see javax.faces.context.FacesContext#addMessage(java.lang.String, javax.faces.application.FacesMessage)
+ */
+ public void addMessage(String clientId, FacesMessage message) {
+ _wrapped.addMessage(clientId, message);
+ }
+
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getApplication()
+ */
+ public Application getApplication() {
+ return _wrapped.getApplication();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getClientIdsWithMessages()
+ */
+ public Iterator getClientIdsWithMessages() {
+ return _wrapped.getClientIdsWithMessages();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getELContext()
+ */
+ public ELContext getELContext() {
+ return _wrapped.getELContext();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getExternalContext()
+ */
+ public ExternalContext getExternalContext() {
+ return _wrapped.getExternalContext();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getMaximumSeverity()
+ */
+ public Severity getMaximumSeverity() {
+ return _wrapped.getMaximumSeverity();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getMessages()
+ */
+ public Iterator getMessages() {
+ return _wrapped.getMessages();
+ }
+
+ /**
+ * @param clientId
+ * @return
+ * @see javax.faces.context.FacesContext#getMessages(java.lang.String)
+ */
+ public Iterator getMessages(String clientId) {
+ return _wrapped.getMessages(clientId);
+ }
+
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getRenderKit()
+ */
+ public RenderKit getRenderKit() {
+ return _wrapped.getRenderKit();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getRenderResponse()
+ */
+ public boolean getRenderResponse() {
+ return _wrapped.getRenderResponse();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getResponseComplete()
+ */
+ public boolean getResponseComplete() {
+ return _wrapped.getResponseComplete();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getResponseStream()
+ */
+ public ResponseStream getResponseStream() {
+ return _wrapped.getResponseStream();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getResponseWriter()
+ */
+ public ResponseWriter getResponseWriter() {
+ return _wrapped.getResponseWriter();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.context.FacesContext#getViewRoot()
+ */
+ public UIViewRoot getViewRoot() {
+ return _wrapped.getViewRoot();
+ }
+
+ /**
+ *
+ * @see javax.faces.context.FacesContext#release()
+ */
+ public void release() {
+ _wrapped.release();
+ _wrapped = null;
+ }
+
+ /**
+ *
+ * @see javax.faces.context.FacesContext#renderResponse()
+ */
+ public void renderResponse() {
+ _wrapped.renderResponse();
+ }
+
+ /**
+ *
+ * @see javax.faces.context.FacesContext#responseComplete()
+ */
+ public void responseComplete() {
+ _wrapped.responseComplete();
+ }
+
+ /**
+ * @param responseStream
+ * @see javax.faces.context.FacesContext#setResponseStream(javax.faces.context.ResponseStream)
+ */
+ public void setResponseStream(ResponseStream responseStream) {
+ _wrapped.setResponseStream(responseStream);
+ }
+
+ /**
+ * @param responseWriter
+ * @see javax.faces.context.FacesContext#setResponseWriter(javax.faces.context.ResponseWriter)
+ */
+ public void setResponseWriter(ResponseWriter responseWriter) {
+ _wrapped.setResponseWriter(responseWriter);
+ }
+
+ /**
+ * @param root
+ * @see javax.faces.context.FacesContext#setViewRoot(javax.faces.component.UIViewRoot)
+ */
+ public void setViewRoot(UIViewRoot root) {
+ _wrapped.setViewRoot(root);
+ }
+
+}
17 years, 8 months
JBoss Ajax4JSF SVN: r61 - trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context.
by ajax4jsf-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-04-10 13:47:42 -0400 (Tue, 10 Apr 2007)
New Revision: 61
Modified:
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextMap.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ServletContextImpl.java
Log:
Continue work for portlet integration
Modified: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java 2007-04-10 17:43:39 UTC (rev 60)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java 2007-04-10 17:47:42 UTC (rev 61)
@@ -66,6 +66,7 @@
import java.security.Principal;
import java.util.Collections;
+import java.util.Enumeration;
import java.util.Enumeration;
@@ -188,202 +189,24 @@
*
*/
- public void dispatch(String path) throws IOException {
-
- // perform Generation in generator, do nothing in Action.
-
- // generator place special Dispatcher to objectModel ...
-
- // May be must set Dispatcher in special method in Context Component ???
-
- String jspPageURL = (String) getCocoonRequest().getAttribute(
-
- JSFGenerator.PAGE_URL_PARAM_NAME);
-
- RequestDispatcher dispatcher = getCocoonHttpContext()
-
- .getNamedDispatcher(getJspServletName());
-
- this.log("Dispatch for page: " + jspPageURL);
-
- // Dispatcher dispatch = getDispatcher();
-
- if (dispatcher == null) {
-
- throw new IOException("NamedDispatcher is null for servlet "
-
- + getJspServletName());
-
- }
-
- try {// Reset jsp Request/Response wrappers - for create on demand
-
- // with new Writer for current XML Consumer.
-
- this.jspRequest = null;
-
- this.jspResponse = null;
-
- dispatcher.include(new JSPServletRequest(getCocoonHttpRequest(),
-
- jspPageURL, null), (ServletResponse) this.getResponse());
-
- } catch (ServletException e) {
-
- //
-
- if (e.getMessage() != null) {
-
- throw new FacesException(e.getMessage(), e);
-
- } else {
-
- throw new FacesException(e);
-
- }
-
- }
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#encodeActionURL(java.lang.String)
- *
- */
-
- public String encodeActionURL(String url) {
-
- //
-
- return getCocoonResponse().encodeURL(url);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#encodeNamespace(java.lang.String)
- *
- */
-
- public String encodeNamespace(String name) {
-
- // HACK - set namespace prefix in Action sitemap parameter.
-
- // return this.getCocoonRequest().getContextPath()+"/"+name;
-
- String namespace = (String) this.getCocoonRequest().getAttribute(
-
- FacesAction.ACT_NAMESPACE);
-
- if (null != namespace) {
-
- return namespace + name;
-
- }
-
- return name;
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#encodeResourceURL(java.lang.String)
- *
- */
-
- public String encodeResourceURL(String url) {
-
- //
-
- return this.getCocoonResponse().encodeURL(url);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getApplicationMap()
- *
- */
-
public Map getApplicationMap() {
-
- //
-
if (applicationMap == null) {
+ applicationMap = new ContextAttributesMap() {
- applicationMap = new ContextMap() {
- public Object get(Object key) {
-
- if (key == null) {
-
- throw new NullPointerException();
-
- }
-
- return getCocoonContext().getAttribute(key.toString());
-
+ protected Enumeration getEnumeration() {
+ return getContextAttributeNames();
}
- public Object put(Object key, Object value) {
- if (key == null) {
-
- throw new NullPointerException();
-
- }
-
- String keyString = key.toString();
-
- Object result = getCocoonContext().getAttribute(keyString);
-
- getCocoonContext().setAttribute(keyString, value);
-
- return (result);
-
+ protected Object getAttribute(String name) {
+ return getContextAttribute(name);
}
- public Object remove(Object key) {
-
- if (key == null) {
-
- return null;
-
- }
-
- String keyString = key.toString();
-
- Object result = getCocoonContext().getAttribute(keyString);
-
- getCocoonContext().removeAttribute(keyString);
-
- return (result);
-
+ protected void setAttribute(String name, Object value) {
+ setContextAttribute(name,value);
}
- protected Enumeration getEnumeration() {
-
- return getCocoonContext().getAttributeNames();
-
- }
-
};
}
@@ -392,122 +215,49 @@
}
+ protected abstract void setContextAttribute(String name, Object value);
+ protected abstract Object getContextAttribute(String name);
+ protected abstract Enumeration getContextAttributeNames();
+
/*
- *
* (non-Javadoc)
- *
- *
- *
* @see javax.faces.context.ExternalContext#getAuthType()
- *
*/
- public String getAuthType() {
-
- //
-
- return this.getCocoonRequest().getAuthType();
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getContext()
- *
- */
-
public Object getContext() {
return this.context;
}
+ /**
+ * @param context
+ */
public void setContext(Object context) {
this.context = context;
}
- /*
- return servletContext; // .getContext(getRequestContextPath());
-
- // return getCocoonHttpContext();
-
- }
-
/*
- *
* (non-Javadoc)
- *
- *
- *
* @see javax.faces.context.ExternalContext#getInitParameter(java.lang.String)
- *
*/
- public String getInitParameter(String name) {
-
- // HACK - get init parameter from Action configuration instead of
-
- // servlet ...
-
- String ret = (String) getActionSettings().get(name);
-
- if (ret == null) {
-
- ret = this.getCocoonContext().getInitParameter(name);
-
- }
-
- return ret;
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getInitParameterMap()
- *
- */
-
public Map getInitParameterMap() {
- // Combine Servlet InitParameters with Cocoon Action configuration
- // parameters ?
-
if (initParameterMap == null) {
- initParameterMap = new ContextConcatentedMap(this
+ initParameterMap = new ContextAttributesMap() {
- .getActionSettings()) {
+ protected Object getAttribute(String name) {
+ return getInitParameter(name);
+ }
- public Object getBase(Object key) {
-
- // HACK - return configuration parameter from Cocoon
-
- // FacesAction
-
- return getCocoonContext().getInitParameter(key.toString());
-
+ protected void setAttribute(String name, Object value) {
+ throw new UnsupportedOperationException();
}
protected Enumeration getEnumeration() {
-
- if (http) {
-
- return getCocoonHttpContext().getInitParameterNames();
-
- } else {
-
- return Collections.enumeration(Collections.EMPTY_SET);
-
- }
-
+ return getInitParametersNames();
}
};
@@ -518,70 +268,35 @@
}
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRemoteUser()
- *
+
+ /**
+ * Hoock method for initialization parameters.
+ * @return
*/
+ protected abstract Enumeration getInitParametersNames();
- public String getRemoteUser() {
- //
- return getCocoonRequest().getRemoteUser();
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
+ /* (non-Javadoc)
* @see javax.faces.context.ExternalContext#getRequest()
- *
*/
-
public Object getRequest() {
return request;
}
+ /* (non-Javadoc)
+ * @see javax.faces.context.ExternalContext#setRequest(java.lang.Object)
+ */
public void setRequest(Object request) {
this.request = request;
}
- public String getRequestContextPath() {
-
- // TODO return Cocoon sitemap-specific path ? or configure from sitemap
-
- // parameters of Action.
-
- return getCocoonRequest().getContextPath();
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestCookieMap()
- *
- */
-
public Map getRequestCookieMap() {
-
- //
-
- return getCocoonRequest().getCookieMap();
-
+ // Portlet environment don't have methods to use cookies.
+ return Collections.EMPTY_MAP;
}
/*
@@ -928,24 +643,6 @@
*
*/
- public String getRequestPathInfo() {
-
- //
-
- return (String) getCocoonRequest().getAttribute(FacesAction.ACT_SRC);
-
- }
-
- /*
- *
- * (non-Javadoc)
- *
- *
- *
- * @see javax.faces.context.ExternalContext#getRequestServletPath()
- *
- */
-
public String getRequestServletPath() {
// TODO return current sitemap path ??? For cocoon, always "/" !
@@ -1199,44 +896,4 @@
}
- // Private methods - for Cocoon Context Interaction.
-
- // TODO - rewrite as lazy creation, but need reset with change Context ?
-
- // private Map getObjectModel() {
-
- // return ContextHelper.getObjectModel(getCocoonContext());
-
- // }
-
- private class EnumerationIterator implements Iterator {
-
- public EnumerationIterator(Enumeration locales) {
-
- this.locales = locales;
-
- }
-
- private Enumeration locales;
-
- public boolean hasNext() {
-
- return locales.hasMoreElements();
-
- }
-
- public Object next() {
-
- return locales.nextElement();
-
- }
-
- public void remove() {
-
- throw new UnsupportedOperationException();
-
- }
-
- }
-
}
\ No newline at end of file
Modified: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextMap.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextMap.java 2007-04-10 17:43:39 UTC (rev 60)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextMap.java 2007-04-10 17:47:42 UTC (rev 61)
@@ -19,10 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
package org.ajax4jsf.portlet.context;
import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
import java.util.Enumeration;
@@ -48,6 +50,8 @@
abstract class ContextMap extends AbstractMap {
+ private transient volatile Set keySet;
+
/*
*
* (non-Javadoc)
@@ -74,6 +78,30 @@
}
+ public Set keySet() {
+ if (keySet == null) {
+ keySet = new AbstractSet(){
+
+ public Iterator iterator() {
+ return new EnumerationIterator(getEnumeration());
+ }
+ public int size() {
+ Enumeration enumeration = getEnumeration();
+ int size = 0;
+ while (enumeration.hasMoreElements()) {
+ size++;
+ };
+ return size;
+ }
+ };
+ }
+ return keySet;
+ }
+
+ public Collection values() {
+ return super.values();
+ }
+
/**
*
*
Modified: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ServletContextImpl.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ServletContextImpl.java 2007-04-10 17:43:39 UTC (rev 60)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ServletContextImpl.java 2007-04-10 17:47:42 UTC (rev 61)
@@ -6,8 +6,14 @@
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.Enumeration;
+import java.util.Map;
import java.util.Set;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
/**
* @author asmirnov
*
@@ -22,29 +28,41 @@
public ServletContextImpl(Object context, Object request, Object response) {
super(context, request, response);
}
+
+ private HttpServletRequest getHttpRequest(){
+ return (HttpServletRequest) getRequest();
+ }
+
+ private ServletContext getServletContext(){
+ return (ServletContext) getContext();
+ }
+ private HttpServletResponse getHttpResponse(){
+ return (HttpServletResponse) getResponse();
+ }
/* (non-Javadoc)
* @see javax.faces.context.ExternalContext#getInitParameter(java.lang.String)
*/
public String getInitParameter(String name) {
- // TODO Auto-generated method stub
- return null;
+ return getServletContext().getInitParameter(name);
}
+
+ protected Enumeration getInitParametersNames() {
+ return getServletContext().getInitParameterNames();
+ }
/* (non-Javadoc)
* @see javax.faces.context.ExternalContext#getResource(java.lang.String)
*/
public URL getResource(String path) throws MalformedURLException {
- // TODO Auto-generated method stub
- return null;
+ return getServletContext().getResource(path);
}
/* (non-Javadoc)
* @see javax.faces.context.ExternalContext#getResourceAsStream(java.lang.String)
*/
public InputStream getResourceAsStream(String path) {
- // TODO Auto-generated method stub
- return null;
+ return getServletContext().getResourceAsStream(path);
}
/* (non-Javadoc)
@@ -52,7 +70,43 @@
*/
public Set getResourcePaths(String path) {
// TODO Auto-generated method stub
- return null;
+ return getServletContext().getResourcePaths(path);
}
+ protected Object getContextAttribute(String name) {
+ return getServletContext().getAttribute(name);
+ }
+
+ protected Enumeration getContextAttributeNames() {
+ return getServletContext().getAttributeNames();
+ }
+
+ protected void setContextAttribute(String name, Object value) {
+ getServletContext().setAttribute(name, value);
+ }
+
+ public String getAuthType() {
+ return getHttpRequest().getAuthType();
+ }
+
+ public String getRemoteUser() {
+ return getHttpRequest().getRemoteUser();
+ }
+
+ public String getRequestContextPath() {
+ return getHttpRequest().getContextPath();
+ }
+
+ public String getRequestPathInfo() {
+ return getHttpRequest().getPathInfo();
+ }
+
+ public String getRequestServletPath() {
+ return getHttpRequest().getServletPath();
+ }
+
+ public Map getRequestCookieMap() {
+ // TODO Auto-generated method stub
+ return getHttpRequest().;
+ }
}
17 years, 8 months
JBoss Ajax4JSF SVN: r60 - trunk/framework/src/main/java/org/ajax4jsf/ajax/repeat.
by ajax4jsf-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-04-10 13:43:39 -0400 (Tue, 10 Apr 2007)
New Revision: 60
Modified:
trunk/framework/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java
Log:
Fix RF-14 related bug : restore rowKey value after broadcast a AjaxEvent. Delete missed comments for restore rowKey value
Modified: trunk/framework/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java 2007-04-09 13:56:00 UTC (rev 59)
+++ trunk/framework/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java 2007-04-10 17:43:39 UTC (rev 60)
@@ -1092,8 +1092,8 @@
rowEvent.getComponent().broadcast(rowEvent);
// For Ajax events, keep row value.
// if (!(rowEvent instanceof AjaxEvent)) {
-// setRowKey(faces, oldRowKey);
-// restoreOrigValue(faces);
+ setRowKey(faces, oldRowKey);
+ restoreOrigValue(faces);
// }
return;
}
17 years, 8 months
JBoss Ajax4JSF SVN: r59 - in trunk/test/src/main/java/org/ajax4jsf/tests: org/apache/shale/test/config and 1 other directories.
by ajax4jsf-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-04-09 09:56:00 -0400 (Mon, 09 Apr 2007)
New Revision: 59
Added:
trunk/test/src/main/java/org/ajax4jsf/tests/xml/
trunk/test/src/main/java/org/ajax4jsf/tests/xml/FacesEntityResolver.java
Modified:
trunk/test/src/main/java/org/ajax4jsf/tests/org/apache/shale/test/config/ConfigParser.java
Log:
ConfigParser has got EntityResolver for SUN RI & MyFaces
Modified: trunk/test/src/main/java/org/ajax4jsf/tests/org/apache/shale/test/config/ConfigParser.java
===================================================================
--- trunk/test/src/main/java/org/ajax4jsf/tests/org/apache/shale/test/config/ConfigParser.java 2007-04-08 22:19:35 UTC (rev 58)
+++ trunk/test/src/main/java/org/ajax4jsf/tests/org/apache/shale/test/config/ConfigParser.java 2007-04-09 13:56:00 UTC (rev 59)
@@ -46,6 +46,8 @@
import javax.faces.render.RenderKit;
import javax.faces.render.RenderKitFactory;
import javax.faces.render.Renderer;
+
+import org.ajax4jsf.tests.xml.FacesEntityResolver;
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.Rule;
import org.apache.shale.test.mock.MockRenderKit;
@@ -230,6 +232,9 @@
digester.addCallMethod
("faces-config/validator/validator-class", "setValidatorClass", 0);
}
+
+ digester.setEntityResolver(new FacesEntityResolver());
+
return this.digester;
}
Added: trunk/test/src/main/java/org/ajax4jsf/tests/xml/FacesEntityResolver.java
===================================================================
--- trunk/test/src/main/java/org/ajax4jsf/tests/xml/FacesEntityResolver.java (rev 0)
+++ trunk/test/src/main/java/org/ajax4jsf/tests/xml/FacesEntityResolver.java 2007-04-09 13:56:00 UTC (rev 59)
@@ -0,0 +1,73 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.tests.xml;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 09.04.2007
+ *
+ */
+public class FacesEntityResolver implements EntityResolver {
+
+ private static final String[] PREFIXES = new String[] {
+ "/com/sun/faces/", "/org/apache/myfaces/resource/"
+ };
+
+ /* (non-Javadoc)
+ * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
+ */
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException, IOException {
+
+ if (systemId == null) {
+ return null;
+ }
+
+ String fileName;
+
+ int idx = systemId.lastIndexOf('/');
+ if (idx == -1) {
+ fileName = systemId;
+ } else {
+ fileName = systemId.substring(idx + 1);
+ }
+
+ for (int i = 0; i < PREFIXES.length; i++) {
+ String prefix = PREFIXES[i];
+
+ URL url = getClass().getResource(prefix + fileName);
+ if (url != null) {
+ return new InputSource(url.openStream());
+ }
+ }
+
+ return null;
+ }
+
+}
17 years, 8 months
JBoss Ajax4JSF SVN: r58 - trunk/test/src/main/java/org/ajax4jsf/tests.
by ajax4jsf-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-04-08 18:19:35 -0400 (Sun, 08 Apr 2007)
New Revision: 58
Added:
trunk/test/src/main/java/org/ajax4jsf/tests/MockMethodBinding.java
Log:
MockMethodBinding class added
Added: trunk/test/src/main/java/org/ajax4jsf/tests/MockMethodBinding.java
===================================================================
--- trunk/test/src/main/java/org/ajax4jsf/tests/MockMethodBinding.java (rev 0)
+++ trunk/test/src/main/java/org/ajax4jsf/tests/MockMethodBinding.java 2007-04-08 22:19:35 UTC (rev 58)
@@ -0,0 +1,87 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.tests;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.MethodNotFoundException;
+
+/**
+ * @author Nick - mailto:nbelaevski@exadel.com
+ * created 09.04.2007
+ *
+ */
+public class MockMethodBinding extends MethodBinding {
+
+ private Class returnType;
+ private MethodResult result;
+
+ private List invocationArgs = new ArrayList();
+
+ public static interface MethodResult {
+ public Object invoke(FacesContext facesContext, Object[] args, Class returnType);
+ }
+
+ public MockMethodBinding() {
+ this(null, null);
+ }
+
+ public MockMethodBinding(Class returnType, MethodResult result) {
+ super();
+ this.returnType = returnType;
+ this.result = result;
+ }
+
+ public Class getType(FacesContext context) throws MethodNotFoundException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ return returnType;
+ }
+
+ public Object invoke(FacesContext context, Object[] params)
+ throws EvaluationException, MethodNotFoundException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ invocationArgs.add(params);
+ if (result != null) {
+ return result.invoke(context, params, returnType);
+ }
+
+ return null;
+ }
+
+ public void clear() {
+ invocationArgs.clear();
+ }
+
+ public Object[][] getInvocationArgs() {
+ return (Object[][]) invocationArgs.toArray(new Object[invocationArgs.size()][]);
+ }
+}
17 years, 8 months