Skip to content

Commit

Permalink
Merge pull request #1768 from volosied/faces23-validateWholeBean-fix
Browse files Browse the repository at this point in the history
Update Faces 2.3 Bean Validation Application to Address Challenge 1715
  • Loading branch information
arjantijms authored Jan 17, 2023
2 parents dfa7fdd + 6b4b853 commit 3d1817b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import java.io.Serializable;

@UserPassword
@UserPassword(groups = {UserPasswordValidatorGroup.class})
public class User implements Serializable {

private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package ee.jakarta.tck.faces.test.javaee8.validateWholeBean;

public interface UserPasswordValidatorGroup {

}
8 changes: 6 additions & 2 deletions tck/faces23/validateWholeBean/src/main/webapp/Issue4083.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@
<h:panelGrid columns="2">

<h:outputText value="Password" />
<h:inputSecret id="password1" value="#{backingBean.password1}"/>
<h:inputSecret id="password1" value="#{backingBean.password1}">
<f:validateBean validationGroups="ee.jakarta.tck.faces.test.javaee8.validateWholeBean.UserPasswordValidatorGroup" />
</h:inputSecret>

<h:outputText value="Password again" />
<h:inputSecret id="password2" value="#{backingBean.password2}"/>
<h:inputSecret id="password2" value="#{backingBean.password2}">
<f:validateBean validationGroups="ee.jakarta.tck.faces.test.javaee8.validateWholeBean.UserPasswordValidatorGroup" />
</h:inputSecret>

<h:commandButton id="submit" value="Submit"/>
</h:panelGrid>
Expand Down
12 changes: 9 additions & 3 deletions tck/faces23/validateWholeBean/src/main/webapp/Issue4313.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,23 @@
<h:panelGrid columns="2">

<h:outputText value="Password" />
<h:inputSecret id="password1" value="#{backingBean.user.password1}"/>
<h:inputSecret id="password1" value="#{backingBean.user.password1}">
<f:validateBean validationGroups="ee.jakarta.tck.faces.test.javaee8.validateWholeBean.UserPasswordValidatorGroup" />
</h:inputSecret>

<h:outputText value="Password again" />
<h:inputSecret id="password2" value="#{backingBean.user.password2}"/>
<h:inputSecret id="password2" value="#{backingBean.user.password2}">
<f:validateBean validationGroups="ee.jakarta.tck.faces.test.javaee8.validateWholeBean.UserPasswordValidatorGroup" />
</h:inputSecret>

<h:commandButton id="submit" value="Submit"/>
</h:panelGrid>

<h:messages id="err"/>

<f:validateWholeBean value="#{backingBean.user}" />
<f:validateWholeBean
value="#{backingBean.user}"
validationGroups="ee.jakarta.tck.faces.test.javaee8.validateWholeBean.UserPasswordValidatorGroup" />
</h:form>
</h:body>
</html>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Contributors to the Eclipse Foundation.
* Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -19,7 +19,7 @@

import static java.lang.System.getProperty;
import static org.jboss.shrinkwrap.api.ShrinkWrap.create;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.net.URL;
Expand Down Expand Up @@ -93,6 +93,6 @@ public void testValidateWholeBean() throws Exception {
HtmlSubmitInput submit = (HtmlSubmitInput) page.getHtmlElementById("submit");
HtmlPage page1 = submit.click();

assertEquals("Password fields must match", page1.getElementById("err").getElementsByTagName("li").get(0).asNormalizedText());
assertTrue("Validation message not found!", page1.getElementById("err").getElementsByTagName("li").get(0).asNormalizedText().contains("Password fields must match"));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Contributors to the Eclipse Foundation.
* Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -19,7 +19,7 @@

import static java.lang.System.getProperty;
import static org.jboss.shrinkwrap.api.ShrinkWrap.create;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.net.URL;
Expand Down Expand Up @@ -90,6 +90,6 @@ public void testValidateWholeBean() throws Exception {
HtmlSubmitInput submit = (HtmlSubmitInput) page.getHtmlElementById("form:submit");
HtmlPage page1 = submit.click();

assertEquals("Password fields must match", page1.getElementById("form:err").getElementsByTagName("li").get(0).asNormalizedText());
assertTrue("Validation message not found!", page1.getElementById("form:err").getElementsByTagName("li").get(0).asNormalizedText().contains("Password fields must match"));
}
}

0 comments on commit 3d1817b

Please sign in to comment.