You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gp...@apache.org on 2010/05/13 23:54:15 UTC

svn commit: r944024 - in /myfaces/extensions/validator/trunk: test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/ validation-modules/property-validation/src/main/java/org/apache/myfaces/ex...

Author: gpetracek
Date: Thu May 13 21:54:14 2010
New Revision: 944024

URL: http://svn.apache.org/viewvc?rev=944024&view=rev
Log:
EXTVAL-75 thx to Rudy De Busscher

Added:
    myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf1TestBean.java
    myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf1TestCase.java
    myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf2TestBean.java
    myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf2TestCase.java
    myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf3TestBean.java
    myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf3TestCase.java
    myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf4TestBean.java
    myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf4TestCase.java
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/EmptyIf.java
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/EmptyIfStrategy.java

Added: myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf1TestBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf1TestBean.java?rev=944024&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf1TestBean.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf1TestBean.java Thu May 13 21:54:14 2010
@@ -0,0 +1,49 @@
+/*
+ * 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.extensions.validator.test.propval.crossval;
+
+import org.apache.myfaces.extensions.validator.crossval.annotation.EmptyIf;
+
+public class EmptyIf1TestBean
+{
+    private String property1;
+
+    @EmptyIf(valueOf = "property1")
+    private String property2;
+
+    public String getProperty1()
+    {
+        return property1;
+    }
+
+    public void setProperty1(String property1)
+    {
+        this.property1 = property1;
+    }
+
+    public String getProperty2()
+    {
+        return property2;
+    }
+
+    public void setProperty2(String property2)
+    {
+        this.property2 = property2;
+    }
+}
\ No newline at end of file

Added: myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf1TestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf1TestCase.java?rev=944024&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf1TestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf1TestCase.java Thu May 13 21:54:14 2010
@@ -0,0 +1,161 @@
+/*
+ * 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.extensions.validator.test.propval.crossval;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.myfaces.extensions.validator.test.propval.AbstractPropertyValidationTestCase;
+
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.html.HtmlForm;
+import javax.faces.component.html.HtmlInputText;
+import javax.faces.application.FacesMessage;
+
+public class EmptyIf1TestCase extends AbstractPropertyValidationTestCase
+{
+
+    HtmlInputText inputComponent1 = null;
+    HtmlInputText inputComponent2 = null;
+
+    UIViewRoot rootComponent = null;
+
+    public EmptyIf1TestCase(String name)
+    {
+        super(name);
+        inputComponent1 = null;
+        inputComponent2 = null;
+        rootComponent = null;
+    }
+
+    public static Test suite()
+    {
+        return new TestSuite(EmptyIf1TestCase.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        EmptyIf1TestBean bean = new EmptyIf1TestBean();
+        createValueBinding(null, "value", "#{testBean}");
+        facesContext.getExternalContext().getRequestMap().put("testBean", bean);
+
+        rootComponent = new UIViewRoot();
+        HtmlForm form = new HtmlForm();
+        form.setId("form");
+        rootComponent.getChildren().add(form);
+        inputComponent1 = new HtmlInputText();
+        form.getChildren().add(inputComponent1);
+        inputComponent1.setId("input1");
+        inputComponent2 = new HtmlInputText();
+        form.getChildren().add(inputComponent2);
+        inputComponent2.setId("input2");
+    }
+
+    @Override
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+    public void testEmptyIfTargetNotEmptyCorrect() throws Exception
+    {
+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");
+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");
+
+        //decode
+        inputComponent1.setSubmittedValue("1d3");
+        inputComponent2.setSubmittedValue("");
+
+        //validate
+        inputComponent1.validate(facesContext);
+        inputComponent2.validate(facesContext);
+
+        processCrossValidation();
+        checkMessageCount(0);
+
+        assertNavigationBlocked(false);
+        //no update model needed
+    }
+
+    public void testEmptyIfTargetNotEmptyFailed() throws Exception
+    {
+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");
+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");
+
+        //decode
+        inputComponent1.setSubmittedValue("1d3");
+        inputComponent2.setSubmittedValue("1d3");
+
+        //validate
+        inputComponent1.validate(facesContext);
+        inputComponent2.validate(facesContext);
+
+        processCrossValidation();
+        checkMessageCount(1);
+
+        assertNavigationBlocked(true);
+
+        checkMessageSeverities(FacesMessage.SEVERITY_ERROR);
+
+        //no update model needed
+    }
+
+    public void testEmptyIfTargetEmptyCorrect1() throws Exception
+    {
+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");
+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");
+
+        //decode
+        inputComponent1.setSubmittedValue("");
+        inputComponent2.setSubmittedValue("");
+
+        //validate
+        inputComponent1.validate(facesContext);
+        inputComponent2.validate(facesContext);
+
+        processCrossValidation();
+        checkMessageCount(0);
+
+        assertNavigationBlocked(false);
+
+        //no update model needed
+    }
+
+    public void testEmptyIfTargetEmptyCorrect2() throws Exception
+    {
+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");
+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");
+
+        //decode
+        inputComponent1.setSubmittedValue("");
+        inputComponent2.setSubmittedValue("1d3");
+
+        //validate
+        inputComponent1.validate(facesContext);
+        inputComponent2.validate(facesContext);
+
+        processCrossValidation();
+        checkMessageCount(0);
+
+        assertNavigationBlocked(false);
+
+        //no update model needed
+    }
+}
\ No newline at end of file

Added: myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf2TestBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf2TestBean.java?rev=944024&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf2TestBean.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf2TestBean.java Thu May 13 21:54:14 2010
@@ -0,0 +1,49 @@
+/*
+ * 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.extensions.validator.test.propval.crossval;
+
+import org.apache.myfaces.extensions.validator.crossval.annotation.EmptyIf;
+import static org.apache.myfaces.extensions.validator.crossval.annotation.RequiredIfType.*;
+
+public class EmptyIf2TestBean
+{
+    private String property1;
+    @EmptyIf(valueOf = "property1", is = empty)
+    private String property2;
+
+    public String getProperty1()
+    {
+        return property1;
+    }
+
+    public void setProperty1(String property1)
+    {
+        this.property1 = property1;
+    }
+
+    public String getProperty2()
+    {
+        return property2;
+    }
+
+    public void setProperty2(String property2)
+    {
+        this.property2 = property2;
+    }
+}
\ No newline at end of file

Added: myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf2TestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf2TestCase.java?rev=944024&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf2TestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf2TestCase.java Thu May 13 21:54:14 2010
@@ -0,0 +1,162 @@
+/*
+ * 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.extensions.validator.test.propval.crossval;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.myfaces.extensions.validator.test.propval.AbstractPropertyValidationTestCase;
+
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.html.HtmlForm;
+import javax.faces.component.html.HtmlInputText;
+import javax.faces.application.FacesMessage;
+
+public class EmptyIf2TestCase extends AbstractPropertyValidationTestCase
+{
+
+    HtmlInputText inputComponent1 = null;
+    HtmlInputText inputComponent2 = null;
+
+    UIViewRoot rootComponent = null;
+
+    public EmptyIf2TestCase(String name)
+    {
+        super(name);
+        inputComponent1 = null;
+        inputComponent2 = null;
+        rootComponent = null;
+    }
+
+    public static Test suite()
+    {
+        return new TestSuite(EmptyIf2TestCase.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        EmptyIf2TestBean bean = new EmptyIf2TestBean();
+        createValueBinding(null, "value", "#{testBean}");
+        facesContext.getExternalContext().getRequestMap().put("testBean", bean);
+
+        rootComponent = new UIViewRoot();
+        HtmlForm form = new HtmlForm();
+        form.setId("form");
+        rootComponent.getChildren().add(form);
+        inputComponent1 = new HtmlInputText();
+        form.getChildren().add(inputComponent1);
+        inputComponent1.setId("input1");
+        inputComponent2 = new HtmlInputText();
+        form.getChildren().add(inputComponent2);
+        inputComponent2.setId("input2");
+    }
+
+    @Override
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+    public void testEmptyIfTargetEmptyCorrect() throws Exception
+    {
+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");
+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");
+
+        //decode
+        inputComponent1.setSubmittedValue("");
+        inputComponent2.setSubmittedValue("");
+
+        //validate
+        inputComponent1.validate(facesContext);
+        inputComponent2.validate(facesContext);
+
+        processCrossValidation();
+        checkMessageCount(0);
+
+        assertNavigationBlocked(false);
+
+        //no update model needed
+    }
+
+    public void testEmptyIfTargetEmptyFailed() throws Exception
+    {
+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");
+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");
+
+        //decode
+        inputComponent1.setSubmittedValue("");
+        inputComponent2.setSubmittedValue("1d3");
+
+        //validate
+        inputComponent1.validate(facesContext);
+        inputComponent2.validate(facesContext);
+
+        processCrossValidation();
+        checkMessageCount(1);
+
+        assertNavigationBlocked(true);
+
+        checkMessageSeverities(FacesMessage.SEVERITY_ERROR);
+
+        //no update model needed
+    }
+
+    public void testEmptyIfTargetNotEmptyCorrect1() throws Exception
+    {
+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");
+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");
+
+        //decode
+        inputComponent1.setSubmittedValue("1d3");
+        inputComponent2.setSubmittedValue("1d3");
+
+        //validate
+        inputComponent1.validate(facesContext);
+        inputComponent2.validate(facesContext);
+
+        processCrossValidation();
+        checkMessageCount(0);
+
+        assertNavigationBlocked(false);
+
+        //no update model needed
+    }
+
+    public void testEmptyIfTargetNotEmptyCorrect2() throws Exception
+    {
+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");
+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");
+
+        //decode
+        inputComponent1.setSubmittedValue("1d3");
+        inputComponent2.setSubmittedValue("");
+
+        //validate
+        inputComponent1.validate(facesContext);
+        inputComponent2.validate(facesContext);
+
+        processCrossValidation();
+        checkMessageCount(0);
+
+        assertNavigationBlocked(false);
+
+        //no update model needed
+    }
+}
\ No newline at end of file

Added: myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf3TestBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf3TestBean.java?rev=944024&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf3TestBean.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf3TestBean.java Thu May 13 21:54:14 2010
@@ -0,0 +1,48 @@
+/*
+ * 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.extensions.validator.test.propval.crossval;
+
+import org.apache.myfaces.extensions.validator.crossval.annotation.EmptyIf;
+
+public class EmptyIf3TestBean
+{
+    private Boolean property1;
+    @EmptyIf(valueOf = "property1")
+    private String property2;
+
+    public Boolean getProperty1()
+    {
+        return property1;
+    }
+
+    public void setProperty1(Boolean property1)
+    {
+        this.property1 = property1;
+    }
+
+    public String getProperty2()
+    {
+        return property2;
+    }
+
+    public void setProperty2(String property2)
+    {
+        this.property2 = property2;
+    }
+}
\ No newline at end of file

Added: myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf3TestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf3TestCase.java?rev=944024&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf3TestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf3TestCase.java Thu May 13 21:54:14 2010
@@ -0,0 +1,162 @@
+/*
+ * 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.extensions.validator.test.propval.crossval;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.myfaces.extensions.validator.test.propval.AbstractPropertyValidationTestCase;
+
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.html.HtmlForm;
+import javax.faces.component.html.HtmlInputText;
+import javax.faces.application.FacesMessage;
+
+public class EmptyIf3TestCase extends AbstractPropertyValidationTestCase
+{
+
+    HtmlInputText inputComponent1 = null;
+    HtmlInputText inputComponent2 = null;
+
+    UIViewRoot rootComponent = null;
+
+    public EmptyIf3TestCase(String name)
+    {
+        super(name);
+        inputComponent1 = null;
+        inputComponent2 = null;
+        rootComponent = null;
+    }
+
+    public static Test suite()
+    {
+        return new TestSuite(EmptyIf3TestCase.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        EmptyIf3TestBean bean = new EmptyIf3TestBean();
+        createValueBinding(null, "value", "#{testBean}");
+        facesContext.getExternalContext().getRequestMap().put("testBean", bean);
+
+        rootComponent = new UIViewRoot();
+        HtmlForm form = new HtmlForm();
+        form.setId("form");
+        rootComponent.getChildren().add(form);
+        inputComponent1 = new HtmlInputText();
+        form.getChildren().add(inputComponent1);
+        inputComponent1.setId("input1");
+        inputComponent2 = new HtmlInputText();
+        form.getChildren().add(inputComponent2);
+        inputComponent2.setId("input2");
+    }
+
+    @Override
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+    public void testEmptyIfBooleanTargetNotEmptyCorrect() throws Exception
+    {
+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");
+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");
+
+        //decode
+        inputComponent1.setSubmittedValue(Boolean.TRUE.toString());
+        inputComponent2.setSubmittedValue("");
+
+        //validate
+        inputComponent1.validate(facesContext);
+        inputComponent2.validate(facesContext);
+
+        processCrossValidation();
+        checkMessageCount(0);
+
+        assertNavigationBlocked(false);
+
+        //no update model needed
+    }
+
+    public void testEmptyIfBooleanTargetNotEmptyFailed() throws Exception
+    {
+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");
+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");
+
+        //decode
+        inputComponent1.setSubmittedValue(Boolean.TRUE.toString());
+        inputComponent2.setSubmittedValue("1d3");
+
+        //validate
+        inputComponent1.validate(facesContext);
+        inputComponent2.validate(facesContext);
+
+        processCrossValidation();
+        checkMessageCount(1);
+
+        assertNavigationBlocked(true);
+
+        checkMessageSeverities(FacesMessage.SEVERITY_ERROR);
+
+        //no update model needed
+    }
+
+    public void testEmptyIfBooleanTargetEmptyCorrect1() throws Exception
+    {
+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");
+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");
+
+        //decode
+        inputComponent1.setSubmittedValue(Boolean.FALSE.toString());
+        inputComponent2.setSubmittedValue("");
+
+        //validate
+        inputComponent1.validate(facesContext);
+        inputComponent2.validate(facesContext);
+
+        processCrossValidation();
+        checkMessageCount(0);
+
+        assertNavigationBlocked(false);
+
+        //no update model needed
+    }
+
+    public void testEmptyIfBooleanTargetEmptyCorrect2() throws Exception
+    {
+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");
+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");
+
+        //decode
+        inputComponent1.setSubmittedValue(Boolean.FALSE.toString());
+        inputComponent2.setSubmittedValue("1d3");
+
+        //validate
+        inputComponent1.validate(facesContext);
+        inputComponent2.validate(facesContext);
+
+        processCrossValidation();
+        checkMessageCount(0);
+
+        assertNavigationBlocked(false);
+
+        //no update model needed
+    }
+}
\ No newline at end of file

Added: myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf4TestBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf4TestBean.java?rev=944024&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf4TestBean.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf4TestBean.java Thu May 13 21:54:14 2010
@@ -0,0 +1,49 @@
+/*
+ * 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.extensions.validator.test.propval.crossval;
+
+import org.apache.myfaces.extensions.validator.crossval.annotation.EmptyIf;
+import static org.apache.myfaces.extensions.validator.crossval.annotation.RequiredIfType.*;
+
+public class EmptyIf4TestBean
+{
+    private boolean property1;
+    @EmptyIf(valueOf = "property1", is = empty)
+    private String property2;
+
+    public boolean isProperty1()
+    {
+        return property1;
+    }
+
+    public void setProperty1(boolean property1)
+    {
+        this.property1 = property1;
+    }
+
+    public String getProperty2()
+    {
+        return property2;
+    }
+
+    public void setProperty2(String property2)
+    {
+        this.property2 = property2;
+    }
+}
\ No newline at end of file

Added: myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf4TestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf4TestCase.java?rev=944024&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf4TestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/EmptyIf4TestCase.java Thu May 13 21:54:14 2010
@@ -0,0 +1,162 @@
+/*
+ * 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.extensions.validator.test.propval.crossval;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.myfaces.extensions.validator.test.propval.AbstractPropertyValidationTestCase;
+
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.html.HtmlForm;
+import javax.faces.component.html.HtmlInputText;
+import javax.faces.application.FacesMessage;
+
+public class EmptyIf4TestCase extends AbstractPropertyValidationTestCase
+{
+
+    HtmlInputText inputComponent1 = null;
+    HtmlInputText inputComponent2 = null;
+
+    UIViewRoot rootComponent = null;
+
+    public EmptyIf4TestCase(String name)
+    {
+        super(name);
+        inputComponent1 = null;
+        inputComponent2 = null;
+        rootComponent = null;
+    }
+
+    public static Test suite()
+    {
+        return new TestSuite(EmptyIf4TestCase.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        EmptyIf4TestBean bean = new EmptyIf4TestBean();
+        createValueBinding(null, "value", "#{testBean}");
+        facesContext.getExternalContext().getRequestMap().put("testBean", bean);
+
+        rootComponent = new UIViewRoot();
+        HtmlForm form = new HtmlForm();
+        form.setId("form");
+        rootComponent.getChildren().add(form);
+        inputComponent1 = new HtmlInputText();
+        form.getChildren().add(inputComponent1);
+        inputComponent1.setId("input1");
+        inputComponent2 = new HtmlInputText();
+        form.getChildren().add(inputComponent2);
+        inputComponent2.setId("input2");
+    }
+
+    @Override
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+    public void testEmptyIfBooleanTargetEmptyCorrect() throws Exception
+    {
+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");
+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");
+
+        //decode
+        inputComponent1.setSubmittedValue(Boolean.FALSE.toString());
+        inputComponent2.setSubmittedValue("");
+
+        //validate
+        inputComponent1.validate(facesContext);
+        inputComponent2.validate(facesContext);
+
+        processCrossValidation();
+        checkMessageCount(0);
+
+        assertNavigationBlocked(false);
+
+        //no update model needed
+    }
+
+    public void testEmptyIfBooleanTargetEmptyFailed() throws Exception
+    {
+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");
+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");
+
+        //decode
+        inputComponent1.setSubmittedValue(Boolean.FALSE.toString());
+        inputComponent2.setSubmittedValue("1d3");
+
+        //validate
+        inputComponent1.validate(facesContext);
+        inputComponent2.validate(facesContext);
+
+        processCrossValidation();
+        checkMessageCount(1);
+
+        assertNavigationBlocked(true);
+
+        checkMessageSeverities(FacesMessage.SEVERITY_ERROR);
+
+        //no update model needed
+    }
+
+    public void testEmptyIfBooleanTargetNotEmptyCorrect1() throws Exception
+    {
+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");
+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");
+
+        //decode
+        inputComponent1.setSubmittedValue(Boolean.TRUE.toString());
+        inputComponent2.setSubmittedValue("1d3");
+
+        //validate
+        inputComponent1.validate(facesContext);
+        inputComponent2.validate(facesContext);
+
+        processCrossValidation();
+        checkMessageCount(0);
+
+        assertNavigationBlocked(false);
+
+        //no update model needed
+    }
+
+    public void testEmptyIfBooleanTargetNotEmptyCorrect2() throws Exception
+    {
+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");
+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");
+
+        //decode
+        inputComponent1.setSubmittedValue(Boolean.TRUE.toString());
+        inputComponent2.setSubmittedValue("");
+
+        //validate
+        inputComponent1.validate(facesContext);
+        inputComponent2.validate(facesContext);
+
+        processCrossValidation();
+        checkMessageCount(0);
+
+        assertNavigationBlocked(false);
+
+        //no update model needed
+    }
+}
\ No newline at end of file

Added: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/EmptyIf.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/EmptyIf.java?rev=944024&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/EmptyIf.java (added)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/EmptyIf.java Thu May 13 21:54:14 2010
@@ -0,0 +1,53 @@
+/*
+ * 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.extensions.validator.crossval.annotation;
+
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ValidationParameter;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ViolationSeverity;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * @author Rudy De Busscher
+ */
+@Target({METHOD, FIELD})
+@Retention(RUNTIME)
+@Documented
+@UsageInformation(UsageCategory.API)
+public @interface EmptyIf
+{
+    String[] valueOf();
+
+    /*
+      * optional section
+      */
+
+    RequiredIfType is() default RequiredIfType.not_empty;
+
+    String validationErrorMsgKey() default "field_not_empty";
+
+    Class<? extends ValidationParameter>[] parameters() default ViolationSeverity.Error.class;
+}

Added: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/EmptyIfStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/EmptyIfStrategy.java?rev=944024&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/EmptyIfStrategy.java (added)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/EmptyIfStrategy.java Thu May 13 21:54:14 2010
@@ -0,0 +1,68 @@
+/*
+ * 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.extensions.validator.crossval.strategy;
+
+import org.apache.myfaces.extensions.validator.crossval.annotation.EmptyIf;
+import org.apache.myfaces.extensions.validator.crossval.annotation.RequiredIfType;
+
+/**
+ * @author Rudy De Busscher
+ */
+public class EmptyIfStrategy extends AbstractCompareStrategy<EmptyIf>
+{
+    @Override
+    protected String getValidationErrorMsgKey(EmptyIf annotation, boolean isTargetComponent)
+    {
+        return annotation.validationErrorMsgKey();
+    }
+
+    @Override
+    public String[] getValidationTargets(EmptyIf annotation)
+    {
+        return annotation.valueOf();
+    }
+
+    @Override
+    public boolean isViolation(Object source, Object target, EmptyIf annotation)
+    {
+        boolean violationFound = false;
+
+        if (annotation.is().equals(RequiredIfType.empty))
+        {
+            violationFound = (isTargetEmpty(target) || Boolean.FALSE.equals(target)) && !isSourceEmpty(source);
+        }
+        else if (annotation.is().equals(RequiredIfType.not_empty))
+        {
+            violationFound = (!isSourceEmpty(source) && !isTargetEmpty(target) && !(target instanceof Boolean)) ||
+                    (Boolean.TRUE.equals(target) && !isSourceEmpty(source));
+        }
+
+        return violationFound;
+    }
+
+    private boolean isTargetEmpty(Object target)
+    {
+        return target == null || target.equals("");
+    }
+
+    private boolean isSourceEmpty(Object source)
+    {
+        return source == null || source.equals("");
+    }
+}
\ No newline at end of file