Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
59 changed files
with
782 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.wicketstuff</groupId> | ||
<artifactId>wicketstuff-core</artifactId> | ||
<version>8.0.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>wicket-datetime-parent</artifactId> | ||
<packaging>pom</packaging> | ||
<name>Wicket-datetime Parent</name> | ||
<description>Specific wicket components to display date/time related controls (with help of YUI JS library)</description> | ||
|
||
<modules> | ||
<module>wicket-datetime</module> | ||
<module>wicket-datetime-examples</module> | ||
</modules> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0"?> | ||
<project | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.wicketstuff</groupId> | ||
<artifactId>wicket-datetime-parent</artifactId> | ||
<version>8.0.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>wicket-datetime-examples</artifactId> | ||
<packaging>war</packaging> | ||
<name>wicket-datetime-examples</name> | ||
<url>http://maven.apache.org</url> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.wicketstuff</groupId> | ||
<artifactId>wicket-datetime</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.wicket</groupId> | ||
<artifactId>wicket-bean-validation</artifactId> | ||
<version>${wicket.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.validation</groupId> | ||
<artifactId>validation-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hibernate</groupId> | ||
<artifactId>hibernate-validator</artifactId> | ||
</dependency> | ||
<!-- JETTY DEPENDENCIES FOR TESTING --> | ||
<dependency> | ||
<groupId>org.eclipse.jetty.aggregate</groupId> | ||
<artifactId>jetty-all</artifactId> | ||
<classifier>uber</classifier> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
46 changes: 46 additions & 0 deletions
46
...wicket-datetime-examples/src/main/java/org/wicketstuff/datetime/examples/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.wicketstuff.datetime.examples; | ||
|
||
import org.apache.wicket.Page; | ||
import org.apache.wicket.bean.validation.BeanValidationConfiguration; | ||
import org.apache.wicket.protocol.http.WebApplication; | ||
import org.apache.wicket.settings.SecuritySettings; | ||
import org.apache.wicket.util.crypt.ClassCryptFactory; | ||
import org.apache.wicket.util.crypt.NoCrypt; | ||
import org.wicketstuff.datetime.examples.dates.DatesPage; | ||
|
||
public class Application extends WebApplication | ||
{ | ||
/** | ||
* prevent wicket from launching a java application window on the desktop <br/> | ||
* once someone uses awt-specific classes java will automatically do so and allocate a window | ||
* unless you tell java to run in 'headless-mode' | ||
*/ | ||
static | ||
{ | ||
System.setProperty("java.awt.headless", "true"); | ||
} | ||
|
||
@Override | ||
protected void init() | ||
{ | ||
// WARNING: DO NOT do this on a real world application unless | ||
// you really want your app's passwords all passed around and | ||
// stored in unencrypted browser cookies (BAD IDEA!)!!! | ||
|
||
// The NoCrypt class is being used here because not everyone | ||
// has the java security classes required by Crypt installed | ||
// and we want them to be able to run the examples out of the | ||
// box. | ||
getSecuritySettings().setCryptFactory( | ||
new ClassCryptFactory(NoCrypt.class, SecuritySettings.DEFAULT_ENCRYPTION_KEY)); | ||
|
||
getDebugSettings().setDevelopmentUtilitiesEnabled(true); | ||
new BeanValidationConfiguration().configure(this); | ||
} | ||
|
||
@Override | ||
public Class<? extends Page> getHomePage() | ||
{ | ||
return DatesPage.class; | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...s/src/main/java/org/wicketstuff/datetime/examples/bean/validation/BeanValidationPage.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<html xmlns:wicket="http://wicket.apache.org"> | ||
<head> | ||
<title>Wicket Examples - Bean Validation</title> | ||
<link rel="stylesheet" type="text/css" href="style.css" /> | ||
<style> | ||
.note { font-size:.8em; } | ||
.required {font-weight: bold;} | ||
</style> | ||
</head> | ||
<body> | ||
<a href="#" wicket:id="datesPage">Go to DatesPage</a> | ||
<br/> | ||
<br/> | ||
<div wicket:id="feedbackErrors"></div> | ||
|
||
<form wicket:id="form" novalidate="novalidate"> | ||
<table cellspacing="0" cellpadding="4"> | ||
<tr> | ||
<td><label wicket:for="name"><wicket:label>Name</wicket:label></label></td> | ||
<td><input wicket:id="name" type="text" size="30"/></td> | ||
<td><pre class="note">@NotNull @Size(min = 2, max = 30)</pre></td> | ||
</tr> | ||
<tr> | ||
<td><label wicket:for="email"><wicket:label>Email</wicket:label></label></td> | ||
<td><input wicket:id="email" type="text" size="30"/></td> | ||
<td><pre class="note">@NotNull @Email</pre></td> | ||
</tr> | ||
<tr> | ||
<td><label wicket:for="phone"><wicket:label>Phone</wicket:label></label></td> | ||
<td><input wicket:id="phone" type="text" size="20"/></td> | ||
<td><pre class="note">@Pattern(regexp = "[0-9]{3}-[0-9]{4}")</pre></td> | ||
</tr> | ||
<tr> | ||
<td><label wicket:for="birthdate"><wicket:label>Birthdate</wicket:label></label></td> | ||
<td><input wicket:id="birthdate" type="text" size="10"/></td> | ||
<td><pre class="note">m/d/yyyy field with @Past</pre></td> | ||
</tr> | ||
<tr> | ||
<td><label wicket:for="password"><wicket:label>Password</wicket:label></label></td> | ||
<td><input wicket:id="password" type="text" size="10"/></td> | ||
<td><pre class="note">Custom constraint @ValidPassword with custom message bundles.<br/>A valid password must contain only alphanumeric chars and at least two digits.</pre> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td></td> | ||
<td> | ||
<input type="submit" value="Submit"/> | ||
</td> | ||
<td><span class="note">press to submit the form and run the validation</span></td> | ||
</tr> | ||
</table> | ||
</form> | ||
<div wicket:id="feedbackSuccess"></div> | ||
</body> | ||
</html> |
73 changes: 73 additions & 0 deletions
73
...s/src/main/java/org/wicketstuff/datetime/examples/bean/validation/BeanValidationPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 org.wicketstuff.datetime.examples.bean.validation; | ||
|
||
import org.apache.wicket.bean.validation.PropertyValidator; | ||
import org.wicketstuff.datetime.StyleDateConverter; | ||
import org.wicketstuff.datetime.examples.dates.DatesPage; | ||
import org.wicketstuff.datetime.markup.html.form.DateTextField; | ||
import org.apache.wicket.feedback.ExactLevelFeedbackMessageFilter; | ||
import org.apache.wicket.feedback.FeedbackMessage; | ||
import org.apache.wicket.markup.html.WebPage; | ||
import org.apache.wicket.markup.html.form.Form; | ||
import org.apache.wicket.markup.html.form.TextField; | ||
import org.apache.wicket.markup.html.link.Link; | ||
import org.apache.wicket.markup.html.panel.FeedbackPanel; | ||
import org.apache.wicket.model.PropertyModel; | ||
|
||
public class BeanValidationPage extends WebPage | ||
{ | ||
private static final long serialVersionUID = 1L; | ||
Person person = new Person(); | ||
|
||
public BeanValidationPage() | ||
{ | ||
add(new Link<Void>("datesPage") | ||
{ | ||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public void onClick() | ||
{ | ||
setResponsePage(DatesPage.class); | ||
} | ||
}); | ||
add(new FeedbackPanel("feedbackErrors", new ExactLevelFeedbackMessageFilter(FeedbackMessage.ERROR))); | ||
|
||
Form<?> form = new Form<Void>("form") { | ||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
protected void onSubmit() | ||
{ | ||
super.onSubmit(); | ||
info("Form successfully submitted!"); | ||
} | ||
}; | ||
|
||
add(form); | ||
|
||
form.add(new TextField<>("name", new PropertyModel<String>(this, "person.name")).add(new PropertyValidator<>())); | ||
form.add(new TextField<>("phone", new PropertyModel<String>(this, "person.phone")).add(new PropertyValidator<>())); | ||
form.add(new TextField<>("email", new PropertyModel<String>(this, "person.email")).add(new PropertyValidator<>())); | ||
form.add(new DateTextField("birthdate", new PropertyModel<>(this, "person.birthdate"), | ||
new StyleDateConverter("S-", true)).add(new PropertyValidator<>())); | ||
form.add(new TextField<>("password", new PropertyModel<String>(this, "person.password")).add(new PropertyValidator<>())); | ||
|
||
add(new FeedbackPanel("feedbackSuccess", new ExactLevelFeedbackMessageFilter(FeedbackMessage.INFO))); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...main/java/org/wicketstuff/datetime/examples/bean/validation/BeanValidationPage.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# 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. | ||
password.needDigits=You need to have at least 2 digits in your password. | ||
password.validChars=Password value can contain only characters and digits. |
101 changes: 101 additions & 0 deletions
101
...time-examples/src/main/java/org/wicketstuff/datetime/examples/bean/validation/Person.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* 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.wicketstuff.datetime.examples.bean.validation; | ||
|
||
import java.io.Serializable; | ||
import java.util.Date; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import javax.validation.constraints.Past; | ||
import javax.validation.constraints.Pattern; | ||
import javax.validation.constraints.Size; | ||
|
||
import org.wicketstuff.datetime.examples.bean.validation.constraint.ValidPassword; | ||
|
||
import javax.validation.constraints.Email; | ||
|
||
public class Person implements Serializable | ||
{ | ||
private static final long serialVersionUID = 1L; | ||
|
||
@NotNull | ||
@Size(min = 2, max = 30) | ||
private String name; | ||
|
||
@NotNull | ||
private String email; | ||
|
||
@Pattern(regexp = "[0-9]{3}-[0-9]{4}") | ||
private String phone; | ||
|
||
@Past | ||
private Date birthdate; | ||
|
||
@ValidPassword | ||
private String password; | ||
|
||
public String getName() | ||
{ | ||
return name; | ||
} | ||
|
||
public void setName(String name) | ||
{ | ||
this.name = name; | ||
} | ||
|
||
public String getEmail() | ||
{ | ||
return email; | ||
} | ||
|
||
public void setEmail(String email) | ||
{ | ||
this.email = email; | ||
} | ||
|
||
public String getPhone() | ||
{ | ||
return phone; | ||
} | ||
|
||
public void setPhone(String phone) | ||
{ | ||
this.phone = phone; | ||
} | ||
|
||
public Date getBirthdate() | ||
{ | ||
return birthdate; | ||
} | ||
|
||
public void setBirthdate(Date birthdate) | ||
{ | ||
this.birthdate = birthdate; | ||
} | ||
|
||
public String getPassword() | ||
{ | ||
return password; | ||
} | ||
|
||
public void setPassword(String password) | ||
{ | ||
this.password = password; | ||
} | ||
} |
Oops, something went wrong.