You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ja...@apache.org on 2010/03/13 12:55:01 UTC
svn commit: r922543 - in
/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces: taglib/core/
view/facelets/tag/jsf/core/
Author: jakobk
Date: Sat Mar 13 11:55:01 2010
New Revision: 922543
URL: http://svn.apache.org/viewvc?rev=922543&view=rev
Log:
MYFACES-2536 converterId and validatorId should not be required (Thanks to Martin Koci for the patch, however applied with some alterations)
Modified:
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/taglib/core/ConverterTag.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/taglib/core/DelegateConverter.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ConvertDelegateHandler.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ValidateDelegateHandler.java
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/taglib/core/ConverterTag.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/taglib/core/ConverterTag.java?rev=922543&r1=922542&r2=922543&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/taglib/core/ConverterTag.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/taglib/core/ConverterTag.java Sat Mar 13 11:55:01 2010
@@ -126,6 +126,12 @@ public class ConverterTag extends Conver
throw new JspException("Exception creating converter with converterId: " + _converterId, e);
}
}
+
+ if (converter == null)
+ {
+ throw new JspException("Could not create converter. Please specify a valid converterId" +
+ " or a non-null binding.");
+ }
return converter;
}
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/taglib/core/DelegateConverter.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/taglib/core/DelegateConverter.java?rev=922543&r1=922542&r2=922543&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/taglib/core/DelegateConverter.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/taglib/core/DelegateConverter.java Sat Mar 13 11:55:01 2010
@@ -157,6 +157,12 @@ public class DelegateConverter implement
throw new ConverterException("Exception creating converter with converterId: " + _converterId, e);
}
}
+
+ if (converter == null)
+ {
+ throw new IllegalStateException("Could not create converter. Please specify a valid converterId" +
+ " or a non-null binding.");
+ }
return converter;
}
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ConvertDelegateHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ConvertDelegateHandler.java?rev=922543&r1=922542&r2=922543&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ConvertDelegateHandler.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ConvertDelegateHandler.java Sat Mar 13 11:55:01 2010
@@ -1,80 +1,84 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.view.facelets.tag.jsf.core;
-
-import javax.el.ELException;
-import javax.faces.FacesException;
-import javax.faces.convert.Converter;
-import javax.faces.view.facelets.ConverterConfig;
-import javax.faces.view.facelets.ConverterHandler;
-import javax.faces.view.facelets.FaceletContext;
-import javax.faces.view.facelets.FaceletException;
-import javax.faces.view.facelets.MetaRuleset;
-import javax.faces.view.facelets.TagAttribute;
-
-import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag;
-
-/**
- * Register a named Converter instance on the UIComponent associated with the closest parent UIComponent custom action.
- * <p/> See <a target="_new" href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/tlddocs/f/converter.html">tag
- * documentation</a>.
- *
- * @author Jacob Hookom
- * @version $Id: ConvertDelegateHandler.java,v 1.4 2008/07/13 19:01:44 rlubke Exp $
- */
-@JSFFaceletTag(
- name = "f:converter",
- bodyContent = "empty",
- tagClass="org.apache.myfaces.taglib.core.ConverterImplTag")
-public final class ConvertDelegateHandler extends ConverterHandler
-{
-
- private final TagAttribute converterId;
-
- /**
- * @param config
- */
- public ConvertDelegateHandler(ConverterConfig config)
- {
- super(config);
- this.converterId = this.getRequiredAttribute("converterId");
- }
-
- /**
- * Uses the specified "converterId" to pull an instance from the Application
- *
- * @see javax.faces.application.Application#createComponent(java.lang.String)
- * @see org.apache.myfaces.view.facelets.tag.jsf.ConverterHandler#createConverter(javax.faces.view.facelets.FaceletContext)
- */
- protected Converter createConverter(FaceletContext ctx) throws FacesException, ELException, FaceletException
- {
- return ctx.getFacesContext().getApplication().createConverter(this.converterId.getValue(ctx));
- }
-
- protected MetaRuleset createMetaRuleset(Class type)
- {
- return super.createMetaRuleset(type).ignoreAll();
- }
-
- @Override
- public String getConverterId(FaceletContext ctx)
- {
- return converterId.getValue(ctx);
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.view.facelets.tag.jsf.core;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.convert.Converter;
+import javax.faces.view.facelets.ConverterConfig;
+import javax.faces.view.facelets.ConverterHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.TagAttribute;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag;
+
+/**
+ * Register a named Converter instance on the UIComponent associated with the closest parent UIComponent custom action.
+ * <p/> See <a target="_new" href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/tlddocs/f/converter.html">tag
+ * documentation</a>.
+ *
+ * @author Jacob Hookom
+ * @version $Id: ConvertDelegateHandler.java,v 1.4 2008/07/13 19:01:44 rlubke Exp $
+ */
+@JSFFaceletTag(
+ name = "f:converter",
+ bodyContent = "empty",
+ tagClass="org.apache.myfaces.taglib.core.ConverterImplTag")
+public final class ConvertDelegateHandler extends ConverterHandler
+{
+
+ private final TagAttribute converterId;
+
+ /**
+ * @param config
+ */
+ public ConvertDelegateHandler(ConverterConfig config)
+ {
+ super(config);
+ this.converterId = this.getAttribute("converterId");
+ }
+
+ /**
+ * Uses the specified "converterId" to pull an instance from the Application
+ *
+ * @see javax.faces.application.Application#createComponent(java.lang.String)
+ * @see org.apache.myfaces.view.facelets.tag.jsf.ConverterHandler#createConverter(javax.faces.view.facelets.FaceletContext)
+ */
+ protected Converter createConverter(FaceletContext ctx) throws FacesException, ELException, FaceletException
+ {
+ return ctx.getFacesContext().getApplication().createConverter(this.getConverterId(ctx));
+ }
+
+ protected MetaRuleset createMetaRuleset(Class type)
+ {
+ return super.createMetaRuleset(type).ignoreAll();
+ }
+
+ @Override
+ public String getConverterId(FaceletContext ctx)
+ {
+ if (converterId == null)
+ {
+ return null;
+ }
+ return converterId.getValue(ctx);
+ }
+}
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ValidateDelegateHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ValidateDelegateHandler.java?rev=922543&r1=922542&r2=922543&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ValidateDelegateHandler.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ValidateDelegateHandler.java Sat Mar 13 11:55:01 2010
@@ -1,76 +1,80 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.view.facelets.tag.jsf.core;
-
-import javax.faces.validator.Validator;
-import javax.faces.view.facelets.FaceletContext;
-import javax.faces.view.facelets.MetaRuleset;
-import javax.faces.view.facelets.TagAttribute;
-import javax.faces.view.facelets.ValidatorConfig;
-import javax.faces.view.facelets.ValidatorHandler;
-
-import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag;
-
-
-/**
- * Register a named Validator instance on the UIComponent associated with the closest parent UIComponent custom
- * action.<p/> See <a target="_new"
- * href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/tlddocs/f/validator.html">tag documentation</a>.
- *
- * @author Jacob Hookom
- * @version $Id: ValidateDelegateHandler.java,v 1.4 2008/07/13 19:01:44 rlubke Exp $
- */
-@JSFFaceletTag(
- name = "f:validator",
- bodyContent = "empty",
- tagClass="org.apache.myfaces.taglib.core.ValidatorImplTag")
-public final class ValidateDelegateHandler extends ValidatorHandler
-{
-
- private final TagAttribute validatorId;
-
- public ValidateDelegateHandler(ValidatorConfig config)
- {
- super(config);
- this.validatorId = this.getRequiredAttribute("validatorId");
- }
-
- /**
- * Uses the specified "validatorId" to get a new Validator instance from the Application.
- *
- * @see javax.faces.application.Application#createValidator(java.lang.String)
- * @see javax.faces.view.facelets.ValidatorHandler#createValidator(javax.faces.view.facelets.FaceletContext)
- */
- protected Validator createValidator(FaceletContext ctx)
- {
- return ctx.getFacesContext().getApplication().createValidator(this.validatorId.getValue(ctx));
- }
-
- protected MetaRuleset createMetaRuleset(Class type)
- {
- return super.createMetaRuleset(type).ignoreAll();
- }
-
- @Override
- public String getValidatorId(FaceletContext ctx)
- {
- return validatorId.getValue(ctx);
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.view.facelets.tag.jsf.core;
+
+import javax.faces.validator.Validator;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.ValidatorConfig;
+import javax.faces.view.facelets.ValidatorHandler;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag;
+
+
+/**
+ * Register a named Validator instance on the UIComponent associated with the closest parent UIComponent custom
+ * action.<p/> See <a target="_new"
+ * href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/tlddocs/f/validator.html">tag documentation</a>.
+ *
+ * @author Jacob Hookom
+ * @version $Id: ValidateDelegateHandler.java,v 1.4 2008/07/13 19:01:44 rlubke Exp $
+ */
+@JSFFaceletTag(
+ name = "f:validator",
+ bodyContent = "empty",
+ tagClass="org.apache.myfaces.taglib.core.ValidatorImplTag")
+public final class ValidateDelegateHandler extends ValidatorHandler
+{
+
+ private final TagAttribute validatorId;
+
+ public ValidateDelegateHandler(ValidatorConfig config)
+ {
+ super(config);
+ this.validatorId = this.getAttribute("validatorId");
+ }
+
+ /**
+ * Uses the specified "validatorId" to get a new Validator instance from the Application.
+ *
+ * @see javax.faces.application.Application#createValidator(java.lang.String)
+ * @see javax.faces.view.facelets.ValidatorHandler#createValidator(javax.faces.view.facelets.FaceletContext)
+ */
+ protected Validator createValidator(FaceletContext ctx)
+ {
+ return ctx.getFacesContext().getApplication().createValidator(this.getValidatorId(ctx));
+ }
+
+ protected MetaRuleset createMetaRuleset(Class type)
+ {
+ return super.createMetaRuleset(type).ignoreAll();
+ }
+
+ @Override
+ public String getValidatorId(FaceletContext ctx)
+ {
+ if (validatorId == null)
+ {
+ return null;
+ }
+ return validatorId.getValue(ctx);
+ }
+
+}