You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@apache.org on 2005/05/28 03:09:09 UTC
svn commit: r178848 [2/2] -
/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain
Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateConverterCommand.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateConverterCommand.java?rev=178848&r1=178847&r2=178848&view=diff
==============================================================================
--- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateConverterCommand.java (original)
+++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateConverterCommand.java Fri May 27 18:09:07 2005
@@ -1,116 +1,116 @@
-/*
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Id$
- */
-
-package org.apache.shale.clay.component.chain;
-
-import java.util.Locale;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.ValueHolder;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-
-import org.apache.commons.chain.Context;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.shale.clay.config.beans.ComponentBean;
-import org.apache.shale.clay.utils.PropUtils;
-
-/**
- * <p>
- * This <code>Command</code> will create a <code>Converter<code> from the
- * <code>displayElement</code> attribute of the {@link org.apache.shale.clay.component.chain.ClayContext} assigning
- * it to the <code>parent</code>
- * </p>
- *
- */
-
-public class CreateConverterCommand extends AbstractCommand {
-
- /**
- * <p>
- * Common Logger utility
- * </p>
- */
- private static Log log;
- static {
- log = LogFactory.getLog(CreateConverterCommand.class);
- }
-
- /**
- * <p>
- * Creates a object instance realizing the {@link Converter} interface
- * assigning to the <code>parent</code>. The <code>parent</code> must
- * implement the {@link ValueHolder} interface.
- * </p>
- */
- public boolean execute(Context context) throws Exception {
-
- boolean isFinal = false;
-
- ClayContext clayContext = (ClayContext) context;
- if (clayContext == null)
- throw new NullPointerException(messages
- .getMessage("clay.null.clayContext"));
-
- UIComponent child = (UIComponent) clayContext.getChild();
- if (child == null)
- throw new NullPointerException(messages
- .getMessage("clay.null.childComponent"));
-
- ComponentBean displayElement = clayContext.getDisplayElement();
- if (displayElement == null)
- throw new NullPointerException(messages
- .getMessage("clay.null.componentBean"));
-
- ValueHolder parent = (ValueHolder) clayContext.getParent();
- if (parent == null)
- throw new NullPointerException(messages
- .getMessage("clay.null.parentComponent"));
-
- FacesContext facesContext = clayContext.getFacesContext();
- if (facesContext == null)
- throw new NullPointerException(messages
- .getMessage("clay.null.facesContext"));
- Converter converter = null;
- try {
- converter = facesContext.getApplication().createConverter(
- displayElement.getComponentType());
- } catch (Exception e) {
- log.error(messages.getMessage("create.converter.error",
- new Object[] { displayElement }), e);
- throw e;
- }
- if (converter != null) {
- Locale locale = facesContext.getViewRoot().getLocale();
- if (locale == null)
- locale = facesContext.getApplication().getDefaultLocale();
- if (locale != null)
- PropUtils.setProperty(converter, "locale", locale, null);
- parent.setConverter(converter);
- // reassign the child to the converter for the
- // AssignPropertiesCommand
- clayContext.setChild(converter);
- } else {
- isFinal = true;
- }
-
- return isFinal;
- }
-
-}
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id$
+ */
+
+package org.apache.shale.clay.component.chain;
+
+import java.util.Locale;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.ValueHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+import org.apache.commons.chain.Context;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.shale.clay.config.beans.ComponentBean;
+import org.apache.shale.clay.utils.PropUtils;
+
+/**
+ * <p>
+ * This <code>Command</code> will create a <code>Converter<code> from the
+ * <code>displayElement</code> attribute of the {@link org.apache.shale.clay.component.chain.ClayContext} assigning
+ * it to the <code>parent</code>
+ * </p>
+ *
+ */
+
+public class CreateConverterCommand extends AbstractCommand {
+
+ /**
+ * <p>
+ * Common Logger utility
+ * </p>
+ */
+ private static Log log;
+ static {
+ log = LogFactory.getLog(CreateConverterCommand.class);
+ }
+
+ /**
+ * <p>
+ * Creates a object instance realizing the {@link Converter} interface
+ * assigning to the <code>parent</code>. The <code>parent</code> must
+ * implement the {@link ValueHolder} interface.
+ * </p>
+ */
+ public boolean execute(Context context) throws Exception {
+
+ boolean isFinal = false;
+
+ ClayContext clayContext = (ClayContext) context;
+ if (clayContext == null)
+ throw new NullPointerException(messages
+ .getMessage("clay.null.clayContext"));
+
+ UIComponent child = (UIComponent) clayContext.getChild();
+ if (child == null)
+ throw new NullPointerException(messages
+ .getMessage("clay.null.childComponent"));
+
+ ComponentBean displayElement = clayContext.getDisplayElement();
+ if (displayElement == null)
+ throw new NullPointerException(messages
+ .getMessage("clay.null.componentBean"));
+
+ ValueHolder parent = (ValueHolder) clayContext.getParent();
+ if (parent == null)
+ throw new NullPointerException(messages
+ .getMessage("clay.null.parentComponent"));
+
+ FacesContext facesContext = clayContext.getFacesContext();
+ if (facesContext == null)
+ throw new NullPointerException(messages
+ .getMessage("clay.null.facesContext"));
+ Converter converter = null;
+ try {
+ converter = facesContext.getApplication().createConverter(
+ displayElement.getComponentType());
+ } catch (Exception e) {
+ log.error(messages.getMessage("create.converter.error",
+ new Object[] { displayElement }), e);
+ throw e;
+ }
+ if (converter != null) {
+ Locale locale = facesContext.getViewRoot().getLocale();
+ if (locale == null)
+ locale = facesContext.getApplication().getDefaultLocale();
+ if (locale != null)
+ PropUtils.setProperty(converter, "locale", locale, null);
+ parent.setConverter(converter);
+ // reassign the child to the converter for the
+ // AssignPropertiesCommand
+ clayContext.setChild(converter);
+ } else {
+ isFinal = true;
+ }
+
+ return isFinal;
+ }
+
+}
Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateValidatorCommand.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateValidatorCommand.java?rev=178848&r1=178847&r2=178848&view=diff
==============================================================================
--- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateValidatorCommand.java (original)
+++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateValidatorCommand.java Fri May 27 18:09:07 2005
@@ -1,102 +1,102 @@
-/*
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Id$
- */
-
-package org.apache.shale.clay.component.chain;
-
-import javax.faces.component.EditableValueHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.validator.Validator;
-
-import org.apache.commons.chain.Context;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.shale.clay.config.beans.ComponentBean;
-
-/**
- * <p>
- * Creates an object implementing the {@link Validator} interface and assigns it
- * to the <code>parent</code> from the {@link ClayContext}.
- * </p>
- */
-public class CreateValidatorCommand extends AbstractCommand {
-
- /**
- * <p>
- * Common Logger utility
- * </p>
- */
- private static Log log;
- static {
- log = LogFactory.getLog(CreateValidatorCommand.class);
- }
-
- /**
- * <p>
- * Creates a faces validator object that is registered in the
- * <strong>faces-config.xml</strong> file and assigns it to the parent.
- * </p>
- */
- public boolean execute(Context context) throws Exception {
-
- boolean isFinal = false;
-
- ClayContext clayContext = (ClayContext) context;
- if (clayContext == null)
- throw new NullPointerException(messages
- .getMessage("clay.null.clayContext"));
-
- UIComponent child = (UIComponent) clayContext.getChild();
- if (child == null)
- throw new NullPointerException(messages
- .getMessage("clay.null.childComponent"));
-
- ComponentBean displayElement = clayContext.getDisplayElement();
- if (displayElement == null)
- throw new NullPointerException(messages
- .getMessage("clay.null.componentBean"));
-
- EditableValueHolder parent = (EditableValueHolder) clayContext
- .getParent();
- if (parent == null)
- throw new NullPointerException(messages
- .getMessage("clay.null.parentComponent"));
-
- FacesContext facesContext = clayContext.getFacesContext();
- if (facesContext == null)
- throw new NullPointerException(messages
- .getMessage("clay.null.facesContext"));
-
- Validator validator = null;
- try {
- validator = facesContext.getApplication().createValidator(
- displayElement.getComponentType());
- } catch (Exception e) {
- log.error(messages.getMessage("create.validator.error",
- new Object[] { displayElement }), e);
- throw e;
- }
- parent.addValidator(validator);
- // reassign the child to the validator for the
- // AssignPropertiesCommand
- clayContext.setChild(validator);
-
- return isFinal;
- }
-
-}
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id$
+ */
+
+package org.apache.shale.clay.component.chain;
+
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.Validator;
+
+import org.apache.commons.chain.Context;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.shale.clay.config.beans.ComponentBean;
+
+/**
+ * <p>
+ * Creates an object implementing the {@link Validator} interface and assigns it
+ * to the <code>parent</code> from the {@link ClayContext}.
+ * </p>
+ */
+public class CreateValidatorCommand extends AbstractCommand {
+
+ /**
+ * <p>
+ * Common Logger utility
+ * </p>
+ */
+ private static Log log;
+ static {
+ log = LogFactory.getLog(CreateValidatorCommand.class);
+ }
+
+ /**
+ * <p>
+ * Creates a faces validator object that is registered in the
+ * <strong>faces-config.xml</strong> file and assigns it to the parent.
+ * </p>
+ */
+ public boolean execute(Context context) throws Exception {
+
+ boolean isFinal = false;
+
+ ClayContext clayContext = (ClayContext) context;
+ if (clayContext == null)
+ throw new NullPointerException(messages
+ .getMessage("clay.null.clayContext"));
+
+ UIComponent child = (UIComponent) clayContext.getChild();
+ if (child == null)
+ throw new NullPointerException(messages
+ .getMessage("clay.null.childComponent"));
+
+ ComponentBean displayElement = clayContext.getDisplayElement();
+ if (displayElement == null)
+ throw new NullPointerException(messages
+ .getMessage("clay.null.componentBean"));
+
+ EditableValueHolder parent = (EditableValueHolder) clayContext
+ .getParent();
+ if (parent == null)
+ throw new NullPointerException(messages
+ .getMessage("clay.null.parentComponent"));
+
+ FacesContext facesContext = clayContext.getFacesContext();
+ if (facesContext == null)
+ throw new NullPointerException(messages
+ .getMessage("clay.null.facesContext"));
+
+ Validator validator = null;
+ try {
+ validator = facesContext.getApplication().createValidator(
+ displayElement.getComponentType());
+ } catch (Exception e) {
+ log.error(messages.getMessage("create.validator.error",
+ new Object[] { displayElement }), e);
+ throw e;
+ }
+ parent.addValidator(validator);
+ // reassign the child to the validator for the
+ // AssignPropertiesCommand
+ clayContext.setChild(validator);
+
+ return isFinal;
+ }
+
+}
Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateValueChangeListenerCommand.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateValueChangeListenerCommand.java?rev=178848&r1=178847&r2=178848&view=diff
==============================================================================
--- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateValueChangeListenerCommand.java (original)
+++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateValueChangeListenerCommand.java Fri May 27 18:09:07 2005
@@ -1,107 +1,107 @@
-/*
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Id$
- */
-
-package org.apache.shale.clay.component.chain;
-
-import javax.faces.component.EditableValueHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.event.ValueChangeListener;
-
-import org.apache.commons.chain.Context;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.shale.clay.config.beans.ComponentBean;
-
-/**
- * <p>
- * Creates a {@link ValueChangeListener} and assign it to the
- * <code>parent</code> property in the {@link ClayContext}.
- */
-public class CreateValueChangeListenerCommand extends AbstractCommand {
-
- /**
- * <p>
- * Common Logging utility
- * </p>
- */
- private static Log log;
- static {
- log = LogFactory.getLog(CreateValueChangeListenerCommand.class);
- }
-
- /**
- * <p>
- * Creates a <code>ValueChangeListener</code> and assigns it to the
- * <code>parent</code> attribute
- * </p>
- */
- public boolean execute(Context context) throws Exception {
-
- boolean isFinal = false;
-
- ClayContext clayContext = (ClayContext) context;
- if (clayContext == null)
- throw new NullPointerException(messages
- .getMessage("clay.null.clayContext"));
-
- UIComponent child = (UIComponent) clayContext.getChild();
- if (child == null)
- throw new NullPointerException(messages
- .getMessage("clay.null.childComponent"));
-
- ComponentBean displayElement = clayContext.getDisplayElement();
- if (displayElement == null)
- throw new NullPointerException(messages
- .getMessage("clay.null.componentBean"));
-
- EditableValueHolder parent = (EditableValueHolder) clayContext
- .getParent();
- if (parent == null)
- throw new NullPointerException(messages
- .getMessage("clay.null.parentComponent"));
-
- FacesContext facesContext = clayContext.getFacesContext();
- if (facesContext == null)
- throw new NullPointerException(messages
- .getMessage("clay.null.facesContext"));
-
- ValueChangeListener listener = null;
- try {
-
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- if (loader == null)
- loader = getClass().getClassLoader();
-
- listener = (ValueChangeListener) loader.loadClass(
- displayElement.getComponentType()).newInstance();
-
- loader = null;
- } catch (Exception e) {
- log.error(messages.getMessage("create.valueChangeListener"), e);
- throw e;
- }
- parent.addValueChangeListener(listener);
- // reassign the child to the valueChangeListener for the
- // AssignPropertiesCommand
- clayContext.setChild(listener);
-
- return isFinal;
- }
-
-}
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id$
+ */
+
+package org.apache.shale.clay.component.chain;
+
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ValueChangeListener;
+
+import org.apache.commons.chain.Context;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.shale.clay.config.beans.ComponentBean;
+
+/**
+ * <p>
+ * Creates a {@link ValueChangeListener} and assign it to the
+ * <code>parent</code> property in the {@link ClayContext}.
+ */
+public class CreateValueChangeListenerCommand extends AbstractCommand {
+
+ /**
+ * <p>
+ * Common Logging utility
+ * </p>
+ */
+ private static Log log;
+ static {
+ log = LogFactory.getLog(CreateValueChangeListenerCommand.class);
+ }
+
+ /**
+ * <p>
+ * Creates a <code>ValueChangeListener</code> and assigns it to the
+ * <code>parent</code> attribute
+ * </p>
+ */
+ public boolean execute(Context context) throws Exception {
+
+ boolean isFinal = false;
+
+ ClayContext clayContext = (ClayContext) context;
+ if (clayContext == null)
+ throw new NullPointerException(messages
+ .getMessage("clay.null.clayContext"));
+
+ UIComponent child = (UIComponent) clayContext.getChild();
+ if (child == null)
+ throw new NullPointerException(messages
+ .getMessage("clay.null.childComponent"));
+
+ ComponentBean displayElement = clayContext.getDisplayElement();
+ if (displayElement == null)
+ throw new NullPointerException(messages
+ .getMessage("clay.null.componentBean"));
+
+ EditableValueHolder parent = (EditableValueHolder) clayContext
+ .getParent();
+ if (parent == null)
+ throw new NullPointerException(messages
+ .getMessage("clay.null.parentComponent"));
+
+ FacesContext facesContext = clayContext.getFacesContext();
+ if (facesContext == null)
+ throw new NullPointerException(messages
+ .getMessage("clay.null.facesContext"));
+
+ ValueChangeListener listener = null;
+ try {
+
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if (loader == null)
+ loader = getClass().getClassLoader();
+
+ listener = (ValueChangeListener) loader.loadClass(
+ displayElement.getComponentType()).newInstance();
+
+ loader = null;
+ } catch (Exception e) {
+ log.error(messages.getMessage("create.valueChangeListener"), e);
+ throw e;
+ }
+ parent.addValueChangeListener(listener);
+ // reassign the child to the valueChangeListener for the
+ // AssignPropertiesCommand
+ clayContext.setChild(listener);
+
+ return isFinal;
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org