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/22 23:23:01 UTC
svn commit: r926376 - in /myfaces/core/trunk/api/src:
main/java/javax/faces/component/UIInput.java
test/java/javax/faces/component/UIInputTest.java
test/java/javax/faces/component/UIViewParameterTest.java
Author: jakobk
Date: Mon Mar 22 22:23:00 2010
New Revision: 926376
URL: http://svn.apache.org/viewvc?rev=926376&view=rev
Log:
MYFACES-2619 FacesContext.validationFailed() must be called on validation errors in validate()
Added:
myfaces/core/trunk/api/src/test/java/javax/faces/component/UIViewParameterTest.java (with props)
Modified:
myfaces/core/trunk/api/src/main/java/javax/faces/component/UIInput.java
myfaces/core/trunk/api/src/test/java/javax/faces/component/UIInputTest.java
Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UIInput.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UIInput.java?rev=926376&r1=926375&r2=926376&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UIInput.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UIInput.java Mon Mar 22 22:23:00 2010
@@ -204,6 +204,7 @@ public class UIInput extends UIOutput im
}
if (!isValid())
{
+ context.validationFailed();
context.renderResponse();
}
}
Modified: myfaces/core/trunk/api/src/test/java/javax/faces/component/UIInputTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/test/java/javax/faces/component/UIInputTest.java?rev=926376&r1=926375&r2=926376&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/test/java/javax/faces/component/UIInputTest.java (original)
+++ myfaces/core/trunk/api/src/test/java/javax/faces/component/UIInputTest.java Mon Mar 22 22:23:00 2010
@@ -36,6 +36,7 @@ import javax.faces.convert.ConverterExce
import javax.faces.el.MethodBinding;
import javax.faces.event.PhaseId;
import javax.faces.event.ValueChangeEvent;
+import javax.faces.validator.LengthValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
import javax.servlet.ServletContext;
@@ -276,6 +277,23 @@ public class UIInputTest extends Abstrac
facesContext.setExternalContext(externalContext);
}
}
+
+ /**
+ * Tests if UIInput.processValidators() correctly calls FacesContext.validationFailed()
+ * if a validation error occurs.
+ */
+ public void testValidationErrorTriggersFacesContextValidationFailed()
+ {
+ LengthValidator validator = new LengthValidator();
+ validator.setMinimum(5);
+ input.addValidator(validator);
+
+ input.setSubmittedValue("123");
+
+ assertFalse(facesContext.isValidationFailed());
+ input.processValidators(facesContext);
+ assertTrue(facesContext.isValidationFailed());
+ }
static public class InitParameterMockExternalContext extends org.apache.myfaces.test.mock.MockExternalContext {
Added: myfaces/core/trunk/api/src/test/java/javax/faces/component/UIViewParameterTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/test/java/javax/faces/component/UIViewParameterTest.java?rev=926376&view=auto
==============================================================================
--- myfaces/core/trunk/api/src/test/java/javax/faces/component/UIViewParameterTest.java (added)
+++ myfaces/core/trunk/api/src/test/java/javax/faces/component/UIViewParameterTest.java Mon Mar 22 22:23:00 2010
@@ -0,0 +1,73 @@
+/*
+ * 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 javax.faces.component;
+
+import org.apache.myfaces.test.base.AbstractJsfTestCase;
+
+/**
+ * Test class for UIViewParameter.
+ *
+ * @author Jakob Korherr (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ *
+ * @since 2.0
+ */
+public class UIViewParameterTest extends AbstractJsfTestCase
+{
+
+ private UIViewParameter viewParameter = null;
+
+ public UIViewParameterTest(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ viewParameter = new UIViewParameter();
+ viewParameter.setName("param");
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ viewParameter = null;
+
+ super.tearDown();
+ }
+
+ /**
+ * Tests if UIViewParameter.processValidators() correctly calls FacesContext.validationFailed()
+ * if the submitted value is null, but required is set to true.
+ * This is a special validation case only for UIViewParameter, so this has to be tested here.
+ */
+ public void testValidationErrorTriggersFacesContextValidationFailed()
+ {
+ viewParameter.setRequired(true);
+ viewParameter.setSubmittedValue(null);
+
+ assertFalse(facesContext.isValidationFailed());
+ viewParameter.processValidators(facesContext);
+ assertTrue(facesContext.isValidationFailed());
+ }
+
+}
Propchange: myfaces/core/trunk/api/src/test/java/javax/faces/component/UIViewParameterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/trunk/api/src/test/java/javax/faces/component/UIViewParameterTest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/core/trunk/api/src/test/java/javax/faces/component/UIViewParameterTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain