You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2016/03/04 03:21:42 UTC
svn commit: r1733543 - in /myfaces/core/trunk:
api/src/main/java/javax/faces/component/ impl/
impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/
impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/core/validation/
impl/src/test/resour...
Author: lu4242
Date: Fri Mar 4 02:21:42 2016
New Revision: 1733543
URL: http://svn.apache.org/viewvc?rev=1733543&view=rev
Log:
MYFACES-3892 Create a option to execute BeanValidation before JSF-Validation (org.apache.myfaces.validator.BEAN_BEFORE_JSF_VALIDATION)
Added:
myfaces/core/trunk/api/src/main/java/javax/faces/component/_BeanValidationUtils.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/core/validation/
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/core/validation/BeanValidationCDIRequestTestCase.java
- copied, changed from r1730129, myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/flow/FlowMyFacesCDIRequestTestCase.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/core/validation/CustomerBean.java
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/core/validation/
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/core/validation/testBeanValidation_1.xhtml
- copied, changed from r1730129, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/core/reset/resetValuesActionListener_2.xhtml
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/core/validation/testBeanValidation_2.xhtml
- copied, changed from r1730129, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/core/reset/resetValuesActionListener_2.xhtml
Modified:
myfaces/core/trunk/api/src/main/java/javax/faces/component/UIInput.java
myfaces/core/trunk/impl/pom.xml
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ValidatorTagHandlerDelegate.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=1733543&r1=1733542&r2=1733543&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 Fri Mar 4 02:21:42 2016
@@ -95,6 +95,8 @@ public class UIInput extends UIOutput im
* ATTENTION: this constant is duplicate in org.apache.myfaces.renderkit.ErrorPageWriter
*/
private static final String DEBUG_INFO_KEY = "org.apache.myfaces.debug.DEBUG_INFO";
+
+ private final static String BEAN_BEFORE_JSF_PROPERTY = "oam.beanBeforeJsf";
private static final Validator[] EMPTY_VALIDATOR_ARRAY = new Validator[0];
@@ -824,8 +826,46 @@ public class UIInput extends UIOutput im
/** See getValidator. */
public Validator[] getValidators()
{
- return _validatorList == null ? EMPTY_VALIDATOR_ARRAY
- : _validatorList.toArray(new Validator[_validatorList.size()]);
+ if (_ExternalSpecifications.isBeanValidationAvailable() &&
+ Boolean.TRUE.equals(this.getAttributes().containsKey(BEAN_BEFORE_JSF_PROPERTY)))
+ {
+ int bvIndex = -1;
+ for (int i = 0; i < _validatorList.size(); i++)
+ {
+ Validator v = _validatorList.get(i);
+ if (_BeanValidationUtils.isBeanValidator(v))
+ {
+ bvIndex = i;
+ break;
+ }
+ }
+ if (bvIndex != -1)
+ {
+ Validator[] array = new Validator[_validatorList.size()];
+ for (int i = 0; i < _validatorList.size(); i++)
+ {
+ if (i == bvIndex)
+ {
+ array[0] = _validatorList.get(i);
+ }
+ else
+ {
+ array[i+1] = _validatorList.get(i);
+ }
+ }
+ return array;
+ }
+ else
+ {
+ return _validatorList == null ? EMPTY_VALIDATOR_ARRAY
+ : _validatorList.toArray(new Validator[_validatorList.size()]);
+ }
+ }
+ else
+ {
+ return _validatorList == null ? EMPTY_VALIDATOR_ARRAY
+ : _validatorList.toArray(new Validator[_validatorList.size()]);
+ }
}
/**
Added: myfaces/core/trunk/api/src/main/java/javax/faces/component/_BeanValidationUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/_BeanValidationUtils.java?rev=1733543&view=auto
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/_BeanValidationUtils.java (added)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/_BeanValidationUtils.java Fri Mar 4 02:21:42 2016
@@ -0,0 +1,35 @@
+/*
+ * 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 javax.faces.validator.BeanValidator;
+import javax.faces.validator.Validator;
+
+/**
+ *
+ * @author lu4242
+ */
+final class _BeanValidationUtils
+{
+
+ public static boolean isBeanValidator(Validator v)
+ {
+ return v instanceof BeanValidator;
+ }
+}
Modified: myfaces/core/trunk/impl/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/pom.xml?rev=1733543&r1=1733542&r2=1733543&view=diff
==============================================================================
--- myfaces/core/trunk/impl/pom.xml (original)
+++ myfaces/core/trunk/impl/pom.xml Fri Mar 4 02:21:42 2016
@@ -1368,6 +1368,14 @@
<version>${openwebbeans.version}</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.bval</groupId>
+ <artifactId>bval-jsr303</artifactId>
+ <version>0.5</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ValidatorTagHandlerDelegate.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ValidatorTagHandlerDelegate.java?rev=1733543&r1=1733542&r2=1733543&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ValidatorTagHandlerDelegate.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ValidatorTagHandlerDelegate.java Fri Mar 4 02:21:42 2016
@@ -36,8 +36,10 @@ import javax.faces.view.facelets.TagAttr
import javax.faces.view.facelets.TagException;
import javax.faces.view.facelets.TagHandlerDelegate;
import javax.faces.view.facelets.ValidatorHandler;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFWebConfigParam;
import org.apache.myfaces.shared.renderkit.JSFAttr;
+import org.apache.myfaces.shared.util.WebConfigParamUtils;
import org.apache.myfaces.view.facelets.FaceletCompositionContext;
import org.apache.myfaces.view.facelets.compiler.FaceletsCompilerUtils;
import org.apache.myfaces.view.facelets.tag.MetaRulesetImpl;
@@ -65,6 +67,15 @@ public class ValidatorTagHandlerDelegate
public final static String VALIDATOR_ID_EXCLUSION_LIST_KEY
= "org.apache.myfaces.validator.VALIDATOR_ID_EXCLUSION_LIST";
+ /**
+ * Enforce <f:validateBean> to be called first before any JSF validator.
+ */
+ @JSFWebConfigParam(defaultValue="false", expectedValues="true, false", since = "2.2.10", group="validation")
+ private final static String BEAN_BEFORE_JSF_VALIDATION
+ = "org.apache.myfaces.validator.BEAN_BEFORE_JSF_VALIDATION";
+
+ private final static String BEAN_BEFORE_JSF_PROPERTY = "oam.beanBeforeJsf";
+
private ValidatorHandler _delegate;
/**
@@ -73,6 +84,8 @@ public class ValidatorTagHandlerDelegate
*/
private final boolean _wrapMode;
+ private Boolean _beanBeforeJsfValidation;
+
public ValidatorTagHandlerDelegate(ValidatorHandler delegate)
{
_delegate = delegate;
@@ -84,6 +97,7 @@ public class ValidatorTagHandlerDelegate
// (this behavior is analog to <f:ajax>)
// --> Determine if we have children:
_wrapMode = FaceletsCompilerUtils.hasChildren(_delegate.getValidatorConfig());
+ _beanBeforeJsfValidation = null;
}
@Override
@@ -277,9 +291,24 @@ public class ValidatorTagHandlerDelegate
throw new TagException(_delegate.getTag(), "No Validator was created");
}
_delegate.setAttributes(faceletContext, v);
+ if (shouldBeanBeforeJsfValidationEnabled(context))
+ {
+ parent.getAttributes().put(BEAN_BEFORE_JSF_PROPERTY, Boolean.TRUE);
+ }
evh.addValidator(v);
}
}
+
+ private boolean shouldBeanBeforeJsfValidationEnabled(FacesContext context)
+ {
+ if (_beanBeforeJsfValidation == null)
+ {
+ _beanBeforeJsfValidation = WebConfigParamUtils.getBooleanInitParameter(context.getExternalContext(),
+ BEAN_BEFORE_JSF_VALIDATION, false);
+ }
+ return _beanBeforeJsfValidation;
+ }
+
public String getFor()
{
Copied: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/core/validation/BeanValidationCDIRequestTestCase.java (from r1730129, myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/flow/FlowMyFacesCDIRequestTestCase.java)
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/core/validation/BeanValidationCDIRequestTestCase.java?p2=myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/core/validation/BeanValidationCDIRequestTestCase.java&p1=myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/flow/FlowMyFacesCDIRequestTestCase.java&r1=1730129&r2=1733543&rev=1733543&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/flow/FlowMyFacesCDIRequestTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/core/validation/BeanValidationCDIRequestTestCase.java Fri Mar 4 02:21:42 2016
@@ -16,14 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.myfaces.application.flow;
+package org.apache.myfaces.view.facelets.tag.jsf.core.validation;
-import javax.enterprise.context.ContextNotActiveException;
-import javax.faces.application.ConfigurableNavigationHandler;
-import javax.faces.application.NavigationCase;
import javax.faces.application.StateManager;
-import javax.faces.component.UICommand;
-import javax.faces.flow.Flow;
+import javax.faces.component.UIInput;
+import javax.faces.validator.BeanValidator;
+import javax.faces.validator.Validator;
import org.apache.myfaces.mc.test.core.AbstractMyFacesCDIRequestTestCase;
import org.apache.myfaces.shared.config.MyfacesConfig;
import org.junit.Assert;
@@ -33,7 +31,7 @@ import org.junit.Test;
* This test is the same as FlowMyFacesRequestTestCase with the diference that
* in this case CDI is enabled and the other alternative is used.
*/
-public class FlowMyFacesCDIRequestTestCase extends AbstractMyFacesCDIRequestTestCase
+public class BeanValidationCDIRequestTestCase extends AbstractMyFacesCDIRequestTestCase
{
@Override
@@ -46,206 +44,50 @@ public class FlowMyFacesCDIRequestTestCa
protected void setUpWebConfigParams() throws Exception
{
super.setUpWebConfigParams();
- servletContext.addInitParameter("org.apache.myfaces.annotation.SCAN_PACKAGES","org.apache.myfaces.application.flow");
+ servletContext.addInitParameter("org.apache.myfaces.annotation.SCAN_PACKAGES",
+ "org.apache.myfaces.view.facelets.tag.jsf.core.validation");
servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME, StateManager.STATE_SAVING_METHOD_CLIENT);
servletContext.addInitParameter("javax.faces.PARTIAL_STATE_SAVING", "true");
servletContext.addInitParameter(MyfacesConfig.INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS, "auto");
- servletContext.addInitParameter("javax.faces.CONFIG_FILES", "/WEB-INF/flow1-flow.xml");
servletContext.addInitParameter("javax.faces.CLIENT_WINDOW_MODE", "url");
+ servletContext.addInitParameter("org.apache.myfaces.validator.BEAN_BEFORE_JSF_VALIDATION", "true");
}
@Test
- public void testFlow1_1() throws Exception
+ public void testBeanValidation_1() throws Exception
{
- startViewRequest("/flow1_1.xhtml");
- processLifecycleExecute();
-
- ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) facesContext.getApplication().getNavigationHandler();
-
- NavigationCase navCase = handler.getNavigationCase(facesContext, null, "flow1");
-
- Assert.assertNotNull(navCase);
-
- NavigationCase contentCase = handler.getNavigationCase(facesContext, null, "flow1_content");
-
- Assert.assertNull(contentCase);
-
- // Check begin view node
- Assert.assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext));
-
- renderResponse();
-
- //Enter flow 1
- UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow1");
- client.submit(button);
+ startViewRequest("/testBeanValidation_1.xhtml");
processLifecycleExecute();
+ processLifecycleRender();
+ client.inputText("mainForm:username", "someusr");
- Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
- Assert.assertNotNull(currentFlow);
-
- // Check Flow1Bean can be created
- Flow1Bean bean1 = facesContext.getApplication().evaluateExpressionGet(
- facesContext, "#{flow1Bean}", Flow1Bean.class);
- Assert.assertNotNull(bean1);
- Assert.assertEquals(bean1.getPostConstructCalled(), "true");
+ client.submit("mainForm:submit");
- contentCase = handler.getNavigationCase(facesContext, null, "flow1_content");
+ processLifecycleExecute();
- Assert.assertNotNull(contentCase);
+ UIInput username = (UIInput) facesContext.getViewRoot().findComponent("mainForm:username");
+ Assert.assertNotNull(username);
+ Validator[] array = username.getValidators();
+ Assert.assertTrue(array[0] instanceof BeanValidator);
}
@Test
- public void testFlow1_2() throws Exception
+ public void testBeanValidation_2() throws Exception
{
- startViewRequest("/flow1_2.xhtml");
- processLifecycleExecute();
-
- ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) facesContext.getApplication().getNavigationHandler();
-
- NavigationCase navCase = handler.getNavigationCase(facesContext, null, "flow1");
-
- Assert.assertNotNull(navCase);
-
- NavigationCase contentCase = handler.getNavigationCase(facesContext, null, "flow1_content");
-
- Assert.assertNull(contentCase);
-
- // Check begin view node
- Assert.assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext));
-
- renderResponse();
-
- //Enter flow 1
- UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow1");
- client.submit(button);
+ startViewRequest("/testBeanValidation_2.xhtml");
processLifecycleExecute();
+ processLifecycleRender();
+ client.inputText("mainForm:username", "someusr");
- Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
- Assert.assertNotNull(currentFlow);
- Assert.assertEquals("flow1", currentFlow.getId());
-
- facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow1","value1");
-
- // Check the bean with @FlowScoped annotation can be instantiated
- Flow1Bean bean1 = facesContext.getApplication().evaluateExpressionGet(
- facesContext, "#{flow1Bean}", Flow1Bean.class);
- Assert.assertNotNull(bean1);
- Assert.assertEquals(bean1.getPostConstructCalled(), "true");
- bean1.setName("John");
-
- renderResponse();
-
- UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow2");
- client.submit(button2);
+ client.submit("mainForm:submit");
processLifecycleExecute();
- currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
- Assert.assertNotNull(currentFlow);
- Assert.assertEquals("flow2", currentFlow.getId());
- Assert.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1"));
- facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow2","value2");
-
- Flow2Bean bean2 = facesContext.getApplication().evaluateExpressionGet(
- facesContext, "#{flow2Bean}", Flow2Bean.class);
- Assert.assertNotNull(bean2);
- Assert.assertEquals(bean2.getPostConstructCalled(), "true");
-
- Flow1Bean bean1_1 = facesContext.getApplication().evaluateExpressionGet(
- facesContext, "#{flow1Bean}", Flow1Bean.class);
- Assert.assertEquals(bean1_1.getName(), "John");
-
- Flow21Bean bean2_1 = facesContext.getApplication().evaluateExpressionGet(
- facesContext, "#{flow21Bean}", Flow21Bean.class);
- Assert.assertNotNull(bean2_1);
- Assert.assertEquals(bean2_1.getPostConstructCalled(), "true");
- Assert.assertNotNull(bean2_1.getFlow1Bean());
-
- renderResponse();
-
- //Check current view is the begin of flow2
- Assert.assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId());
-
- UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:content");
- client.submit(button3);
- processLifecycleExecute();
- renderResponse();
-
- currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
- Assert.assertNotNull(currentFlow);
- Assert.assertEquals("flow2", currentFlow.getId());
-
- NavigationCase endCase = handler.getNavigationCase(facesContext, null, "end");
- Assert.assertNotNull(endCase);
-
- UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:end_flow");
- client.submit(button4);
-
- processLifecycleExecute();
-
- // The interesting thing here is that it requires to get out from two consecutive flows, and it needs
- // to chain all commands. The difficulty here resides in the context should be resolved properly, and
- // there are a couple of recursive calls that needs to be solved.
- currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
- Assert.assertNull(currentFlow);
- Assert.assertEquals("/flow1_end.xhtml", facesContext.getViewRoot().getViewId());
-
- try
- {
- Flow1Bean bean1_2 = facesContext.getApplication().evaluateExpressionGet(
- facesContext, "#{flow1Bean}", Flow1Bean.class);
- bean1_2.getName();
- Assert.fail("Invocation show throw NullPointerException or ContextNotActiveException");
- }
- catch (ContextNotActiveException e)
- {
- }
- catch (NullPointerException e)
- {
- }
+ UIInput username = (UIInput) facesContext.getViewRoot().findComponent("mainForm:username");
+ Assert.assertNotNull(username);
+ Validator[] array = username.getValidators();
+ Assert.assertTrue(array[0] instanceof BeanValidator);
}
-
- /**
- * Check outbound parameter is initialized before call initializer method
- *
- * @throws Exception
- */
- @Test
- public void testFlow1_12() throws Exception
- {
- startViewRequest("/flow_base.xhtml");
- processLifecycleExecute();
-
- ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) facesContext.getApplication().getNavigationHandler();
-
- renderResponse();
-
- //Enter flow 1
- UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow4");
- client.submit(button);
-
- processLifecycleExecute();
-
- Assert.assertEquals("/flow4/flow4.xhtml", facesContext.getViewRoot().getViewId());
-
- Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
- Assert.assertNotNull(currentFlow);
- Assert.assertEquals(currentFlow.getId(), "flow4");
-
- renderResponse();
-
- NavigationCase goFlowBase = handler.getNavigationCase(facesContext, null, "call_flow5_4");
- Assert.assertNotNull(goFlowBase);
-
- UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow5");
- client.submit(button2);
-
- processLifecycleExecute();
-
- Assert.assertEquals("/flow5/flow5.xhtml", facesContext.getViewRoot().getViewId());
-
- renderResponse();
- }
}
Added: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/core/validation/CustomerBean.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/core/validation/CustomerBean.java?rev=1733543&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/core/validation/CustomerBean.java (added)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/core/validation/CustomerBean.java Fri Mar 4 02:21:42 2016
@@ -0,0 +1,54 @@
+/*
+ * 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.validation;
+
+import javax.enterprise.context.RequestScoped;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+/**
+ *
+ * @author lu4242
+ */
+@RequestScoped
+public class CustomerBean
+{
+
+ @NotNull
+ @Size(min=6,max=10)
+ private String username;
+
+ /**
+ * @return the username
+ */
+ public String getUsername()
+ {
+ return username;
+ }
+
+ /**
+ * @param username the username to set
+ */
+ public void setUsername(String username)
+ {
+ this.username = username;
+ }
+
+}
Copied: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/core/validation/testBeanValidation_1.xhtml (from r1730129, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/core/reset/resetValuesActionListener_2.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/core/validation/testBeanValidation_1.xhtml?p2=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/core/validation/testBeanValidation_1.xhtml&p1=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/core/reset/resetValuesActionListener_2.xhtml&r1=1730129&r2=1733543&rev=1733543&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/core/reset/resetValuesActionListener_2.xhtml (original)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/core/validation/testBeanValidation_1.xhtml Fri Mar 4 02:21:42 2016
@@ -18,12 +18,10 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:form id="mainForm">
- <h:inputText id="field1" value="#{bean.field1}">
- <f:validateLength minimum="4"/>
+ <h:inputText id="username" value="#{customerBean.username}">
+ <f:validateRegex pattern="[A-Z]" />
+ <f:validateBean />
</h:inputText>
- <h:inputText id="field2" value="#{bean.field2}"/>
- <h:commandButton id="submit" value="Submit">
- <f:ajax resetValues="true" render="field1 mainForm:field2"/>
- </h:commandButton>
+ <h:commandButton id="submit" value="Submit"/>
</h:form>
</ui:composition>
\ No newline at end of file
Copied: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/core/validation/testBeanValidation_2.xhtml (from r1730129, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/core/reset/resetValuesActionListener_2.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/core/validation/testBeanValidation_2.xhtml?p2=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/core/validation/testBeanValidation_2.xhtml&p1=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/core/reset/resetValuesActionListener_2.xhtml&r1=1730129&r2=1733543&rev=1733543&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/core/reset/resetValuesActionListener_2.xhtml (original)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/core/validation/testBeanValidation_2.xhtml Fri Mar 4 02:21:42 2016
@@ -18,12 +18,11 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:form id="mainForm">
- <h:inputText id="field1" value="#{bean.field1}">
- <f:validateLength minimum="4"/>
- </h:inputText>
- <h:inputText id="field2" value="#{bean.field2}"/>
- <h:commandButton id="submit" value="Submit">
- <f:ajax resetValues="true" render="field1 mainForm:field2"/>
- </h:commandButton>
+ <f:validateBean>
+ <h:inputText id="username" value="#{customerBean.username}">
+ <f:validateRegex pattern="[A-Z]" />
+ </h:inputText>
+ </f:validateBean>
+ <h:commandButton id="submit" value="Submit"/>
</h:form>
</ui:composition>
\ No newline at end of file