jsf4portlets-devel Mailing List for JSF 4 Portlets (Page 4)
Status: Alpha
Brought to you by:
alonsoft
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(6) |
Jul
(3) |
Aug
(4) |
Sep
(8) |
Oct
(1) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(4) |
Jul
|
Aug
|
Sep
|
Oct
(4) |
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
(4) |
May
(8) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
(4) |
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
(23) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <alo...@us...> - 2007-06-07 00:01:31
|
Revision: 15 http://jsf4portlets.svn.sourceforge.net/jsf4portlets/?rev=15&view=rev Author: alonsoft Date: 2007-06-06 17:01:23 -0700 (Wed, 06 Jun 2007) Log Message: ----------- Added two new ELVariables: "portletPreference" and "portletPreferenceValues". Removed the previous ELVariable "portletPreferences". Modified Paths: -------------- trunk/src/main/java/javax/portlet/faces/GenericFacesPortlet.java trunk/src/main/java/net/sf/jsf4portlets/config/PortletConfiguration.java trunk/src/main/java/net/sf/jsf4portlets/context/ExternalContextImpl.java trunk/src/main/java/net/sf/jsf4portlets/context/PreDestroyCallback.java trunk/src/main/java/net/sf/jsf4portlets/el/ELConstants.java trunk/src/main/java/net/sf/jsf4portlets/el/ImplicitObjectELResolver.java trunk/src/main/java/net/sf/jsf4portlets/util/Util.java Added Paths: ----------- trunk/src/main/java/net/sf/jsf4portlets/context/PortletExternalContext.java trunk/src/main/java/net/sf/jsf4portlets/context/PortletPreferenceMap.java trunk/src/main/java/net/sf/jsf4portlets/context/PortletPreferenceValuesMap.java trunk/src/main/java/net/sf/jsf4portlets/util/MessagesFactory.java trunk/src/main/resources/javax/ trunk/src/main/resources/javax/portlet/ trunk/src/main/resources/javax/portlet/faces/ trunk/src/main/resources/javax/portlet/faces/Messages.properties Modified: trunk/src/main/java/javax/portlet/faces/GenericFacesPortlet.java =================================================================== --- trunk/src/main/java/javax/portlet/faces/GenericFacesPortlet.java 2007-06-04 20:36:23 UTC (rev 14) +++ trunk/src/main/java/javax/portlet/faces/GenericFacesPortlet.java 2007-06-07 00:01:23 UTC (rev 15) @@ -151,8 +151,8 @@ if(viewId == null) { if(PortletMode.VIEW.equals(portletMode)) { - throw new PortletException("Portlet '" + getPortletName() + "' misses a default view page. " + - "Please take a look to http://jsf4portlets.sf.net/web/user_docs.html"); + throw new PortletException("Portlet '" + getPortletName() + + "' misses a default view page. "); } throw new PortletException("Portlet '" + getPortletName() + "' misses a default viewId for portlet mode: " + portletMode); Modified: trunk/src/main/java/net/sf/jsf4portlets/config/PortletConfiguration.java =================================================================== --- trunk/src/main/java/net/sf/jsf4portlets/config/PortletConfiguration.java 2007-06-04 20:36:23 UTC (rev 14) +++ trunk/src/main/java/net/sf/jsf4portlets/config/PortletConfiguration.java 2007-06-07 00:01:23 UTC (rev 15) @@ -23,7 +23,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.util.Enumeration; +import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,6 +69,16 @@ private String facesMapping = null; + private Map<BooleanInitParameter, Boolean> booleanInitParams = + new HashMap<BooleanInitParameter, Boolean>(); + + public boolean getBooleanInitParameter(BooleanInitParameter param) { + if(param == null) { + throw new IllegalArgumentException(); + } + return booleanInitParams.get(param); + } + /** * Finds the <tt>servlet-mapping</tt> used for the * JSF servlet in the application web.xml file. @@ -122,6 +132,7 @@ try { facesConfig = loadFacesConfig(servletContext); webappConfig = loadWebXml(servletContext); + parseInitParameters(servletContext); } catch(Exception e) { throw new ExceptionInInitializerError(e); } @@ -183,4 +194,84 @@ return (WebAppBean) digester.parse(in); } + private void parseInitParameters(ServletContext context) { + for(BooleanInitParameter param : BooleanInitParameter.values()) { + Boolean value = getBooleanInitParameterValue(context, param); + booleanInitParams.put(param, value); + } + } + + private Boolean getBooleanInitParameterValue( + ServletContext context, BooleanInitParameter initParam) { + String result = context.getInitParameter(initParam.getName()); + if(result != null) { + return Boolean.valueOf(result); + } + + if(initParam.isDeprecated() && initParam.getAlternate() != null) { + return getBooleanInitParameterValue(context, + initParam.getAlternate()); + } + return Boolean.valueOf(initParam.getDefaultValue()); + } + + // Nested classes + + public enum BooleanInitParameter { + ENCODE_REDIRECT_URL( + "javax.portlet.faces.ENCODE_REDIRECT_URL", + false + ), + PRESERVE_ACTION_PARAMS( + "javax.portlet.faces.PRESERVE_ACTION_PARAMS", + false + ); + + private String name; + private boolean defaultValue; + private boolean deprecated; + private BooleanInitParameter alternate; + + private BooleanInitParameter(String name, boolean defaultValue) { + this(name, defaultValue, false, null); + } + + private BooleanInitParameter(String name, boolean defaultValue, + boolean deprecated, BooleanInitParameter alternate) { + this.name = name; + this.defaultValue = defaultValue; + this.deprecated = deprecated; + this.alternate = alternate; + } + + /** + * @return The init parameter name + */ + public String getName() { + return name; + } + + /** + * @return el defaultValue + */ + public boolean getDefaultValue() { + return defaultValue; + } + + /** + * @return The alternate init parameter + */ + public BooleanInitParameter getAlternate() { + return alternate; + } + + /** + * @return If this init parameter is deprecated or not + */ + public boolean isDeprecated() { + return deprecated; + } + + } + } Modified: trunk/src/main/java/net/sf/jsf4portlets/context/ExternalContextImpl.java =================================================================== --- trunk/src/main/java/net/sf/jsf4portlets/context/ExternalContextImpl.java 2007-06-04 20:36:23 UTC (rev 14) +++ trunk/src/main/java/net/sf/jsf4portlets/context/ExternalContextImpl.java 2007-06-07 00:01:23 UTC (rev 15) @@ -65,7 +65,7 @@ */ public class ExternalContextImpl extends ExternalContext -implements PreDestroyCallback { +implements PortletExternalContext, PreDestroyCallback { private final Logger logger = Logger.getLogger( ExternalContextImpl.class.getPackage().getName(), "net.sf.jsf4portlets.LogMessages"); @@ -116,6 +116,8 @@ private Map<String, String> requestParameterMap = null; private Map<String, String[]> requestParameterValuesMap = null; private Map<String, Object> sessionMap = null; + private Map<String, String> portletPreferenceMap = null; + private Map<String, String[]> portletPreferenceValuesMap = null; // ---------------------------------------------------------- Public Methods @@ -324,6 +326,22 @@ } return (requestHeaderValuesMap); } + + public Map<String, String> getPortletPreferenceMap() { + if(portletPreferenceMap == null) { + portletPreferenceMap = new PortletPreferenceMap( + request.getPreferences()); + } + return portletPreferenceMap; + } + + public Map<String, String[]> getPortletPreferenceValuesMap() { + if(portletPreferenceValuesMap == null) { + portletPreferenceValuesMap = new PortletPreferenceValuesMap( + request.getPreferences()); + } + return portletPreferenceValuesMap; + } @Override public Locale getRequestLocale() { Added: trunk/src/main/java/net/sf/jsf4portlets/context/PortletExternalContext.java =================================================================== --- trunk/src/main/java/net/sf/jsf4portlets/context/PortletExternalContext.java (rev 0) +++ trunk/src/main/java/net/sf/jsf4portlets/context/PortletExternalContext.java 2007-06-07 00:01:23 UTC (rev 15) @@ -0,0 +1,31 @@ +/* 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.context; + +import java.util.Map; + +public interface PortletExternalContext { + + public Map<String, String> getPortletPreferenceMap(); + + public Map<String, String[]> getPortletPreferenceValuesMap(); + +} Added: trunk/src/main/java/net/sf/jsf4portlets/context/PortletPreferenceMap.java =================================================================== --- trunk/src/main/java/net/sf/jsf4portlets/context/PortletPreferenceMap.java (rev 0) +++ trunk/src/main/java/net/sf/jsf4portlets/context/PortletPreferenceMap.java 2007-06-07 00:01:23 UTC (rev 15) @@ -0,0 +1,73 @@ +/* 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.context; + +import java.util.Enumeration; + +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; +import javax.portlet.PortletPreferences; +import javax.portlet.ReadOnlyException; + +import net.sf.jsf4portlets.util.MessagesFactory; + +class PortletPreferenceMap extends AbstractAttributeMap<String> { + private PortletPreferences prefs; + + protected PortletPreferenceMap(PortletPreferences prefs) { + if(prefs == null) { + throw new NullPointerException(); + } + this.prefs = prefs; + } + + protected String getAttribute(String name) { + return prefs.getValue(name, null); + } + + @SuppressWarnings("unchecked") + protected Enumeration<String> getAttributeNames() { + return prefs.getNames(); + } + + protected void setAttribute(String name, String value) { + throw new UnsupportedOperationException(); + /* Possible behavior : + + try { + prefs.setValue(name, value); + } catch(ReadOnlyException e) { + FacesContext context = FacesContext.getCurrentInstance(); + FacesMessage message = MessagesFactory.getMessage( + context, + FacesMessage.SEVERITY_ERROR, + MessagesFactory.READ_ONLY_PREFERENCE, + name); + context.addMessage(null, message); + context.renderResponse(); + }*/ + } + + protected void removeAttribute(String name) { + throw new UnsupportedOperationException(); + } + +} Added: trunk/src/main/java/net/sf/jsf4portlets/context/PortletPreferenceValuesMap.java =================================================================== --- trunk/src/main/java/net/sf/jsf4portlets/context/PortletPreferenceValuesMap.java (rev 0) +++ trunk/src/main/java/net/sf/jsf4portlets/context/PortletPreferenceValuesMap.java 2007-06-07 00:01:23 UTC (rev 15) @@ -0,0 +1,79 @@ +/* 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.context; + +import java.util.Enumeration; + +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; +import javax.portlet.PortletPreferences; +import javax.portlet.ReadOnlyException; + +import net.sf.jsf4portlets.util.MessagesFactory; + +/** + * + * @author alonso + * + */ +class PortletPreferenceValuesMap extends AbstractAttributeMap<String[]> { + private PortletPreferences prefs; + + protected PortletPreferenceValuesMap(PortletPreferences prefs) { + if(prefs == null) { + throw new NullPointerException(); + } + this.prefs = prefs; + } + + protected String[] getAttribute(String name) { + return prefs.getValues(name, null); + } + + @SuppressWarnings("unchecked") + protected Enumeration<String> getAttributeNames() { + return prefs.getNames(); + } + + protected void setAttribute(String name, String value[]) { + throw new UnsupportedOperationException(); + + /* Possible behavior + + try { + prefs.setValues(name, value); + } catch(ReadOnlyException e) { + FacesContext context = FacesContext.getCurrentInstance(); + FacesMessage message = MessagesFactory.getMessage( + context, + FacesMessage.SEVERITY_ERROR, + MessagesFactory.READ_ONLY_PREFERENCE, + name); + context.addMessage(null, message); + context.renderResponse(); + }*/ + } + + protected void removeAttribute(String name) { + throw new UnsupportedOperationException(); + } + +} Modified: trunk/src/main/java/net/sf/jsf4portlets/context/PreDestroyCallback.java =================================================================== --- trunk/src/main/java/net/sf/jsf4portlets/context/PreDestroyCallback.java 2007-06-04 20:36:23 UTC (rev 14) +++ trunk/src/main/java/net/sf/jsf4portlets/context/PreDestroyCallback.java 2007-06-07 00:01:23 UTC (rev 15) @@ -1,3 +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... + */ package net.sf.jsf4portlets.context; interface PreDestroyCallback { Modified: trunk/src/main/java/net/sf/jsf4portlets/el/ELConstants.java =================================================================== --- trunk/src/main/java/net/sf/jsf4portlets/el/ELConstants.java 2007-06-04 20:36:23 UTC (rev 14) +++ trunk/src/main/java/net/sf/jsf4portlets/el/ELConstants.java 2007-06-07 00:01:23 UTC (rev 15) @@ -22,9 +22,10 @@ public final class ELConstants { public static final int PORTLET_CONFIG = 0; - public static final int PORTLET_PREFERENCES = 1; - public static final int SESSION_APPLICATION_SCOPE = 2; - public static final int SESSION_PORTLET_SCOPE = 3; + public static final int PORTLET_PREFERENCE = 1; + public static final int PORTLET_PREFERENCE_VALUES = 2; + public static final int SESSION_APPLICATION_SCOPE = 3; + public static final int SESSION_PORTLET_SCOPE = 4; private ELConstants() { } Modified: trunk/src/main/java/net/sf/jsf4portlets/el/ImplicitObjectELResolver.java =================================================================== --- trunk/src/main/java/net/sf/jsf4portlets/el/ImplicitObjectELResolver.java 2007-06-04 20:36:23 UTC (rev 14) +++ trunk/src/main/java/net/sf/jsf4portlets/el/ImplicitObjectELResolver.java 2007-06-07 00:01:23 UTC (rev 15) @@ -36,9 +36,9 @@ import javax.faces.context.FacesContext; import javax.portlet.PortletConfig; import javax.portlet.PortletPreferences; -import javax.portlet.PortletRequest; import net.sf.jsf4portlets.BridgeConstants; +import net.sf.jsf4portlets.context.PortletExternalContext; import net.sf.jsf4portlets.util.Util; /** @@ -49,8 +49,11 @@ public class ImplicitObjectELResolver extends ELResolver { private static final String[] IMPLICIT_OBJECTS = { - "portletConfig", "sessionPortletScope", - "sessionApplicationScope", "portletPreferences" + "portletConfig", + "portletPreference", + "portletPreferenceValues", + "sessionApplicationScope", + "sessionPortletScope" }; @Override @@ -73,8 +76,10 @@ "sessionPortletScope", false, false, true, Map.class, true)); list.add(Util.getFeatureDescriptor("sessionApplicationScope", "sessionApplicationScope", "sessionApplicationScope", false, false, true, Map.class, true)); - list.add(Util.getFeatureDescriptor("portletPreferences", "portletPreferences", + list.add(Util.getFeatureDescriptor("portletPreference", "portletPreference", "portletPreferences", false, false, true, PortletPreferences.class, true)); + list.add(Util.getFeatureDescriptor("portletPreferenceValues", "portletPreferenceValues", + "portletPreferences' array values", false, false, true, PortletPreferences.class, true)); return list.iterator(); } @@ -108,6 +113,7 @@ FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class); ExternalContext extContext = facesContext.getExternalContext(); + PortletExternalContext pec = (PortletExternalContext) extContext; int index = Arrays.binarySearch(IMPLICIT_OBJECTS, property); if(index < 0) { return null; @@ -124,11 +130,12 @@ context.setPropertyResolved(true); return extContext.getSessionMap().get( BridgeConstants.APPLICATION_SCOPE_MAP); - case ELConstants.PORTLET_PREFERENCES: + case ELConstants.PORTLET_PREFERENCE: + context.setPropertyResolved(true); + return pec.getPortletPreferenceMap(); + case ELConstants.PORTLET_PREFERENCE_VALUES: context.setPropertyResolved(true); - PortletRequest request = (PortletRequest) - extContext.getRequest(); - return request.getPreferences(); + return pec.getPortletPreferenceValuesMap(); default: return null; } @@ -164,6 +171,7 @@ int index = Arrays.binarySearch(IMPLICIT_OBJECTS, property); if(index >= 0) { + context.setPropertyResolved(true); throw new PropertyNotWritableException((String) property); } } Added: trunk/src/main/java/net/sf/jsf4portlets/util/MessagesFactory.java =================================================================== --- trunk/src/main/java/net/sf/jsf4portlets/util/MessagesFactory.java (rev 0) +++ trunk/src/main/java/net/sf/jsf4portlets/util/MessagesFactory.java 2007-06-07 00:01:23 UTC (rev 15) @@ -0,0 +1,66 @@ +package net.sf.jsf4portlets.util; + +import java.text.MessageFormat; +import java.util.Locale; +import java.util.MissingResourceException; +import java.util.ResourceBundle; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; + +public final class MessagesFactory { + + public static final String READ_ONLY_PREFERENCE = + "javax.portlet.faces.extension.READ_ONLY_PREFERENCE"; + + private static final String FACES_MESSAGE_BUNDLE = + "javax.portlet.faces.Messages"; + + private static final Logger logger = Logger.getLogger( + MessagesFactory.class.getPackage().getName()); + + public static FacesMessage getMessage(FacesMessage.Severity severity, + String messageId, Object... params) { + return getMessage(FacesContext.getCurrentInstance(), + severity, messageId, params); + } + + public static FacesMessage getMessage(FacesContext context, + FacesMessage.Severity severity, String messageId, Object... params) { + ResourceBundle bundle = getBundle(context); + String summary = bundle.getString(messageId); + String detail = bundle.getString(messageId + "_detail"); + if(params != null && params.length > 0) { + detail = MessageFormat.format(detail, params); + } + return new FacesMessage(severity, summary, detail); + } + + private static ResourceBundle getBundle(FacesContext context) { + Locale locale; + if(context.getViewRoot() != null) { + locale = context.getViewRoot().getLocale(); + } else { + locale = context.getApplication().getDefaultLocale(); + } + + ResourceBundle bundle; + ClassLoader loader = Util.getClassLoader(MessagesFactory.class); + String basename = context.getApplication().getMessageBundle(); + if(basename != null) { + try { + bundle = ResourceBundle.getBundle(basename, locale, + loader); + return bundle; + } catch(MissingResourceException e) { + logger.log(Level.FINE, "Resource bundle couldn't " + + "be loaded: " + basename); + } + } + + return ResourceBundle.getBundle(FACES_MESSAGE_BUNDLE, locale, loader); + } + +} Modified: trunk/src/main/java/net/sf/jsf4portlets/util/Util.java =================================================================== --- trunk/src/main/java/net/sf/jsf4portlets/util/Util.java 2007-06-04 20:36:23 UTC (rev 14) +++ trunk/src/main/java/net/sf/jsf4portlets/util/Util.java 2007-06-07 00:01:23 UTC (rev 15) @@ -92,6 +92,14 @@ return mapping.startsWith("/"); } + public static ClassLoader getClassLoader(Object caller) { + ClassLoader loader = Thread.currentThread().getContextClassLoader(); + if(loader == null) { + loader = caller.getClass().getClassLoader(); + } + return loader; + } + private Util(){ } } Added: trunk/src/main/resources/javax/portlet/faces/Messages.properties =================================================================== --- trunk/src/main/resources/javax/portlet/faces/Messages.properties (rev 0) +++ trunk/src/main/resources/javax/portlet/faces/Messages.properties 2007-06-07 00:01:23 UTC (rev 15) @@ -0,0 +1,2 @@ +javax.portlet.faces.extension.READ_ONLY_PREFERENCE=Tried to modify a read-only preference. +javax.portlet.faces.extension.READ_ONLY_PREFERENCE_detail=User tried to modify the \"{0}\" read-only prference. \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <alo...@us...> - 2007-06-04 20:36:25
|
Revision: 14 http://jsf4portlets.svn.sourceforge.net/jsf4portlets/?rev=14&view=rev Author: alonsoft Date: 2007-06-04 13:36:23 -0700 (Mon, 04 Jun 2007) Log Message: ----------- Fixed JSR-301 bugs and started development of 1.0-alpha-2 version. Modified Paths: -------------- trunk/pom.xml trunk/src/main/java/javax/portlet/faces/GenericFacesPortlet.java trunk/src/main/java/net/sf/jsf4portlets/BridgeImpl.java trunk/src/main/java/net/sf/jsf4portlets/context/AbstractAttributeMap.java trunk/src/main/java/net/sf/jsf4portlets/context/ApplicationMap.java trunk/src/main/java/net/sf/jsf4portlets/context/ExternalContextImpl.java trunk/src/main/java/net/sf/jsf4portlets/context/RequestMap.java trunk/src/main/java/net/sf/jsf4portlets/context/SessionMap.java Added Paths: ----------- trunk/src/main/java/net/sf/jsf4portlets/context/PreDestroyCallback.java trunk/src/site/apt/ trunk/src/site/apt/download.apt trunk/src/site/apt/release_notes.apt trunk/src/site/apt/user_docs.apt Removed Paths: ------------- trunk/src/site/xdoc/download.xml trunk/src/site/xdoc/release_notes.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2007-06-03 19:32:14 UTC (rev 13) +++ trunk/pom.xml 2007-06-04 20:36:23 UTC (rev 14) @@ -11,9 +11,9 @@ <url>http://jsf4portlets.sf.net/</url> <scm> - <connection>scm:svn:https://jsf4portlets.svn.sourceforge.net/svnroot/jsf4portlets/tags/jsf4portlets-1.0-alpha-1</connection> - <developerConnection>scm:svn:https://jsf4portlets.svn.sourceforge.net/svnroot/jsf4portlets/tags/jsf4portlets-1.0-alpha-1</developerConnection> - <url>http://jsf4portlets.svn.sourceforge.net/viewvc/jsf4portlets/tags/jsf4portlets-1.0-alpha-1</url> + <connection>scm:svn:https://jsf4portlets.svn.sourceforge.net/svnroot/jsf4portlets/trunk</connection> + <developerConnection>scm:svn:https://jsf4portlets.svn.sourceforge.net/svnroot/jsf4portlets/trunk</developerConnection> + <url>http://jsf4portlets.svn.sourceforge.net/viewvc/jsf4portlets/trunk</url> </scm> <description> @@ -158,6 +158,10 @@ <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/src/main/java/javax/portlet/faces/GenericFacesPortlet.java =================================================================== --- trunk/src/main/java/javax/portlet/faces/GenericFacesPortlet.java 2007-06-03 19:32:14 UTC (rev 13) +++ trunk/src/main/java/javax/portlet/faces/GenericFacesPortlet.java 2007-06-04 20:36:23 UTC (rev 14) @@ -126,10 +126,19 @@ return portletConfig.getResourceBundle(locale); } + protected Bridge getBridge() { + return bridge; + } + private void storeViewIdParameter(PortletRequest request) throws PortletException { PortletMode portletMode = request.getPortletMode(); + // Check whether the requested mode is allowed + if(!request.isPortletModeAllowed(portletMode)) { + throw new PortletException(portletMode + " is not allowed"); + } + String viewId = null; // Get the view identifier based on the mode. if(PortletMode.VIEW.equals(portletMode)) { @@ -140,9 +149,13 @@ viewId = getPortletConfig().getInitParameter(INIT_HELP); } - // Check whether the requested mode is allowed - if(!request.isPortletModeAllowed(portletMode) || viewId == null) { - throw new PortletException(portletMode + " is not allowed"); + if(viewId == null) { + if(PortletMode.VIEW.equals(portletMode)) { + throw new PortletException("Portlet '" + getPortletName() + "' misses a default view page. " + + "Please take a look to http://jsf4portlets.sf.net/web/user_docs.html"); + } + throw new PortletException("Portlet '" + getPortletName() + + "' misses a default viewId for portlet mode: " + portletMode); } request.setAttribute("javax.portlet.faces.defaultViewId", viewId); Modified: trunk/src/main/java/net/sf/jsf4portlets/BridgeImpl.java =================================================================== --- trunk/src/main/java/net/sf/jsf4portlets/BridgeImpl.java 2007-06-03 19:32:14 UTC (rev 13) +++ trunk/src/main/java/net/sf/jsf4portlets/BridgeImpl.java 2007-06-04 20:36:23 UTC (rev 14) @@ -245,7 +245,7 @@ // Protected methods - protected final RequestScope getPreviousRequestScope( + protected RequestScope getPreviousRequestScope( PortletRequest request) { PortletSession session = request.getPortletSession(true); String requestScopeId = getRequestScopeIdentifier(request); Modified: trunk/src/main/java/net/sf/jsf4portlets/context/AbstractAttributeMap.java =================================================================== --- trunk/src/main/java/net/sf/jsf4portlets/context/AbstractAttributeMap.java 2007-06-03 19:32:14 UTC (rev 13) +++ trunk/src/main/java/net/sf/jsf4portlets/context/AbstractAttributeMap.java 2007-06-04 20:36:23 UTC (rev 14) @@ -36,13 +36,13 @@ private Set<Entry<String, T>> entries = new AttributeEntrySet(); private Collection<T> values = new ValueSet(); - private ExternalContextImpl.Callback callback; + private PreDestroyCallback callback; protected AbstractAttributeMap() { this(null); } - protected AbstractAttributeMap(ExternalContextImpl.Callback callback) { + protected AbstractAttributeMap(PreDestroyCallback callback) { this.callback = callback; } @@ -55,7 +55,7 @@ for(String key : names) { T value = getAttribute(key); removeAttribute(key); - if(callback != null) { + if(callback != null && value != null) { callback.attributeRemoved(key, value); } } @@ -143,7 +143,7 @@ protected abstract void removeAttribute(String key); - protected final ExternalContextImpl.Callback getCallback() { + protected final PreDestroyCallback getCallback() { return callback; } Modified: trunk/src/main/java/net/sf/jsf4portlets/context/ApplicationMap.java =================================================================== --- trunk/src/main/java/net/sf/jsf4portlets/context/ApplicationMap.java 2007-06-03 19:32:14 UTC (rev 13) +++ trunk/src/main/java/net/sf/jsf4portlets/context/ApplicationMap.java 2007-06-04 20:36:23 UTC (rev 14) @@ -27,8 +27,10 @@ class ApplicationMap extends AbstractAttributeMap<Object> { private PortletContext portletContext; - protected ApplicationMap(PortletContext portletContext) { - assert portletContext != null; + protected ApplicationMap(PortletContext portletContext, + PreDestroyCallback callback) { + super(callback); + assert (portletContext != null && callback != null); this.portletContext = portletContext; } Modified: trunk/src/main/java/net/sf/jsf4portlets/context/ExternalContextImpl.java =================================================================== --- trunk/src/main/java/net/sf/jsf4portlets/context/ExternalContextImpl.java 2007-06-03 19:32:14 UTC (rev 13) +++ trunk/src/main/java/net/sf/jsf4portlets/context/ExternalContextImpl.java 2007-06-04 20:36:23 UTC (rev 14) @@ -64,17 +64,12 @@ * a portlet environment.</p> */ -public class ExternalContextImpl extends ExternalContext { +public class ExternalContextImpl extends ExternalContext +implements PreDestroyCallback { private final Logger logger = Logger.getLogger( ExternalContextImpl.class.getPackage().getName(), "net.sf.jsf4portlets.LogMessages"); - // ---------------------------------------------------- Protected Interfaces - - protected static interface Callback { - public void attributeRemoved(String name, Object value); - } - // ------------------------------------------------------------ Constructors @@ -122,8 +117,6 @@ private Map<String, String[]> requestParameterValuesMap = null; private Map<String, Object> sessionMap = null; - private Callback callback = null; - // ---------------------------------------------------------- Public Methods @@ -245,7 +238,7 @@ @Override public Map<String, Object> getApplicationMap() { if (applicationMap == null) { - applicationMap = new ApplicationMap(context); + applicationMap = new ApplicationMap(context, this); } return (applicationMap); } @@ -346,7 +339,7 @@ @Override public Map<String, Object> getRequestMap() { if (requestMap == null) { - requestMap = new RequestMap(request, getCallback()); + requestMap = new RequestMap(request, this); } return (requestMap); } @@ -364,12 +357,14 @@ if(requestScope != null) { logger.log(Level.FINER, "J4P_000019"); requestParameterMap = new RenderRequestParameterMap(requestScope); - } else { - requestParameterMap = Collections.<String, String>emptyMap(); } - } else { - throw new IllegalStateException(); } + + // Don't throw an IllegalStateException, return an empty map. + // Throwing an exception provokes that the portlet becomes unavailable. + if(requestParameterMap == null) { + requestParameterMap = Collections.<String, String>emptyMap(); + } } } return requestParameterMap; @@ -393,12 +388,14 @@ if(requestScope != null) { logger.log(Level.FINER, "J4P_000019"); requestParameterValuesMap = new RenderRequestParameterValuesMap(requestScope); - } else { - requestParameterValuesMap = Collections.<String, String[]>emptyMap(); } - } else { - throw new IllegalStateException(); } + + // Don't throw an IllegalStateException, return an empty map. + // Throwing an exception provokes that the portlet becomes unavailable. + if(requestParameterValuesMap == null) { + requestParameterValuesMap = Collections.<String, String[]>emptyMap(); + } } } return requestParameterValuesMap; @@ -477,7 +474,7 @@ @Override public Map<String, Object> getSessionMap() { if (sessionMap == null) { - sessionMap = new SessionMap(request, getCallback()); + sessionMap = new SessionMap(request, this); } return (sessionMap); } @@ -554,7 +551,7 @@ } PathString qs = PathString.parse(getRequestContextPath(), path); - if(path.startsWith("#") || path.startsWith(getRequestContextPath()) + if(path.startsWith("#") || !path.startsWith(getRequestContextPath()) || !"true".equals(qs.getParameter(BridgeConstants.DIRECT_LINK))) { if (logger.isLoggable(Level.FINEST)) { logger.log(Level.FINER, "J4P_000024", path); @@ -563,33 +560,24 @@ } logger.exiting(ExternalContextImpl.class.getName(), "redirect"); } - - private Callback getCallback() { - if(callback == null) { - callback = new CallbackImpl(); - } - return callback; - } - private class CallbackImpl implements Callback { - - public void attributeRemoved(String name, Object value) { - PortletConfiguration config = PortletConfiguration - .getInstance(ExternalContextImpl.this); - if(config.getManagedBean(name) != null) { - InjectionProvider ip = InjectionProviderFactory - .createInstance(ExternalContextImpl.this); - try { - ip.invokePreDestroy(value); - } catch(InjectionProviderException e) { - LogRecord logRecord = new LogRecord(Level.INFO, "J4P_000033"); - logRecord.setParameters(new Object[]{ name }); - logRecord.setThrown(e); - logger.log(logRecord); - } + // PreDestroyCallback + + public void attributeRemoved(String name, Object value) { + PortletConfiguration config = PortletConfiguration + .getInstance(ExternalContextImpl.this); + if(config.getManagedBean(name) != null) { + InjectionProvider ip = InjectionProviderFactory + .createInstance(this); + try { + ip.invokePreDestroy(value); + } catch(InjectionProviderException e) { + LogRecord logRecord = new LogRecord(Level.INFO, "J4P_000033"); + logRecord.setParameters(new Object[]{ name }); + logRecord.setThrown(e); + logger.log(logRecord); } } - } } Added: trunk/src/main/java/net/sf/jsf4portlets/context/PreDestroyCallback.java =================================================================== --- trunk/src/main/java/net/sf/jsf4portlets/context/PreDestroyCallback.java (rev 0) +++ trunk/src/main/java/net/sf/jsf4portlets/context/PreDestroyCallback.java 2007-06-04 20:36:23 UTC (rev 14) @@ -0,0 +1,7 @@ +package net.sf.jsf4portlets.context; + +interface PreDestroyCallback { + + public void attributeRemoved(String name, Object value); + +} Modified: trunk/src/main/java/net/sf/jsf4portlets/context/RequestMap.java =================================================================== --- trunk/src/main/java/net/sf/jsf4portlets/context/RequestMap.java 2007-06-03 19:32:14 UTC (rev 13) +++ trunk/src/main/java/net/sf/jsf4portlets/context/RequestMap.java 2007-06-04 20:36:23 UTC (rev 14) @@ -28,9 +28,9 @@ private PortletRequest portletRequest; protected RequestMap(PortletRequest portletRequest, - ExternalContextImpl.Callback callback) { + PreDestroyCallback callback) { super(callback); - assert portletRequest != null; + assert (portletRequest != null && callback != null); this.portletRequest = portletRequest; } Modified: trunk/src/main/java/net/sf/jsf4portlets/context/SessionMap.java =================================================================== --- trunk/src/main/java/net/sf/jsf4portlets/context/SessionMap.java 2007-06-03 19:32:14 UTC (rev 13) +++ trunk/src/main/java/net/sf/jsf4portlets/context/SessionMap.java 2007-06-04 20:36:23 UTC (rev 14) @@ -34,16 +34,14 @@ private int scope; protected SessionMap(PortletRequest portletRequest, - ExternalContextImpl.Callback callback) { + PreDestroyCallback callback) { this(portletRequest, PortletSession.PORTLET_SCOPE, callback); } protected SessionMap(PortletRequest portletRequest, int scope, - ExternalContextImpl.Callback callback) { + PreDestroyCallback callback) { super(callback); - if(portletRequest == null) { - throw new NullPointerException(); - } + assert (portletRequest != null && callback != null); this.portletRequest = portletRequest; this.scope = scope; } Added: trunk/src/site/apt/download.apt =================================================================== --- trunk/src/site/apt/download.apt (rev 0) +++ trunk/src/site/apt/download.apt 2007-06-04 20:36:23 UTC (rev 14) @@ -0,0 +1,31 @@ + --- + Download JSF 4 Portlets + --- + A. Alonso Domínguez + --- + +Download JSF 4 Portlets + + 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 + +** 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}} | +*----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + Unix (bzip2) | {{{http://downloads.sourceforge.net/jsf4portlets/jsf4portlets-1.0-alpha-1-bin.tar.bz2?modtime=1180909014&big_mirror=0}jsf4portlets-1.0-alpha-1-bin.tar.bz2}} | +*----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +** Source Distributions + +*----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + Windows (*.zip) | {{{http://downloads.sourceforge.net/jsf4portlets/jsf4portlets-1.0-alpha-1-src.zip?modtime=1180909373&big_mirror=0}jsf4portlets-1.0-alpha-1-src.zip}} | +*----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + Unix (gzip) | {{{http://downloads.sourceforge.net/jsf4portlets/jsf4portlets-1.0-alpha-1-src.tar.gz?modtime=1180909345&big_mirror=0}jsf4portlets-1.0-alpha-1-src.tar.gz}} | +*----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + Unix (bzip2) | {{{http://downloads.sourceforge.net/jsf4portlets/jsf4portlets-1.0-alpha-1-src.tar.bz2?modtime=1180909325&big_mirror=0}jsf4portlets-1.0-alpha-1-src.tar.bz2}} | +*----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ Added: trunk/src/site/apt/release_notes.apt =================================================================== --- trunk/src/site/apt/release_notes.apt (rev 0) +++ trunk/src/site/apt/release_notes.apt 2007-06-04 20:36:23 UTC (rev 14) @@ -0,0 +1 @@ +JSF 4 Portlets - Release Notes Added: trunk/src/site/apt/user_docs.apt =================================================================== --- trunk/src/site/apt/user_docs.apt (rev 0) +++ trunk/src/site/apt/user_docs.apt 2007-06-04 20:36:23 UTC (rev 14) @@ -0,0 +1,130 @@ + --- + Using JSF 4 Portlets + --- + A. Alonso Dominguez + + +Using JSF 4 Portlets + + Before reading this document you should take a look to the {{{getting_started.html}Getting Started Guide}}. + +* Basic Configuration + + Because a JSF Portlet Application is a normal JSF Web Application we need to configure the Faces Servlet and the state saving method: + +** Faces Servlet + ++--- +<web-app ...> + + <context-param> + <param-name>javax.faces.STATE_SAVING_METHOD</param-name> + <param-name>server</param-name> + </context-param> + + <servlet> + <servlet-name>FacesServlet</servlet-name> + <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> + + <load-on-startup>0</load-on-startup> + </servlet> + + <servlet-mapping> + <servlet-name>FacesServlet</servlet-name> + <url-pattern>*.jsf</url-pattern> + </servlet-mapping> + +</web-app> ++--- + +** Default Bridge Implementation + + Configure the default bridge that will be used if a given portlet is not specified with another diferent implementation in the file <<<WEB-INF/web.xml>>>: + ++--- +<context-param> + <param-name>javax.portlet.faces.extension.bridgeClass</param-name> + <param-value>net.sf.jsf4portlets.BridgeImpl</param-value> +</context-param> ++--- + +** 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: + ++--- +<portlet-app ...> + + <portlet> + <portlet-name>MyFacesPortlet</portlet-name> + <portlet-class> + javax.portlet.faces.GenericFacesPortlet + </portlet-class> + + <init-param> + <name>javax.portlet.faces.extension.INIT_VIEW</name> + <value>/welcome.jsf</value> + </init-param> + + ... + </portlet> + +</portlet-app> ++--- + +* Advanced Configuration + +** 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: + ++--- +<context-param> + <param-name>javax.portlet.faces.ENCODE_REDIRECT_URL</param-name> + <param-value>true</param-value> +</context-param> ++--- + +*** Preserving action parameters + ++--- +<context-param> + <param-name>javax.portlet.faces.PRESERVE_ACTION_PARAMS</param-name> + <param-value>true</param-value> +</context-param> ++--- + +** 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: + +*** View + ++--- +<init-param> + <name>javax.portlet.faces.extension.INIT_VIEW</name> + <value>/view.jsf</value> +</init-param> ++--- + +*** Edit + ++--- +<init-param> + <name>javax.portlet.faces.extension.INIT_EDIT</name> + <value>/edit.jsf</value> +</init-param> ++--- + +*** Help + ++--- +<init-param> + <name>javax.portlet.faces.extension.INIT_HELP</name> + <value>/help.jsf</value> +</init-param> ++--- Deleted: trunk/src/site/xdoc/download.xml =================================================================== --- trunk/src/site/xdoc/download.xml 2007-06-03 19:32:14 UTC (rev 13) +++ trunk/src/site/xdoc/download.xml 2007-06-04 20:36:23 UTC (rev 14) @@ -1,35 +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... ---> - -<document> - <properties> - <autor email="alo...@us...">A. Alonso Dominguez</autor> - <title>Download JSF 4 Portlets</title> - </properties> - <body> - <section name="Binaries"> - <p>Sorry, there are no releases yet.</p> - </section> - </body> -</document> \ No newline at end of file Deleted: trunk/src/site/xdoc/release_notes.xml =================================================================== --- trunk/src/site/xdoc/release_notes.xml 2007-06-03 19:32:14 UTC (rev 13) +++ trunk/src/site/xdoc/release_notes.xml 2007-06-04 20:36:23 UTC (rev 14) @@ -1,32 +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... ---> - -<document> - <properties> - <author email="alo...@us...">A. Alonso Dominguez</author> - <title>JSF 4 Portlets - Release Notes</title> - </properties> - <body> - </body> -</document> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |