Author: nbelaevski
Date: 2010-07-21 10:43:04 -0400 (Wed, 21 Jul 2010)
New Revision: 18179
Added:
root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinPropertiesELResolver.java
Removed:
root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinPropertyResolver.java
root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinVariableResolver.java
Modified:
root/core/trunk/impl/src/main/resources/META-INF/faces-config.xml
Log:
Legacy skin EL-related classes updated
Added:
root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinPropertiesELResolver.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinPropertiesELResolver.java
(rev 0)
+++
root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinPropertiesELResolver.java 2010-07-21
14:43:04 UTC (rev 18179)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.skin;
+
+import java.beans.FeatureDescriptor;
+import java.util.Iterator;
+
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.el.PropertyNotFoundException;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class SkinPropertiesELResolver extends ELResolver {
+
+ @Override
+ public Object getValue(ELContext context, Object base, Object property) {
+ if (base instanceof Skin) {
+ Skin skin = (Skin) base;
+
+ if (property == null) {
+ throw new PropertyNotFoundException("property name is null");
+ }
+
+ context.setPropertyResolved(true);
+ FacesContext facesContext = (FacesContext)
context.getContext(FacesContext.class);
+ return skin.getParameter(facesContext, property.toString());
+ }
+
+ return null;
+ }
+
+ @Override
+ public Class<?> getType(ELContext context, Object base, Object property) {
+ return null;
+ }
+
+ @Override
+ public void setValue(ELContext context, Object base, Object property, Object value)
{
+ if (base instanceof Skin) {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ @Override
+ public boolean isReadOnly(ELContext context, Object base, Object property) {
+ return true;
+ }
+
+ @Override
+ public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context,
Object base) {
+ return null;
+ }
+
+ @Override
+ public Class<?> getCommonPropertyType(ELContext context, Object base) {
+ return Object.class;
+ }
+
+}
Deleted: root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinPropertyResolver.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinPropertyResolver.java 2010-07-21
14:40:56 UTC (rev 18178)
+++
root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinPropertyResolver.java 2010-07-21
14:43:04 UTC (rev 18179)
@@ -1,180 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.skin;
-
-import org.ajax4jsf.Messages;
-import org.richfaces.log.RichfacesLogger;
-import org.slf4j.Logger;
-
-import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.PropertyResolver;
-
-/**
- * Resolve Skin propertyes.
- *
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:41 $
- */
-public class SkinPropertyResolver extends PropertyResolver {
- private static final Logger LOG = RichfacesLogger.APPLICATION.getLogger();
- private PropertyResolver parent = null;
-
- /**
- * @param parent
- */
- public SkinPropertyResolver(PropertyResolver parent) {
- this.parent = parent;
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.el.PropertyResolver#getType(java.lang.Object, int)
- */
- @Override
- public Class getType(Object base, int index) {
- if (base instanceof Skin) {
- if (LOG.isDebugEnabled()) {
-
LOG.debug(Messages.getMessage(Messages.ACESSING_SKIN_PROPERTY_AS_ARRAY_ERROR));
- }
-
- return null;
- }
-
- return parent.getType(base, index);
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.el.PropertyResolver#getType(java.lang.Object, java.lang.Object)
- */
- @Override
- public Class getType(Object base, Object property) {
- if (base instanceof Skin) {
- Skin skin = (Skin) base;
-
- if (property instanceof String) {
- return skin.getParameter(FacesContext.getCurrentInstance(), (String)
property).getClass();
- }
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(Messages.getMessage(Messages.ACESSING_SKIN_PROPERTY_ERROR));
- }
-
- return null;
- }
-
- return parent.getType(base, property);
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.el.PropertyResolver#getValue(java.lang.Object, int)
- */
- @Override
- public Object getValue(Object base, int index) {
- if (base instanceof Skin) {
- if (LOG.isDebugEnabled()) {
-
LOG.debug(Messages.getMessage(Messages.ACESSING_SKIN_PROPERTY_AS_ARRAY_ERROR));
- }
-
- return null;
- }
-
- return parent.getValue(base, index);
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.el.PropertyResolver#getValue(java.lang.Object, java.lang.Object)
- */
- @Override
- public Object getValue(Object base, Object property) {
- if (base instanceof Skin) {
- Skin skin = (Skin) base;
-
- if (property instanceof String) {
- return skin.getParameter(FacesContext.getCurrentInstance(), (String)
property);
- }
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(Messages.getMessage(Messages.ACESSING_SKIN_PROPERTY_ERROR));
- }
-
- return null;
- }
-
- return parent.getValue(base, property);
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.el.PropertyResolver#isReadOnly(java.lang.Object, int)
- */
- @Override
- public boolean isReadOnly(Object base, int arg1) {
- if (base instanceof Skin) {
- return true;
- }
-
- return parent.isReadOnly(base, arg1);
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.el.PropertyResolver#isReadOnly(java.lang.Object,
java.lang.Object)
- */
- @Override
- public boolean isReadOnly(Object base, Object arg1) {
- if (base instanceof Skin) {
- return true;
- }
-
- return parent.isReadOnly(base, arg1);
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.el.PropertyResolver#setValue(java.lang.Object, int,
java.lang.Object)
- */
- @Override
- public void setValue(Object base, int index, Object value) {
- if (base instanceof Skin) {
- throw new
EvaluationException(Messages.getMessage(Messages.SKIN_PROPERTIES_READ_ONLY_ERROR));
- }
-
- parent.setValue(base, index, value);
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.el.PropertyResolver#setValue(java.lang.Object, java.lang.Object,
java.lang.Object)
- */
- @Override
- public void setValue(Object base, Object property, Object value) {
- if (base instanceof Skin) {
- throw new
EvaluationException(Messages.getMessage(Messages.SKIN_PROPERTIES_READ_ONLY_ERROR));
- }
-
- parent.setValue(base, property, value);
- }
-}
Deleted: root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinVariableResolver.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinVariableResolver.java 2010-07-21
14:40:56 UTC (rev 18178)
+++
root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinVariableResolver.java 2010-07-21
14:43:04 UTC (rev 18179)
@@ -1,65 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.skin;
-
-import org.richfaces.VersionBean;
-
-import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.VariableResolver;
-
-/**
- * Resolve current skin as EL Variable. e.g. #{chameleonSkin['color'] }
#{chameleonSkin.color}
- * must be evaluated as Skin.getProperty(context,"color");
- *
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:41 $
- */
-public class SkinVariableResolver extends VariableResolver {
- public static final String CHAMELEON_VARIABLE_NAME = "vcp";
- public static final String SKIN_VARIABLE_NAME = "vcpSkin";
- private VariableResolver parent = null;
-
- public SkinVariableResolver(VariableResolver parent) {
- this.parent = parent;
- }
-
- /*
- * (non-Javadoc)
- * @see
javax.faces.el.VariableResolver#resolveVariable(javax.faces.context.FacesContext,
java.lang.String)
- */
- public Object resolveVariable(FacesContext context, String name) throws
EvaluationException {
-
- // TODO: Why do we need this?
- if (SKIN_VARIABLE_NAME.equals(name)) {
- return SkinFactory.getInstance().getSkin(context);
- } else if (CHAMELEON_VARIABLE_NAME.equals(name)) {
- return new VersionBean();
- }
-
- if (parent != null) {
- return parent.resolveVariable(context, name);
- } else {
- return null;
- }
- }
-}
Modified: root/core/trunk/impl/src/main/resources/META-INF/faces-config.xml
===================================================================
--- root/core/trunk/impl/src/main/resources/META-INF/faces-config.xml 2010-07-21 14:40:56
UTC (rev 18178)
+++ root/core/trunk/impl/src/main/resources/META-INF/faces-config.xml 2010-07-21 14:43:04
UTC (rev 18179)
@@ -15,11 +15,10 @@
<source-class>org.ajax4jsf.component.UIDataAdaptor</source-class>
</system-event-listener -->
<!--
- <variable-resolver>org.richfaces.skin.SkinVariableResolver</variable-resolver>
- <property-resolver>org.richfaces.skin.SkinPropertyResolver</property-resolver>
<view-handler>org.ajax4jsf.application.AjaxViewHandler</view-handler>
-->
<!-- state-manager>org.ajax4jsf.application.AjaxStateManager</state-manager
-->
+
<el-resolver>org.richfaces.skin.SkinPropertiesELResolver</el-resolver>
</application>
<!-- lifecycle>
<phase-listener>org.ajax4jsf.event.AjaxPhaseListener</phase-listener>