form validation ready
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/invite-friends-vre@114562 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
cc12dd1ffd
commit
d7eecbf6e3
|
@ -1,18 +1,18 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" output="target/invite-friends-vre-0.0.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
<classpathentry kind="src" output="target/invite-friends-vre-0.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="src" output="target/invite-friends-vre-0.0.1-SNAPSHOT/WEB-INF/classes" path="target/generated-sources/gwt">
|
<classpathentry kind="src" output="target/invite-friends-vre-0.1.0-SNAPSHOT/WEB-INF/classes" path="target/generated-sources/gwt">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry excluding="**" kind="src" output="target/invite-friends-vre-0.0.1-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
<classpathentry excluding="**" kind="src" output="target/invite-friends-vre-0.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
@ -39,5 +39,5 @@
|
||||||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/invite-friends-vre-0.0.1-SNAPSHOT/WEB-INF/classes"/>
|
<classpathentry kind="output" path="target/invite-friends-vre-0.1.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
10
.project
10
.project
|
@ -25,11 +25,6 @@
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
|
<name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
|
@ -40,6 +35,11 @@
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
validateFragments=false
|
||||||
|
validation.use-project-settings=true
|
|
@ -1,10 +1,13 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||||
<wb-module deploy-name="invite-friends-vre">
|
<wb-module deploy-name="invite-friends-vre-portlet">
|
||||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||||
|
<dependent-module archiveName="session-checker-0.3.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/session-checker/session-checker">
|
||||||
|
<dependency-type>uses</dependency-type>
|
||||||
|
</dependent-module>
|
||||||
<property name="context-root" value="invite-friends-vre"/>
|
<property name="context-root" value="invite-friends-vre"/>
|
||||||
<property name="java-output-path" value="/invite-friends-vre/target/invite-friends-vre-0.0.1-SNAPSHOT/WEB-INF/classes"/>
|
<property name="java-output-path" value="/invite-friends-vre/target/invite-friends-vre-0.0.1-SNAPSHOT/WEB-INF/classes"/>
|
||||||
</wb-module>
|
</wb-module>
|
||||||
|
|
|
@ -4,4 +4,5 @@
|
||||||
<installed facet="java" version="1.7"/>
|
<installed facet="java" version="1.7"/>
|
||||||
<installed facet="jst.web" version="2.3"/>
|
<installed facet="jst.web" version="2.3"/>
|
||||||
<installed facet="wst.jsdt.web" version="1.0"/>
|
<installed facet="wst.jsdt.web" version="1.0"/>
|
||||||
|
<installed facet="liferay.portlet" version="6.0"/>
|
||||||
</faceted-project>
|
</faceted-project>
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
{"ide":{"scriptPaths":[]},"plugins":{"aui":{},"liferay":{},"yui":{}},"libs":["ecma5","browser"]}
|
4
pom.xml
4
pom.xml
|
@ -6,7 +6,7 @@
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
<artifactId>invite-friends-vre</artifactId>
|
<artifactId>invite-friends-vre</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.1.0-SNAPSHOT</version>
|
||||||
<name>Invite Friends to VRE</name>
|
<name>Invite Friends to VRE</name>
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/${project.artifactId}</connection>
|
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/${project.artifactId}</connection>
|
||||||
|
@ -55,11 +55,13 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.gwt</groupId>
|
<groupId>com.google.gwt</groupId>
|
||||||
<artifactId>gwt-user</artifactId>
|
<artifactId>gwt-user</artifactId>
|
||||||
|
<version>${gwtVersion}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.gwt</groupId>
|
<groupId>com.google.gwt</groupId>
|
||||||
<artifactId>gwt-dev</artifactId>
|
<artifactId>gwt-dev</artifactId>
|
||||||
|
<version>${gwtVersion}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -39,20 +39,41 @@ public class FormErrorsValidation extends AbstractActivity implements FormView.D
|
||||||
@Override
|
@Override
|
||||||
public boolean onSendClick() {
|
public boolean onSendClick() {
|
||||||
EditorDriver<UserDetails> editorDriver = view.getEditorDriver();
|
EditorDriver<UserDetails> editorDriver = view.getEditorDriver();
|
||||||
UserDetails login = editorDriver.flush();
|
UserDetails details = editorDriver.flush();
|
||||||
Set<ConstraintViolation<UserDetails>> violations = validate(login);
|
Set<ConstraintViolation<UserDetails>> violations = validateEmailTextBox(details);
|
||||||
//decorate widgets implementing HasEditorErrors with validation messages
|
//decorate widgets implementing HasEditorErrors with validation messages
|
||||||
return editorDriver.setConstraintViolations( (Set) violations);
|
return editorDriver.setConstraintViolations( (Set) violations);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<ConstraintViolation<UserDetails>> validate(UserDetails user2InviteBean){
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
|
@Override
|
||||||
|
public boolean onEmailSendInviteClick() {
|
||||||
|
EditorDriver<UserDetails> editorDriver = view.getEditorDriver();
|
||||||
|
UserDetails details = editorDriver.flush();
|
||||||
|
Set<ConstraintViolation<UserDetails>> violations = validateName(details);
|
||||||
|
return !violations.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<ConstraintViolation<UserDetails>> validateName(UserDetails user2InviteBean) {
|
||||||
|
Set<ConstraintViolation<UserDetails>> violations = new HashSet<ConstraintViolation<UserDetails>>();
|
||||||
|
if(user2InviteBean.getName() == null || "".equals(user2InviteBean.getName().trim())) {
|
||||||
|
violations.add(buildNotNullConstraintViolation(user2InviteBean, "name"));
|
||||||
|
}
|
||||||
|
if(user2InviteBean.getLastName() == null || "".equals(user2InviteBean.getLastName().trim())) {
|
||||||
|
violations.add(buildNotNullConstraintViolation(user2InviteBean, "lastname"));
|
||||||
|
}
|
||||||
|
return violations;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<ConstraintViolation<UserDetails>> validateEmailTextBox(UserDetails user2InviteBean){
|
||||||
Set<ConstraintViolation<UserDetails>> violations = new HashSet<ConstraintViolation<UserDetails>>();
|
Set<ConstraintViolation<UserDetails>> violations = new HashSet<ConstraintViolation<UserDetails>>();
|
||||||
if(user2InviteBean.getEmail() == null || "".equals(user2InviteBean.getEmail().trim())) {
|
if(user2InviteBean.getEmail() == null || "".equals(user2InviteBean.getEmail().trim())) {
|
||||||
violations.add(buildNotNullConstraintViolation(user2InviteBean, "email"));
|
violations.add(buildNotNullConstraintViolation(user2InviteBean, "email"));
|
||||||
}
|
}
|
||||||
else if (!isValidEmailAddress(user2InviteBean.getEmail())) {
|
else if (!isValidEmailAddress(user2InviteBean.getEmail())) {
|
||||||
violations.add(buildInvalidEmailAddressConstraintViolation(user2InviteBean, "email"));
|
violations.add(buildInvalidEmailAddressConstraintViolation(user2InviteBean, "email"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return violations;
|
return violations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,4 +176,5 @@ public class FormErrorsValidation extends AbstractActivity implements FormView.D
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,11 @@ public interface FormView extends IsWidget {
|
||||||
|
|
||||||
public interface Delegate {
|
public interface Delegate {
|
||||||
boolean onSendClick();
|
boolean onSendClick();
|
||||||
|
|
||||||
|
boolean onEmailSendInviteClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EditorDriver<UserDetails> getEditorDriver();
|
EditorDriver<UserDetails> getEditorDriver();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,11 @@
|
||||||
package org.gcube.portlets.user.invitefriends.client.validation;
|
package org.gcube.portlets.user.invitefriends.client.validation;
|
||||||
|
|
||||||
import com.github.gwtbootstrap.client.ui.Button;
|
import com.github.gwtbootstrap.client.ui.Button;
|
||||||
|
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
||||||
import com.github.gwtbootstrap.client.ui.HelpBlock;
|
import com.github.gwtbootstrap.client.ui.HelpBlock;
|
||||||
import com.github.gwtbootstrap.client.ui.Modal;
|
import com.github.gwtbootstrap.client.ui.Modal;
|
||||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||||
|
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.editor.client.Editor;
|
import com.google.gwt.editor.client.Editor;
|
||||||
import com.google.gwt.editor.client.EditorDriver;
|
import com.google.gwt.editor.client.EditorDriver;
|
||||||
|
@ -41,8 +43,11 @@ public class FormViewImpl extends Composite implements FormView, Editor<FormView
|
||||||
@UiField Button cancelInvite;
|
@UiField Button cancelInvite;
|
||||||
@UiField Button sendInvite;
|
@UiField Button sendInvite;
|
||||||
@UiField Modal modalWindow;
|
@UiField Modal modalWindow;
|
||||||
|
@UiField HelpBlock nameErrors;
|
||||||
@UiField HelpBlock helpBlock;
|
@UiField HelpBlock helpBlock;
|
||||||
|
|
||||||
|
@UiField
|
||||||
|
ControlGroup nameGroup;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -62,6 +67,17 @@ public class FormViewImpl extends Composite implements FormView, Editor<FormView
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UiHandler("sendInvite")
|
||||||
|
void onSendInviteClick(ClickEvent event) {
|
||||||
|
if (delegate.onEmailSendInviteClick()) {
|
||||||
|
nameGroup.setType(ControlGroupType.ERROR);
|
||||||
|
nameErrors.setText("Please fill both name and last name");
|
||||||
|
} else {
|
||||||
|
nameGroup.setType(ControlGroupType.SUCCESS);
|
||||||
|
nameErrors.setText("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@UiHandler("cancelInvite")
|
@UiHandler("cancelInvite")
|
||||||
public void onCancelClick(ClickEvent e) {
|
public void onCancelClick(ClickEvent e) {
|
||||||
modalWindow.hide();
|
modalWindow.hide();
|
||||||
|
|
|
@ -2,37 +2,31 @@
|
||||||
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
|
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
|
||||||
xmlns:g='urn:import:com.google.gwt.user.client.ui' xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
|
xmlns:g='urn:import:com.google.gwt.user.client.ui' xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
|
||||||
<b:Form type="VERTICAL">
|
<b:Form type="VERTICAL">
|
||||||
<b:Fieldset ui:field="controlFieldset">
|
<b:ControlGroup ui:field="emailGroup">
|
||||||
|
<b:TextBox placeholder="e-mail address" ui:field="email"
|
||||||
|
controlGroup="{emailGroup}" errorLabel="{emailErrors}" />
|
||||||
|
<b:HelpBlock ui:field="emailErrors"></b:HelpBlock>
|
||||||
|
</b:ControlGroup>
|
||||||
|
<b:Button ui:field="openModal">Send Invite</b:Button>
|
||||||
|
<b:Modal ui:field="modalWindow" title="Invite Friend"
|
||||||
|
backdrop="STATIC" keyboard="true" animation="true">
|
||||||
|
<b:Form type="VERTICAL">
|
||||||
|
<b:ControlGroup ui:field="nameGroup">
|
||||||
|
<b:HelpBlock styleName="helpFontSize">Please, enter Name and
|
||||||
|
Last name
|
||||||
|
of the friend you
|
||||||
|
wish to invite:</b:HelpBlock>
|
||||||
|
|
||||||
<b:ControlGroup ui:field="emailGroup">
|
<b:TextBox placeholder="name" ui:field="name"></b:TextBox>
|
||||||
<b:TextBox placeholder="e-mail address" ui:field="email"
|
<b:TextBox placeholder="last name" ui:field="lastName"></b:TextBox>
|
||||||
controlGroup="{emailGroup}" errorLabel="{emailErrors}" />
|
<b:HelpBlock ui:field="nameErrors"></b:HelpBlock>
|
||||||
<b:HelpBlock ui:field="emailErrors"></b:HelpBlock>
|
<b:HelpBlock ui:field="helpBlock" styleName="helpFontSize"></b:HelpBlock>
|
||||||
</b:ControlGroup>
|
</b:ControlGroup>
|
||||||
<b:Button ui:field="openModal">Send Invite</b:Button>
|
</b:Form>
|
||||||
|
<b:ModalFooter>
|
||||||
<b:Modal ui:field="modalWindow" title="Invite Friend"
|
<b:Button ui:field="cancelInvite">Cancel</b:Button>
|
||||||
backdrop="STATIC" keyboard="true" animation="true">
|
<b:Button ui:field="sendInvite" type="PRIMARY">Send Invite</b:Button>
|
||||||
<b:Form type="VERTICAL" ui:field="mainForm">
|
</b:ModalFooter>
|
||||||
<b:Fieldset>
|
</b:Modal>
|
||||||
<b:ControlGroup>
|
|
||||||
<b:HelpBlock styleName="helpFontSize">Please, enter Name and
|
|
||||||
Last name
|
|
||||||
of the friend you
|
|
||||||
wish to invite:</b:HelpBlock>
|
|
||||||
|
|
||||||
<b:TextBox placeholder="name" ui:field="name"></b:TextBox>
|
|
||||||
<b:TextBox placeholder="last name" ui:field="lastName"></b:TextBox>
|
|
||||||
|
|
||||||
<b:HelpBlock ui:field="helpBlock" styleName="helpFontSize"></b:HelpBlock>
|
|
||||||
</b:ControlGroup>
|
|
||||||
</b:Fieldset>
|
|
||||||
</b:Form>
|
|
||||||
<b:ModalFooter>
|
|
||||||
<b:Button ui:field="cancelInvite">Cancel</b:Button>
|
|
||||||
<b:Button ui:field="sendInvite" type="PRIMARY">Send Invite</b:Button>
|
|
||||||
</b:ModalFooter>
|
|
||||||
</b:Modal>
|
|
||||||
</b:Fieldset>
|
|
||||||
</b:Form>
|
</b:Form>
|
||||||
</ui:UiBinder>
|
</ui:UiBinder>
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
form {
|
||||||
|
margin-bottom: 10px !important;
|
||||||
|
}
|
||||||
|
|
||||||
.helpFontSize {
|
.helpFontSize {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
|
|
||||||
<title>Web Application Starter Project</title>
|
<title>Web Application Starter Project</title>
|
||||||
|
|
||||||
<script type="text/javascript" src="invitefriends/js/jquery-1.10.1.min.js"></script>
|
|
||||||
<script type="text/javascript" src="invitefriends/js/bootstrap.min.js"></script>
|
|
||||||
<script type="text/javascript" language="javascript" src="invitefriends/invitefriends.nocache.js"></script>
|
<script type="text/javascript" language="javascript" src="invitefriends/invitefriends.nocache.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,6 @@
|
||||||
--%>
|
--%>
|
||||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript"
|
|
||||||
src="<%=request.getContextPath()%>/invitefriends/js/jquery-1.10.1.min.js"></script>
|
|
||||||
<script type="text/javascript"
|
|
||||||
src="<%=request.getContextPath()%>/invitefriends/js/bootstrap.min.js"></script>
|
|
||||||
<script type="text/javascript"
|
<script type="text/javascript"
|
||||||
src='<%=request.getContextPath()%>/invitefriends/invitefriends.nocache.js'></script>
|
src='<%=request.getContextPath()%>/invitefriends/invitefriends.nocache.js'></script>
|
||||||
<div id="invite-friends-DIV"></div>
|
<div id="invite-friends-DIV"></div>
|
||||||
|
|
Loading…
Reference in New Issue