[Jsf4portlets-devel] SF.net SVN: jsf4portlets: [29] trunk
Status: Alpha
Brought to you by:
alonsoft
From: <alo...@us...> - 2007-09-26 17:47:39
|
Revision: 29 http://jsf4portlets.svn.sourceforge.net/jsf4portlets/?rev=29&view=rev Author: alonsoft Date: 2007-09-26 10:47:31 -0700 (Wed, 26 Sep 2007) Log Message: ----------- Website and docs updated Modified Paths: -------------- trunk/jsf4portlets/pom.xml trunk/jsf4portlets/src/main/java/javax/portlet/faces/component/PortletNamingContainerUIViewRoot.java trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/BridgeImpl.java trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/RequestScopeManager.java trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/application/BridgeLifecycleListener.java trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/config/ApplicationConfiguration.java trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/renderkit/ResponseStateManagerWrapper.java trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/spi/InjectionProviderFactory.java trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/util/Util.java trunk/jsf4portlets/src/main/resources/META-INF/faces-config.xml trunk/jsf4portlets/src/main/resources/net/sf/jsf4portlets/LogMessages.properties trunk/jsf4portlets-ext/pom.xml trunk/jsf4portlets-ext/src/main/resources/META-INF/faces-config.xml trunk/pom.xml trunk/src/assembly/bin.xml trunk/src/site/apt/download.apt trunk/src/site/apt/release_notes.apt trunk/src/site/apt/user_docs.apt trunk/src/site/site.xml trunk/src/site/xdoc/getting_started.xml Added Paths: ----------- trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/spi/ContainerInjectionProvider.java trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/vendor/ trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/vendor/GenericInjectionProvider.java trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/vendor/Tomcat6InjectionProvider.java trunk/jsf4portlets/src/main/resources/META-INF/services/net.sf.jsf4portlets.spi.InjectionProvider trunk/src/legal/ trunk/src/site/ Removed Paths: ------------- trunk/jsf4portlets/src/legal/ trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/ext/ trunk/jsf4portlets/src/main/resources/META-INF/jsf4portlets.tld trunk/jsf4portlets/src/site/ trunk/jsf4portlets-ext/src/main/java/net/sf/jsf4portlets/ajax/ Modified: trunk/jsf4portlets/pom.xml =================================================================== --- trunk/jsf4portlets/pom.xml 2007-09-06 17:28:35 UTC (rev 28) +++ trunk/jsf4portlets/pom.xml 2007-09-26 17:47:31 UTC (rev 29) @@ -12,6 +12,11 @@ <name>JSF 4 Portlets Core</name> + <description> + This is the main module of JSF 4 Portlets. This module brings an implementation of + the JSF Portlet Bridge (JSR-301) which allows JSR-168 Portlets running as JSF applications. + </description> + <dependencies> <dependency> <groupId>javax.el</groupId> @@ -42,6 +47,11 @@ <groupId>commons-digester</groupId> <artifactId>commons-digester</artifactId> </dependency> + + <dependency> + <groupId>org.apache.tomcat</groupId> + <artifactId>catalina</artifactId> + </dependency> <dependency> <groupId>junit</groupId> @@ -63,10 +73,6 @@ <groupId>net.sourceforge.maven-taglib</groupId> <artifactId>maven-taglib-plugin</artifactId> </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-changelog-plugin</artifactId> - </plugin> </plugins> </reporting> Modified: trunk/jsf4portlets/src/main/java/javax/portlet/faces/component/PortletNamingContainerUIViewRoot.java =================================================================== --- trunk/jsf4portlets/src/main/java/javax/portlet/faces/component/PortletNamingContainerUIViewRoot.java 2007-09-06 17:28:35 UTC (rev 28) +++ trunk/jsf4portlets/src/main/java/javax/portlet/faces/component/PortletNamingContainerUIViewRoot.java 2007-09-26 17:47:31 UTC (rev 29) @@ -70,6 +70,7 @@ } // Implement the method that satisfies NamingContainer + @Override public String getContainerClientId(FacesContext context) { return PortletNamingContainerUIViewRoot.getContainerClientId( context, super.getContainerClientId(context)); Modified: trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/BridgeImpl.java =================================================================== --- trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/BridgeImpl.java 2007-09-06 17:28:35 UTC (rev 28) +++ trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/BridgeImpl.java 2007-09-26 17:47:31 UTC (rev 29) @@ -78,6 +78,7 @@ facesContextFactory = null; lifecycle = null; portletConfig = null; + requestScopeManager = null; logger.log(Level.FINEST, "J4P_000004", getPortletName()); } Modified: trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/RequestScopeManager.java =================================================================== --- trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/RequestScopeManager.java 2007-09-06 17:28:35 UTC (rev 28) +++ trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/RequestScopeManager.java 2007-09-26 17:47:31 UTC (rev 29) @@ -51,7 +51,13 @@ import net.sf.jsf4portlets.config.PortletConfiguration; import net.sf.jsf4portlets.config.PortletConfiguration.BooleanPortletParameter; import net.sf.jsf4portlets.util.Util; - + +/** + * Manages the state of the request scope + * + * @author A. Alonso Dominguez + * + */ public class RequestScopeManager { public static final int DEFAULT_MAX_MANAGED_REQUEST_SCOPES = 1000; @@ -70,11 +76,20 @@ private int maxRequestScopes; - public RequestScopeManager(int maxRequestScopes) { + public RequestScopeManager(int maxRequestScopes) { + if(maxRequestScopes < 0) { + throw new IllegalArgumentException(); + } + this.maxRequestScopes = maxRequestScopes; scopes = new HashMap<String, RequestScope>(this.maxRequestScopes); } - + + /** + * Restores the current request scope into the given <code>FacesContext</code> + * + * @param context the current <code>FacesContext</code> + */ public void restore(FacesContext context) { ExternalContext extContext = context.getExternalContext(); PortletRequest request = (PortletRequest) extContext.getRequest(); @@ -140,7 +155,13 @@ request.setAttribute(BridgeConstants.REQUEST_SCOPE, scope); releasePreviousRequestScope(request); } - + + /** + * Stores the current state of the <code>FacesContext</code> into the + * request scope for later use. + * + * @param context the current <code>FacesContext</code> + */ @SuppressWarnings("unchecked") public void save(FacesContext context) { ExternalContext extContext = context.getExternalContext(); @@ -219,7 +240,8 @@ } } - scope.setViewRoot(context.getViewRoot()); + scope.setViewRoot(context.getViewRoot()); + scope.setViewId(null); } if(scope != null) { Modified: trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/application/BridgeLifecycleListener.java =================================================================== --- trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/application/BridgeLifecycleListener.java 2007-09-06 17:28:35 UTC (rev 28) +++ trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/application/BridgeLifecycleListener.java 2007-09-26 17:47:31 UTC (rev 29) @@ -21,18 +21,17 @@ package net.sf.jsf4portlets.application; import java.util.logging.Level; -import java.util.logging.LogRecord; import java.util.logging.Logger; -import javax.portlet.*; -import javax.faces.component.*; +import javax.faces.component.UIViewRoot; import javax.faces.context.FacesContext; import javax.faces.event.PhaseEvent; import javax.faces.event.PhaseId; import javax.faces.event.PhaseListener; -import javax.portlet.faces.*; +import javax.portlet.PortletResponse; +import javax.portlet.faces.Bridge; import javax.portlet.faces.Bridge.PortletPhase; -import javax.portlet.faces.component.*; +import javax.portlet.faces.component.PortletNamingContainerUIViewRoot; import net.sf.jsf4portlets.util.Util; Modified: trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/config/ApplicationConfiguration.java =================================================================== --- trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/config/ApplicationConfiguration.java 2007-09-06 17:28:35 UTC (rev 28) +++ trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/config/ApplicationConfiguration.java 2007-09-26 17:47:31 UTC (rev 29) @@ -28,9 +28,7 @@ import java.util.logging.Logger; import javax.faces.context.ExternalContext; -import javax.servlet.ServletContext; -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; +import javax.portlet.PortletContext; import org.apache.commons.digester.Digester; import org.xml.sax.SAXException; @@ -42,7 +40,7 @@ * @author A. Alonso Dominguez * @version 1.0 */ -public final class ApplicationConfiguration implements ServletContextListener { +public final class ApplicationConfiguration { private static final String INSTANCE_KEY = ApplicationConfiguration.class.getName(); @@ -56,8 +54,14 @@ "javax.faces.webapp.FacesServlet"; public static ApplicationConfiguration getInstance(ExternalContext context) { - return (ApplicationConfiguration) context + ApplicationConfiguration result = (ApplicationConfiguration) context .getApplicationMap().get(INSTANCE_KEY); + if(result == null) { + PortletContext portletContext = (PortletContext) context.getContext(); + result = new ApplicationConfiguration(); + result.configure(portletContext); + } + return result; } private final Logger logger = Logger.getLogger( @@ -112,53 +116,44 @@ public Enumeration<String> getManagedBeanNames() { return facesConfig.getManagedBeanNames(); } - - // ServletContextListener - - public void contextInitialized(ServletContextEvent event) { - ServletContext servletContext = event.getServletContext(); - if(isFacesApp(servletContext)) { + protected void configure(PortletContext portletContext) { + if(isFacesApp(portletContext)) { logger.log(Level.INFO, "J4P_000028", - servletContext.getContextPath()); + portletContext.getPortletContextName()); try { - facesConfig = loadFacesConfig(servletContext); - webappConfig = loadWebXml(servletContext); + facesConfig = loadFacesConfig(portletContext); + webappConfig = loadWebXml(portletContext); } catch(Exception e) { throw new ExceptionInInitializerError(e); } - servletContext.setAttribute(INSTANCE_KEY, this); + portletContext.setAttribute(INSTANCE_KEY, this); } } - public void contextDestroyed(ServletContextEvent event) { - ServletContext servletContext = event.getServletContext(); - servletContext.removeAttribute(INSTANCE_KEY); - } - private Digester createDigester() { Digester digester = new Digester(); digester.setClassLoader(Thread.currentThread().getContextClassLoader()); return digester; } - private InputStream getStream(ServletContext servletContext, String path) + private InputStream getStream(PortletContext portletContext, String path) throws IOException { - InputStream in = servletContext.getResourceAsStream(path); + InputStream in = portletContext.getResourceAsStream(path); if(in == null) { throw new FileNotFoundException( - servletContext.getRealPath(path)); + portletContext.getRealPath(path)); } return in; } - private boolean isFacesApp(ServletContext servletContext) { - InputStream in = servletContext.getResourceAsStream(FACES_CONFIG_XML); + private boolean isFacesApp(PortletContext portletContext) { + InputStream in = portletContext.getResourceAsStream(FACES_CONFIG_XML); return (in != null); } - private FacesConfigBean loadFacesConfig(ServletContext servletContext) + private FacesConfigBean loadFacesConfig(PortletContext portletContext) throws IOException, SAXException { Digester digester = createDigester(); @@ -169,11 +164,11 @@ digester.addBeanPropertySetter("faces-config/managed-bean/managed-bean-class", "className"); digester.addBeanPropertySetter("faces-config/managed-bean/managed-bean-scope", "scope"); - InputStream in = getStream(servletContext, FACES_CONFIG_XML); + InputStream in = getStream(portletContext, FACES_CONFIG_XML); return (FacesConfigBean) digester.parse(in); } - private WebAppBean loadWebXml(ServletContext servletContext) + private WebAppBean loadWebXml(PortletContext portletContext) throws IOException, SAXException { Digester digester = createDigester(); @@ -187,7 +182,7 @@ digester.addCallParam("web-app/servlet-mapping/servlet-name", 0); digester.addCallParam("web-app/servlet-mapping/url-pattern", 1); - InputStream in = getStream(servletContext, WEB_APP_XML); + InputStream in = getStream(portletContext, WEB_APP_XML); return (WebAppBean) digester.parse(in); } Modified: trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/renderkit/ResponseStateManagerWrapper.java =================================================================== --- trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/renderkit/ResponseStateManagerWrapper.java 2007-09-06 17:28:35 UTC (rev 28) +++ trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/renderkit/ResponseStateManagerWrapper.java 2007-09-26 17:47:31 UTC (rev 29) @@ -31,7 +31,7 @@ import net.sf.jsf4portlets.util.Util; /** - * @author alonso + * @author A. Alonso Dominguez * */ public class ResponseStateManagerWrapper extends ResponseStateManager { @@ -43,8 +43,10 @@ } /** - * @param arg0 - * @return + * Obtains an object which represents the components' state for restore. + * + * @param context the current <code>FacesContext</code> + * @return the components' state * @deprecated * @see javax.faces.render.ResponseStateManager#getComponentStateToRestore(javax.faces.context.FacesContext) */ @@ -54,9 +56,11 @@ } /** - * @param arg0 - * @param arg1 - * @return + * Obtains the current state of the given view + * + * @param context the current <code>FacesContext</code> + * @param viewId the current <code>viewId</code> + * @return the view state * @see javax.faces.render.ResponseStateManager#getState(javax.faces.context.FacesContext, java.lang.String) */ public Object getState(FacesContext context, String viewId) { @@ -64,9 +68,11 @@ } /** - * @param arg0 - * @param arg1 - * @return + * Obtains the tree structure for restore + * + * @param context the current <code>FacesContext</code> + * @param treeId the current <code>treeId</code> + * @return the tree structure * @deprecated * @see javax.faces.render.ResponseStateManager#getTreeStructureToRestore(javax.faces.context.FacesContext, java.lang.String) */ @@ -76,8 +82,10 @@ } /** - * @param arg0 - * @return + * Checks if the bridge is performing a postback + * + * @param context the current <code>FacesContext</code> + * @return <code>true</code> - if we are inside a postback request, <code>false</code> otherwise. * @see javax.faces.render.ResponseStateManager#isPostback(javax.faces.context.FacesContext) */ public boolean isPostback(FacesContext context) { @@ -90,9 +98,13 @@ } /** - * @param arg0 - * @param arg1 - * @throws IOException + * Writes the current state of the view into the request scope, + * then delegate to wrapped response state manager so view state + * can be written to the response too. + * + * @param context the current <code>FacesContext</code> + * @param view the view state to be written. + * @throws IOException * @deprecated * @see javax.faces.render.ResponseStateManager#writeState(javax.faces.context.FacesContext, javax.faces.application.StateManager.SerializedView) */ Added: trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/spi/ContainerInjectionProvider.java =================================================================== --- trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/spi/ContainerInjectionProvider.java (rev 0) +++ trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/spi/ContainerInjectionProvider.java 2007-09-26 17:47:31 UTC (rev 29) @@ -0,0 +1,36 @@ +/* JSF 4 Portlets - JSF Portlet Bridge (JSR-301) + * Copyright (C) 2007 A. Alonso Dominguez + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * A. Alonso Dominguez + * alo...@us... + */ +package net.sf.jsf4portlets.spi; + +import net.sf.jsf4portlets.util.Util; + +public abstract class ContainerInjectionProvider implements InjectionProvider { + + public static boolean isInjectionFeatureEnabled(String delegateClass) { + try { + Util.loadClass(delegateClass, null); + return true; + } catch(ClassNotFoundException e) { + return false; + } + } + +} Modified: trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/spi/InjectionProviderFactory.java =================================================================== --- trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/spi/InjectionProviderFactory.java 2007-09-06 17:28:35 UTC (rev 28) +++ trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/spi/InjectionProviderFactory.java 2007-09-26 17:47:31 UTC (rev 29) @@ -20,15 +20,23 @@ */ package net.sf.jsf4portlets.spi; -import java.lang.reflect.Method; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; -import javax.annotation.PreDestroy; import javax.faces.context.ExternalContext; +import javax.portlet.PortletContext; import net.sf.jsf4portlets.BridgeConstants; +import net.sf.jsf4portlets.util.Util; +import net.sf.jsf4portlets.vendor.GenericInjectionProvider; /** * @author A. Alonso Dom\xEDnguez @@ -41,8 +49,19 @@ private static final InjectionProvider NOOP_PROVIDER = new NoopInjectionProvider(); + private static final InjectionProvider GENERIC_INJECTION_PROVIDER = + new GenericInjectionProvider(); + + private static final String[] EMPTY_ARRAY = new String[0]; + + private static final String INJECTION_PROVIDER_PROPERTY = + "net.sf.jsf4portlets.injection_provider"; + + private static final String INJECTION_SERVICE = + "META-INF/services/" + InjectionProvider.class.getName(); + private static Logger logger = Logger.getLogger( - "net.sf.jsf4portlets.application", + InjectionProviderFactory.class.getPackage().getName(), "net.sf.jsf4portlets.LogMessages"); static { @@ -57,7 +76,7 @@ public static InjectionProvider createInstance(ExternalContext context) { String providerClass = findProviderClass(context); - InjectionProvider provider = getProviderInstance(providerClass); + InjectionProvider provider = getProviderInstance(providerClass, context); if(provider.getClass() != NoopInjectionProvider.class) { if(logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "J4P_000037", providerClass); @@ -73,21 +92,56 @@ private static String findProviderClass(ExternalContext context) { String provider = context.getInitParameter( BridgeConstants.INJECTION_PROVIDER); - return (provider != null) ? provider : - System.getProperty(BridgeConstants.INJECTION_PROVIDER); + if(provider != null) { + return provider; + } else { + provider = System.getProperty(INJECTION_PROVIDER_PROPERTY); + } + + if(provider != null) { + return provider; + } else { + String[] serviceEntries = getServiceEntries(); + if(serviceEntries.length > 0) { + for(int i = 0;i < serviceEntries.length;i++) { + provider = getProviderFromEntry(serviceEntries[i]); + if(provider != null) { + break; + } + } + } else { + return null; + } + } + + return provider; } - private static InjectionProvider getProviderInstance(String className) { + private static InjectionProvider getProviderInstance(String className, + ExternalContext context) { if(!INJECTION_ENABLED) { return NOOP_PROVIDER; } - InjectionProvider provider = new DefaultInjectionProvider(); + InjectionProvider provider = GENERIC_INJECTION_PROVIDER; if(className != null) { try { Class<?> clazz = Class.forName(className, true, InjectionProviderFactory.class.getClassLoader()); if(clazz.isAssignableFrom(InjectionProvider.class)) { - provider = (InjectionProvider) clazz.newInstance(); + try { + Constructor<?> cons = clazz.getConstructor(PortletContext.class); + provider = (InjectionProvider) cons.newInstance( + (PortletContext) context.getContext()); + } catch(NoSuchMethodException e) { + provider = (InjectionProvider) clazz.newInstance(); + } catch(InvocationTargetException e) { + if(logger.isLoggable(Level.SEVERE)) { + LogRecord logRecord = new LogRecord(Level.SEVERE, "J4P_000036"); + logRecord.setParameters(new Object[]{ className }); + logRecord.setThrown(e); + logger.log(logRecord); + } + } } else { if(logger.isLoggable(Level.SEVERE)) { logger.log(Level.SEVERE, "J4P_000035", className); @@ -116,24 +170,74 @@ return provider; } - private static class DefaultInjectionProvider implements InjectionProvider { - - public void invokePreDestroy(Object managedBean) - throws InjectionProviderException { - Class<?> managedBeanClass = managedBean.getClass(); - for(Method method : managedBeanClass.getDeclaredMethods()) { - if(!method.isAnnotationPresent(PreDestroy.class)) { - continue; + private static String getProviderFromEntry(String entry) { + if(entry == null || entry.length() == 0) { + return null; + } + + String[] parts = entry.split(":"); + if(parts.length != 2) { + // TODO log about this problem + return null; + } + + try { + Class<?> clazz = Util.loadClass(parts[0], null); + if(ContainerInjectionProvider.class.isAssignableFrom(clazz)) { + if(ContainerInjectionProvider.isInjectionFeatureEnabled(parts[1])) { + return parts[0]; } - + } else { + // TODO Entry not discoverable + return null; + } + } catch(ClassNotFoundException e) { + // TODO provider not found + return null; + } + + return null; + } + + private static String[] getServiceEntries() { + String[] results = EMPTY_ARRAY; + ClassLoader loader = Util.getClassLoader(null); + + InputStream stream = null; + BufferedReader reader = null; + try { + stream = loader.getResourceAsStream(INJECTION_SERVICE); + if(stream != null) { try { - method.invoke(managedBean); + reader = new BufferedReader(new InputStreamReader(stream, "UTF-8")); } catch(Exception e) { - throw new InjectionProviderException(e); + reader = new BufferedReader(new InputStreamReader(stream)); } + List<String> list = new ArrayList<String>(); + for(String line = reader.readLine();line != null;line = reader.readLine()) { + list.add(line.trim()); + } + results = list.toArray(new String[list.size()]); } + } catch(Exception e) { + if(logger.isLoggable(Level.SEVERE)) { + logger.log(Level.SEVERE, "J4P_000049", e); + } + results = EMPTY_ARRAY; + } finally { + if(stream != null) { + try { + stream.close(); + } catch(Exception e) { } + } + if(reader != null) { + try { + reader.close(); + } catch(Exception e) { } + } } + return results; } private static class NoopInjectionProvider implements InjectionProvider { Modified: trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/util/Util.java =================================================================== --- trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/util/Util.java 2007-09-06 17:28:35 UTC (rev 28) +++ trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/util/Util.java 2007-09-26 17:47:31 UTC (rev 29) @@ -106,10 +106,20 @@ return mapping.startsWith("/"); } + public static Class<?> loadClass(String className, Object caller) + throws ClassNotFoundException { + ClassLoader loader = getClassLoader(caller); + return loader.loadClass(className); + } + public static ClassLoader getClassLoader(Object caller) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); if(loader == null) { - loader = caller.getClass().getClassLoader(); + if(caller != null) { + loader = caller.getClass().getClassLoader(); + } else { + loader = Util.class.getClassLoader(); + } } return loader; } Added: trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/vendor/GenericInjectionProvider.java =================================================================== --- trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/vendor/GenericInjectionProvider.java (rev 0) +++ trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/vendor/GenericInjectionProvider.java 2007-09-26 17:47:31 UTC (rev 29) @@ -0,0 +1,124 @@ +/* JSF 4 Portlets - JSF Portlet Bridge (JSR-301) + * Copyright (C) 2007 A. Alonso Dominguez + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * A. Alonso Dominguez + * alo...@us... + */ +package net.sf.jsf4portlets.vendor; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.annotation.PreDestroy; + +import net.sf.jsf4portlets.spi.InjectionProvider; +import net.sf.jsf4portlets.spi.InjectionProviderException; + +public class GenericInjectionProvider implements InjectionProvider { + + private final Logger logger = Logger.getLogger( + GenericInjectionProvider.class.getPackage().getName(), + "net.sf.jsf4portlets.LogMessages"); + + public void invokePreDestroy(Object managedBean) + throws InjectionProviderException { + if(managedBean != null) { + Method annotatedMethod = getAnnotatedMethod( + managedBean, PreDestroy.class); + invokeMethod(managedBean, annotatedMethod); + } + } + + private void invokeMethod(Object managedBean, Method method) + throws InjectionProviderException { + if(method != null) { + boolean accessible = method.isAccessible(); + method.setAccessible(true); + try { + method.invoke(managedBean); + } catch(Exception e) { + throw new InjectionProviderException(e); + } finally { + method.setAccessible(accessible); + } + } + } + + private Method getAnnotatedMethod(Object managedBean, + Class<? extends Annotation> annotation) { + Class<?> clazz = managedBean.getClass(); + while(!Object.class.equals(clazz)) { + Method[] methods = clazz.getDeclaredMethods(); + for(Method method : methods) { + if(method.isAnnotationPresent(annotation)) { + // validate method + if(Modifier.isStatic(method.getModifiers())) { + if(logger.isLoggable(Level.WARNING)) { + logger.log(Level.WARNING, "J4P_000045", new Object[]{ + method.getName(), annotation.getName() + }); + } + continue; + } + if(!Void.TYPE.equals(method.getReturnType())) { + if(logger.isLoggable(Level.WARNING)) { + logger.log(Level.WARNING, "J4P_000046", new Object[]{ + method.getName(), annotation.getName() + }); + } + continue; + } + if(method.getParameterTypes().length != 0) { + if(logger.isLoggable(Level.WARNING)) { + logger.log(Level.WARNING, "J4P_000047", new Object[]{ + method.getName(), annotation.getName() + }); + } + continue; + } + Class<?>[] exceptions = method.getExceptionTypes(); + if(exceptions.length != 0) { + boolean hasChecked = false; + for(Class<?> excClass : exceptions) { + if(!RuntimeException.class.isAssignableFrom(excClass)) { + hasChecked = true; + break; + } + } + if(hasChecked) { + if(logger.isLoggable(Level.WARNING)) { + logger.log(Level.WARNING, "J4P_000048", new Object[]{ + method.getName(), annotation.getName() + }); + } + continue; + } + } + return method; + } + } + + clazz = clazz.getSuperclass(); + } + + return null; + } + +} Added: trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/vendor/Tomcat6InjectionProvider.java =================================================================== --- trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/vendor/Tomcat6InjectionProvider.java (rev 0) +++ trunk/jsf4portlets/src/main/java/net/sf/jsf4portlets/vendor/Tomcat6InjectionProvider.java 2007-09-26 17:47:31 UTC (rev 29) @@ -0,0 +1,52 @@ +/* JSF 4 Portlets - JSF Portlet Bridge (JSR-301) + * Copyright (C) 2007 A. Alonso Dominguez + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * A. Alonso Dominguez + * alo...@us... + */ +package net.sf.jsf4portlets.vendor; + +import javax.portlet.PortletContext; + +import net.sf.jsf4portlets.spi.ContainerInjectionProvider; +import net.sf.jsf4portlets.spi.InjectionProviderException; + +import org.apache.AnnotationProcessor; + +public class Tomcat6InjectionProvider extends ContainerInjectionProvider { + + private PortletContext portletContext; + + public Tomcat6InjectionProvider(PortletContext portletContext) { + this.portletContext = portletContext; + } + + public void invokePreDestroy(Object managedBean) + throws InjectionProviderException { + try { + getProcessor().preDestroy(managedBean); + } catch(Exception e) { + throw new InjectionProviderException(e); + } + } + + protected AnnotationProcessor getProcessor() { + return (AnnotationProcessor) portletContext.getAttribute( + AnnotationProcessor.class.getName()); + } + +} Modified: trunk/jsf4portlets/src/main/resources/META-INF/faces-config.xml =================================================================== --- trunk/jsf4portlets/src/main/resources/META-INF/faces-config.xml 2007-09-06 17:28:35 UTC (rev 28) +++ trunk/jsf4portlets/src/main/resources/META-INF/faces-config.xml 2007-09-26 17:47:31 UTC (rev 29) @@ -48,18 +48,4 @@ </el-resolver> </application> - <component> - <description> - PortletPage component used to namespace portlet's - view components. - </description> - <display-name>Portlet Page</display-name> - <component-type> - net.sf.jsf4portlets.PortletPage - </component-type> - <component-class> - net.sf.jsf4portlets.ext.UIPortletPage - </component-class> - </component> - </faces-config> \ No newline at end of file Deleted: trunk/jsf4portlets/src/main/resources/META-INF/jsf4portlets.tld =================================================================== --- trunk/jsf4portlets/src/main/resources/META-INF/jsf4portlets.tld 2007-09-06 17:28:35 UTC (rev 28) +++ trunk/jsf4portlets/src/main/resources/META-INF/jsf4portlets.tld 2007-09-26 17:47:31 UTC (rev 29) @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- - JSF 4 Portlets - JSF Portlet Bridge (JSR-301) - Copyright (C) 2007 A. Alonso Dominguez - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - A. Alonso Dominguez - alo...@us... ---> - -<!DOCTYPE taglib - PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" - "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd"> - -<taglib> - <tlib-version>1.0</tlib-version> - <jsp-version>2.1</jsp-version> - <short-name>j4p</short-name> - <uri>http://jsf4portlets.sf.net/tld/jsf4portlets_1_0.tld</uri> - <display-name>JSF 4 Portlets TagLib</display-name> - - <listener> - <listener-class> - net.sf.jsf4portlets.config.ApplicationConfiguration - </listener-class> - </listener> - - <tag> - <name>portletPage</name> - <tag-class> - net.sf.jsf4portlets.ext.PortletPageTag - </tag-class> - <body-content>JSP</body-content> - <display-name>PortletPage Tag</display-name> - <description> - PortletPage component tag handler. - </description> - </tag> -</taglib> \ No newline at end of file Added: trunk/jsf4portlets/src/main/resources/META-INF/services/net.sf.jsf4portlets.spi.InjectionProvider =================================================================== --- trunk/jsf4portlets/src/main/resources/META-INF/services/net.sf.jsf4portlets.spi.InjectionProvider (rev 0) +++ trunk/jsf4portlets/src/main/resources/META-INF/services/net.sf.jsf4portlets.spi.InjectionProvider 2007-09-26 17:47:31 UTC (rev 29) @@ -0,0 +1 @@ +net.sf.jsf4portlets.vendor.Tomcat6InjectionProvider:org.apache.catalina.util.DefaultAnnotationProcessor \ No newline at end of file Modified: trunk/jsf4portlets/src/main/resources/net/sf/jsf4portlets/LogMessages.properties =================================================================== --- trunk/jsf4portlets/src/main/resources/net/sf/jsf4portlets/LogMessages.properties 2007-09-06 17:28:35 UTC (rev 28) +++ trunk/jsf4portlets/src/main/resources/net/sf/jsf4portlets/LogMessages.properties 2007-09-26 17:47:31 UTC (rev 29) @@ -62,3 +62,8 @@ J4P_000042=J4P000042: Exception caught when delegating the faces request during renderView. J4P_000043=J4P000043: Portlet {0} has init param {1} but it is deprecated. It should be replaced by {2}. J4P_000044=J4P000044: Using {0} as view root for portlet {1} +J4P_000045=J4P000045: Injection method {0} should not be declared 'static' for annotation {1}. +J4P_000046=J4P000046: Return type of injection method {0} should be 'void' for annotation {1}. +J4P_000047=J4P000047: Injection method {0} should be declared with no parameters for annotation {1}. +J4P_000048=J4P000048: Injection method {0} should thrown no checked exceptions for annotation {1}. +J4P_000049=J4P000049: Cannot read injection provider service. Modified: trunk/jsf4portlets-ext/pom.xml =================================================================== --- trunk/jsf4portlets-ext/pom.xml 2007-09-06 17:28:35 UTC (rev 28) +++ trunk/jsf4portlets-ext/pom.xml 2007-09-26 17:47:31 UTC (rev 29) @@ -12,6 +12,11 @@ <name>JSF 4 Portlets Extensions</name> + <description> + This is the extensions module of JSF 4 Portlets. This module brings some + additional features to the bridge implementation like Facelets support and more. + </description> + <dependencies> <dependency> <groupId>javax.el</groupId> @@ -47,10 +52,7 @@ <groupId>net.sf.jsf4portlets</groupId> <artifactId>jsf4portlets</artifactId> </dependency> - <dependency> - <groupId>org.ajax4jsf</groupId> - <artifactId>ajax4jsf</artifactId> - </dependency> + <dependency> <groupId>com.sun.facelets</groupId> <artifactId>jsf-facelets</artifactId> @@ -76,10 +78,6 @@ <groupId>net.sourceforge.maven-taglib</groupId> <artifactId>maven-taglib-plugin</artifactId> </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-changelog-plugin</artifactId> - </plugin> </plugins> </reporting> Modified: trunk/jsf4portlets-ext/src/main/resources/META-INF/faces-config.xml =================================================================== --- trunk/jsf4portlets-ext/src/main/resources/META-INF/faces-config.xml 2007-09-06 17:28:35 UTC (rev 28) +++ trunk/jsf4portlets-ext/src/main/resources/META-INF/faces-config.xml 2007-09-26 17:47:31 UTC (rev 29) @@ -27,32 +27,4 @@ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd" version="1.2"> - <lifecycle> - <phase-listener> - net.sf.jsf4portlets.ajax.AjaxPortletLifecycleListener - </phase-listener> - </lifecycle> - - <managed-bean> - <managed-bean-name>ajaxContext</managed-bean-name> - <managed-bean-class> - net.sf.jsf4portlets.ajax.AjaxPortletContext - </managed-bean-class> - <managed-bean-scope>request</managed-bean-scope> - </managed-bean> - - <render-kit> - <renderer> - <component-family> - javax.faces.ViewRoot - </component-family> - <renderer-type> - javax.faces.ViewRoot - </renderer-type> - <renderer-class> - net.sf.jsf4portlets.ajax.AjaxPortletViewRootRenderer - </renderer-class> - </renderer> - </render-kit> - </faces-config> \ No newline at end of file Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2007-09-06 17:28:35 UTC (rev 28) +++ trunk/pom.xml 2007-09-26 17:47:31 UTC (rev 29) @@ -119,10 +119,10 @@ <groupId>net.sourceforge.maven-taglib</groupId> <artifactId>maven-taglib-plugin</artifactId> </plugin> - <plugin> + <!--<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-changelog-plugin</artifactId> - </plugin> + </plugin>--> </plugins> </reporting> @@ -191,9 +191,9 @@ </dependency> <dependency> - <groupId>org.ajax4jsf</groupId> - <artifactId>ajax4jsf</artifactId> - <version>1.1.1</version> + <groupId>org.apache.tomcat</groupId> + <artifactId>catalina</artifactId> + <version>6.0.13</version> <scope>compile</scope> <optional>true</optional> </dependency> Modified: trunk/src/assembly/bin.xml =================================================================== --- trunk/src/assembly/bin.xml 2007-09-06 17:28:35 UTC (rev 28) +++ trunk/src/assembly/bin.xml 2007-09-26 17:47:31 UTC (rev 29) @@ -38,11 +38,14 @@ <binaries> <outputDirectory>/lib</outputDirectory> <unpack>false</unpack> - <includeDependecies>false</includeDependencies> <dependencySets> <dependencySet> <outputDirectory>/lib</outputDirectory> <scope>runtime</scope> + <excludes> + <exclude>org.apache.tomcat:*</exclude> + <exclude>com.sun.facelets:*</exclude> + </excludes> </dependencySet> </dependencySets> </binaries> @@ -57,6 +60,10 @@ </includes> </fileSet> <fileSet> + <directory>src/legal</directory> + <outputDirectory>/lib</outputDirectory> + </fileSet> + <fileSet> <directory>target</directory> <outputDirectory>/</outputDirectory> <includes> @@ -65,14 +72,14 @@ </fileSet> <fileSet> <directory>target/site/apidocs</directory> - <outputDirectory>/apidocs</outputDirectory> + <outputDirectory>/doc/apidocs</outputDirectory> <includes> <include>**/*</include> </includes> </fileSet> <fileSet> <directory>target/site/tlddoc</directory> - <outputDirectory>/tlddocs</outputDirectory> + <outputDirectory>/doc/tlddocs</outputDirectory> <includes> <include>**/*</include> </includes> Copied: trunk/src/legal (from rev 28, trunk/jsf4portlets/src/legal) Copied: trunk/src/site (from rev 28, trunk/jsf4portlets/src/site) Modified: trunk/src/site/apt/download.apt =================================================================== --- trunk/jsf4portlets/src/site/apt/download.apt 2007-09-06 17:28:35 UTC (rev 28) +++ trunk/src/site/apt/download.apt 2007-09-26 17:47:31 UTC (rev 29) @@ -1,3 +1,25 @@ +~~ +~~ JSF 4 Portlets - JSF Portlet Bridge (JSR-301) +~~ Copyright (C) 2007 A. Alonso Dominguez +~~ +~~ This library is free software; you can redistribute it and/or +~~ modify it under the terms of the GNU Lesser General Public +~~ License as published by the Free Software Foundation; either +~~ version 2.1 of the License, or (at your option) any later version. +~~ +~~ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +~~ +~~ A. Alonso Dominguez +~~ alo...@us... +~~ + --- Download JSF 4 Portlets --- @@ -8,11 +30,37 @@ Downloads for JSF 4 Portlets are served by {{{http://www.sourceforge.net}SourceForge.net}}, you can access the global project downloads through the following link {{http://sourceforge.net/project/showfiles.php?group_id=196120}}. -* Current Release : 1.0-alpha-1 +* Current Release : 1.0-alpha-2 + Implements JSR-301 Early Draft 2 + ** Binary Distributions *----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + Windows (*.zip) | {{{http://downloads.sourceforge.net/jsf4portlets/jsf4portlets-1.0-alpha-2-bin.zip?modtime=1180909157&big_mirror=0}jsf4portlets-1.0-alpha-2-bin.zip}} | +*----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + Unix (gzip) | {{{http://downloads.sourceforge.net/jsf4portlets/jsf4portlets-1.0-alpha-2-bin.tar.gz?modtime=1180909046&big_mirror=0}jsf4portlets-1.0-alpha-2-bin.tar.gz}} | +*----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + Unix (bzip2) | {{{http://downloads.sourceforge.net/jsf4portlets/jsf4portlets-1.0-alpha-2-bin.tar.bz2?modtime=1180909014&big_mirror=0}jsf4portlets-1.0-alpha-2-bin.tar.bz2}} | +*----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +** Source Distributions + +*----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + Windows (*.zip) | {{{http://downloads.sourceforge.net/jsf4portlets/jsf4portlets-1.0-alpha-2-src.zip?modtime=1180909373&big_mirror=0}jsf4portlets-1.0-alpha-2-src.zip}} | +*----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + Unix (gzip) | {{{http://downloads.sourceforge.net/jsf4portlets/jsf4portlets-1.0-alpha-2-src.tar.gz?modtime=1180909345&big_mirror=0}jsf4portlets-1.0-alpha-2-src.tar.gz}} | +*----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + Unix (bzip2) | {{{http://downloads.sourceforge.net/jsf4portlets/jsf4portlets-1.0-alpha-2-src.tar.bz2?modtime=1180909325&big_mirror=0}jsf4portlets-1.0-alpha-2-src.tar.bz2}} | +*----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +* Older release : 1.0-alpha-1 + + Implements JSR-301 Early Draft 1 + +** Binary Distributions + +*----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ Windows (*.zip) | {{{http://downloads.sourceforge.net/jsf4portlets/jsf4portlets-1.0-alpha-1-bin.zip?modtime=1180909157&big_mirror=0}jsf4portlets-1.0-alpha-1-bin.zip}} | *----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ Unix (gzip) | {{{http://downloads.sourceforge.net/jsf4portlets/jsf4portlets-1.0-alpha-1-bin.tar.gz?modtime=1180909046&big_mirror=0}jsf4portlets-1.0-alpha-1-bin.tar.gz}} | Modified: trunk/src/site/apt/release_notes.apt =================================================================== --- trunk/jsf4portlets/src/site/apt/release_notes.apt 2007-09-06 17:28:35 UTC (rev 28) +++ trunk/src/site/apt/release_notes.apt 2007-09-26 17:47:31 UTC (rev 29) @@ -1 +1,23 @@ +~~ +~~ JSF 4 Portlets - JSF Portlet Bridge (JSR-301) +~~ Copyright (C) 2007 A. Alonso Dominguez +~~ +~~ This library is free software; you can redistribute it and/or +~~ modify it under the terms of the GNU Lesser General Public +~~ License as published by the Free Software Foundation; either +~~ version 2.1 of the License, or (at your option) any later version. +~~ +~~ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +~~ +~~ A. Alonso Dominguez +~~ alo...@us... +~~ + JSF 4 Portlets - Release Notes Modified: trunk/src/site/apt/user_docs.apt =================================================================== --- trunk/jsf4portlets/src/site/apt/user_docs.apt 2007-09-06 17:28:35 UTC (rev 28) +++ trunk/src/site/apt/user_docs.apt 2007-09-26 17:47:31 UTC (rev 29) @@ -1,3 +1,25 @@ +~~ +~~ JSF 4 Portlets - JSF Portlet Bridge (JSR-301) +~~ Copyright (C) 2007 A. Alonso Dominguez +~~ +~~ This library is free software; you can redistribute it and/or +~~ modify it under the terms of the GNU Lesser General Public +~~ License as published by the Free Software Foundation; either +~~ version 2.1 of the License, or (at your option) any later version. +~~ +~~ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +~~ +~~ A. Alonso Dominguez +~~ alo...@us... +~~ + --- Using JSF 4 Portlets --- @@ -48,6 +70,8 @@ </context-param> +--- + This context init parameter is useful when we have more than one implementation of the JSF Portlet Bridge in the classpath, so we need to specify which of the current implementations of the Bridge interface must be used by our portlets. + ** Basic Portlet Configuration So, the last work is to configure the <<<javax.portlet.faces.GenericFacesPortlet>>>. This portlet will delegate all work to the bridge implementation. This portlet needs at least one init parameter so it can know the default <<<viewId>>> to be rendered when no <<<viewId>>> has been requested. Following there is an example: @@ -77,6 +101,7 @@ ** Bridge Parameters JSF portlets have the ability to preserve its action parameters during the render phase and to perform redirects againts the portal. This two features are disabled by default so they must be configured so portlets can take advantage of them. + If you want to configure this two features to every portlet in the same web application you must set the following in your <<<WEB-INF/web.xml>>> file. You can also specify these parameters in the <<<WEB-INF/portlet.xml>>> file as portlet init parameters. *** Performing redirects againts the portal page: @@ -90,17 +115,60 @@ *** Preserving action parameters + This attribute is used when we need access the portlet parameters which caused the current view to be rendered during the render phase. This parameters can be accessed using EL expressions like <<<#\{param.[param_name]\}>>>. + +--- <context-param> - <param-name>javax.portlet.faces.PRESERVE_ACTION_PARAMS</param-name> + <param-name>javax.portlet.faces.preserveActionParams</param-name> <param-value>true</param-value> </context-param> +--- +** Portlet Render Policy + + This is a special feature of the JSF Portlet Bridge. The render policy stablishes if the bridge should delegate rendering to parent view handlers. Delegation of the render operation depends of 3 different possible values: + + [DEFAULT] Renders the current view delegating the render operation to the parent <<<ViewHandler>>>. If this operation throws any exception, then the bridge will try to render the output by itself. + + [ALWAYS_DELEGATE] Always delegate the render operation to the parent <<<ViewHandler>>>. If this operation throws any exception, it should be caught by the <<<GenericFacesPortlet>>> and rethrown as a <<<PortletException>>>. + + [NEVER_DELEGATE] Never delegate the render operation to the parent <<<ViewHandler>>>. The bridge will always try to render the current view by itself. + + The default behaivour is <<<DEFAULT>>>, if we need to change this, we must stablish a portlet init parameter like below: + ++--- +<portlet> + ... + + <init-param> + <name>javax.portlet.faces.renderPolicy</name> + <value>NEVER_DELEGATE</value> + </init-param> + + ... +</portlet> ++--- + + This feature allows retaining the natural order of non-Faces and Faces output when both exists in the same JSP file. Because JSR-168 doesn't allows request/response wrapping, we need to configure a servlet filter around the Faces' servlet like following: + ++--- +<filter> + <filter-name>Faces Portlet Render Filter</filter-name> + <filter-class>javax.portlet.faces.BridgeRenderFilter</filter-class> +</filter> + +<filter-mapping> + <filter-name>Faces Portlet Render Filter</filter-name> + <servlet-name>FacesServlet</servlet-name> + <dispatcher>INCLUDE</dispatcher> +</filter-mapping> ++--- + ** Portlet Modes - JSF 4 Porlets supports portlets with 3 different portlet modes: <<<VIEW>>>, <<<EDIT>>> and <<<HELP>>>, in the future custom portlet modes will also be supported. Every portlet needs to configure the <<<VIEW>>> mode as the default, <<<EDIT>>> and <<<HELP>>> modes are optional. - Each portlet mode has a corresponding portlet init parameter so portlet can stablish the default viewId for the current portlet mode: + JSF 4 Porlets supports portlets with standard portlet modes (<<<VIEW>>>, <<<EDIT>>> and <<<HELP>>>) and custom portlet modes. Every portlet needs to configure the <<<VIEW>>> mode as the default, <<<EDIT>>> and <<<HELP>>> modes are optional. Custom portlet modes must be defined in <<<portlet.xml>>> to become available. + + Each portlet mode has a corresponding portlet init parameter so portlet can stablish the default viewId for the current portlet mode. When a portlet receives a PortletRequest for portlet mode which has not been configured, a <<<BridgeDefaultViewNotSpecifiedException>>> is thrown. *** View @@ -124,7 +192,16 @@ +--- <init-param> - <name>javax.portlet.faces.defaultViewId</name> + <name>javax.portlet.faces.defaultViewId.help</name> <value>/help.jsf</value> </init-param> +--- + +*** Custom Portlet Modes + ++--- +<init-param> + <name>javax.portlet.faces.defaultViewId.[custom_portlet_mode]</name> + <value>/custom.jsf</value> +</init-param> ++--- \ No newline at end of file Modified: trunk/src/site/site.xml =================================================================== --- trunk/jsf4portlets/src/site/site.xml 2007-09-06 17:28:35 UTC (rev 28) +++ trunk/src/site/site.xml 2007-09-26 17:47:31 UTC (rev 29) @@ -50,9 +50,10 @@ <menu name="Documentation"> <item name="User Documentation" href="user_docs.html" /> <item name="Java Docs" href="apidocs/index.html" /> - <item name="Taglib Docs" href="tlddoc/index.html" /> </menu> + <menu ref="modules" /> + <menu ref="reports" /> </body> </project> Modified: trunk/src/site/xdoc/getting_started.xml =================================================================== --- trunk/jsf4portlets/src/site/xdoc/getting_started.xml 2007-09-06 17:28:35 UTC (rev 28) +++ trunk/src/site/xdoc/getting_started.xml 2007-09-26 17:47:31 UTC (rev 29) @@ -36,7 +36,7 @@ <p>Copy distributed libraries into directory <tt>[TOMCAT_HOME]/lib</tt>. The result must to be like following:</p> <source><![CDATA[ [TOMCAT_HOME]/lib/... -[TOMCAT_HOME]/lib/jsf4portlets-1.0-alpha-1.jar +[TOMCAT_HOME]/lib/jsf4portlets-1.0-alpha-2.jar [TOMCAT_HOME]/lib/commons-digester-1.8.jar [TOMCAT_HOME]/lib/commons-beanutils-1.7.0.jar [TOMCAT_HOME]/lib/commons-logging-1.1.jar @@ -49,7 +49,7 @@ <p>Copy distributed libraries into <tt>/lib</tt> directory inside the domain tree. The result must be like the following.</p> <source><![CDATA[ [DOMAIN_HOME]/lib/... -[DOMAIN_HOME]/lib/jsf4portlets-1.0-alpha-1.jar +[DOMAIN_HOME]/lib/jsf4portlets-1.0-alpha-2.jar [DOMAIN_HOME]/lib/commons-digester-1.8.jar [DOMAIN_HOME]/lib/commons-beanutils-1.7.0.jar [DOMAIN_HOME]/lib/commons-logging-1.1.jar @@ -69,7 +69,7 @@ <context-param> <param-name> - javax.portlet.faces.extension.bridgeClass + javax.portlet.faces.BridgeClassName </param-name> <param-value> net.sf.jsf4portlets.BridgeImpl @@ -86,7 +86,7 @@ ... <init-param> <name> - javax.portlet.faces.extension.bridgeClass + javax.portlet.faces.BridgeClassName </name> <value> net.sf.jsf4portlets.BridgeImpl @@ -117,7 +117,7 @@ ]]></source> </subsection> <subsection name="JSF Portlet configuration"> - <p>JSF 4 Portlet requires at least one parameter to be configured in <tt>portlet.xml</tt> for each portlet. This parameter is <tt>javax.portlet.faces.extension.INIT_VIEW</tt> and it's needed to know the first view to be rendered when no viewId has been requested.</p> + <p>JSF 4 Portlet requires at least one parameter to be configured in <tt>portlet.xml</tt> for each portlet. This parameter is <code>javax.portlet.faces.defaultViewId.view</code> and it's needed to know the first view to be rendered when no viewId has been requested.</p> <source><![CDATA[ <portlet-app ...> @@ -128,7 +128,7 @@ </portlet-class> <init-param> - <name>javax.portlet.faces.extension.INIT_VIEW</name> + <name>javax.portlet.faces.defaultViewId.view</name> <value>/path/to/viewId</value> </init-param> </portlet> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |