Author: ndkhoiits
Date: 2011-09-28 06:29:18 -0400 (Wed, 28 Sep 2011)
New Revision: 7548
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterForm.java
portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/UIAccountForm.java
Log:
GTNPORTAL-2117 The username value should be validated even click on 'Check
Avaiablitiy'
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterForm.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterForm.java 2011-09-28
10:17:50 UTC (rev 7547)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterForm.java 2011-09-28
10:29:18 UTC (rev 7548)
@@ -19,9 +19,8 @@
package org.exoplatform.account.webui.component;
-import org.exoplatform.portal.webui.CaptchaValidator;
-import org.exoplatform.portal.webui.UICaptcha;
-import org.exoplatform.portal.webui.util.Util;
+import nl.captcha.Captcha;
+
import org.exoplatform.services.organization.OrganizationService;
import org.exoplatform.services.organization.UserHandler;
import org.exoplatform.web.application.ApplicationMessage;
@@ -33,23 +32,18 @@
import org.exoplatform.webui.core.UIPopupMessages;
import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
import org.exoplatform.webui.event.Event;
-import org.exoplatform.webui.event.EventListener;
import org.exoplatform.webui.event.Event.Phase;
+import org.exoplatform.webui.event.EventListener;
import org.exoplatform.webui.exception.MessageException;
import org.exoplatform.webui.form.UIForm;
import org.exoplatform.webui.form.UIFormInputWithActions;
-import org.exoplatform.webui.form.UIFormStringInput;
import org.exoplatform.webui.form.UIFormInputWithActions.ActionData;
-import org.exoplatform.webui.form.validator.MandatoryValidator;
+import org.exoplatform.webui.form.UIFormStringInput;
+import org.exoplatform.webui.form.validator.Validator;
import java.util.ArrayList;
import java.util.List;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import nl.captcha.Captcha;
-
/**
*
* @author <a href="mailto:hoang281283@gmail.com">Minh Hoang
TO</a>
@@ -91,7 +85,6 @@
@Override
public void processAction(WebuiRequestContext context) throws Exception
{
- // TODO Auto-generated method stub
super.processAction(context);
UIApplication uiApp = context.getUIApplication();
@@ -147,16 +140,19 @@
OrganizationService orgService =
registerForm.getApplicationComponent(OrganizationService.class);
UIRegisterInputSet registerInput =
registerForm.getChild(UIRegisterInputSet.class);
UIFormStringInput userNameInput =
registerInput.getUIStringInput(UIRegisterInputSet.USER_NAME);
- MandatoryValidator validator = new MandatoryValidator();
- try
+ List<Validator> validators = userNameInput.getValidators();
+ for (Validator validator : validators)
{
- validator.validate(userNameInput);
+ try
+ {
+ validator.validate(userNameInput);
+ }
+ catch (MessageException e)
+ {
+
event.getRequestContext().getUIApplication().addMessage(e.getDetailMessage());
+ return;
+ }
}
- catch (MessageException e)
- {
-
event.getRequestContext().getUIApplication().addMessage(e.getDetailMessage());
- return;
- }
String typedUsername = userNameInput.getValue();
WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
@@ -168,7 +164,7 @@
}
else
{
- uiApp.addMessage(new
ApplicationMessage("UIAccountInputSet.msg.user-not-exist", new
String[]{typedUsername}));
+ uiApp.addMessage(new
ApplicationMessage("UIAccountInputSet.msg.user-not-exist", new
String[]{typedUsername}, ApplicationMessage.INFO));
}
}
@@ -195,7 +191,6 @@
@Override
public void execute(Event<UIRegisterForm> event) throws Exception
{
- // TODO Auto-generated method stub
UIRegisterForm registerForm = event.getSource();
registerForm.resetInput();
}
Modified:
portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/UIAccountForm.java
===================================================================
---
portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/UIAccountForm.java 2011-09-28
10:17:50 UTC (rev 7547)
+++
portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/UIAccountForm.java 2011-09-28
10:29:18 UTC (rev 7548)
@@ -32,10 +32,13 @@
import org.exoplatform.webui.event.Event;
import org.exoplatform.webui.event.EventListener;
import org.exoplatform.webui.event.Event.Phase;
+import org.exoplatform.webui.exception.MessageException;
import org.exoplatform.webui.form.UIFormInputSet;
import org.exoplatform.webui.form.UIFormInputWithActions;
+import org.exoplatform.webui.form.UIFormStringInput;
import org.exoplatform.webui.form.UIFormTabPane;
import org.exoplatform.webui.form.UIFormInputWithActions.ActionData;
+import org.exoplatform.webui.form.validator.Validator;
import java.util.ArrayList;
import java.util.List;
@@ -127,21 +130,27 @@
WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
UIApplication uiApp = context.getUIApplication();
OrganizationService service =
uiForm.getApplicationComponent(OrganizationService.class);
- String userName = uiForm.getChild(UIAccountInputSet.class).getUserName();
- if (userName == null)
+ UIFormStringInput usernameInput =
uiForm.getChild(UIAccountInputSet.class).getUIStringInput(UIAccountInputSet.USERNAME);
+ for (Validator validator : usernameInput.getValidators())
{
- uiApp.addMessage(new
ApplicationMessage("UIAccountInputSet.msg.empty-input", null,
- ApplicationMessage.WARNING));
- return;
+ try
+ {
+ validator.validate(usernameInput);
+ }
+ catch (MessageException e)
+ {
+ uiApp.addMessage(e.getDetailMessage());
+ return;
+ }
}
+
+ String userName = usernameInput.getValue();
if (service.getUserHandler().findUserByName(userName) != null)
{
- uiApp.addMessage(new
ApplicationMessage("UIAccountInputSet.msg.user-exist", null,
- ApplicationMessage.WARNING));
+ uiApp.addMessage(new
ApplicationMessage("UIAccountInputSet.msg.user-exist", null,
ApplicationMessage.WARNING));
return;
}
- uiApp.addMessage(new
ApplicationMessage("UIAccountInputSet.msg.user-not-exist", null,
- ApplicationMessage.WARNING));
+ uiApp.addMessage(new
ApplicationMessage("UIAccountInputSet.msg.user-not-exist", null,
ApplicationMessage.INFO));
}
}
}
\ No newline at end of file
Show replies by date