Author: hoang_to
Date: 2010-05-14 06:38:42 -0400 (Fri, 14 May 2010)
New Revision: 3093
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterEditMode.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterInputSet.java
Log:
GTNPORTAL-1156: Captcha input visibility does not follow Register portlet 's Portlet
Preferences
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterEditMode.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterEditMode.java 2010-05-14
10:17:46 UTC (rev 3092)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterEditMode.java 2010-05-14
10:38:42 UTC (rev 3093)
@@ -18,6 +18,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 org.exoplatform.portal.webui.workspace.UIPortalApplication;
import org.exoplatform.webui.application.WebuiRequestContext;
@@ -30,6 +32,7 @@
import org.exoplatform.webui.event.EventListener;
import org.exoplatform.webui.form.UIForm;
import org.exoplatform.webui.form.UIFormCheckBoxInput;
+import org.exoplatform.webui.form.validator.MandatoryValidator;
import javax.portlet.PortletMode;
import javax.portlet.PortletPreferences;
@@ -70,6 +73,28 @@
PortletPreferences pref = pcontext.getRequest().getPreferences();
pref.setValue(USE_CAPTCHA, Boolean.toString(useCaptcha));
pref.store();
+
+ //Show/hide the captcha input in UIRegisterInputSet
+ UIRegisterPortlet registerPortlet = uiForm.getParent();
+ UIRegisterInputSet registerInputSet =
registerPortlet.findFirstComponentOfType(UIRegisterInputSet.class);
+
+ if(useCaptcha)
+ {
+ if(!registerInputSet.getCaptchaInputAvailability())
+ {
+ registerInputSet.addUIFormInput(new UICaptcha(UIRegisterInputSet.CAPTCHA,
UIRegisterInputSet.CAPTCHA,
null).addValidator(MandatoryValidator.class).addValidator(CaptchaValidator.class));
+ registerInputSet.setCaptchaInputAvailability(true);
+ }
+ }
+ else
+ {
+ if(registerInputSet.getCaptchaInputAvailability())
+ {
+ registerInputSet.removeChildById(UIRegisterInputSet.CAPTCHA);
+ registerInputSet.setCaptchaInputAvailability(false);
+ }
+ }
+
UIPortalApplication portalApp = Util.getUIPortalApplication();
if (portalApp.getModeState() == UIPortalApplication.NORMAL_MODE)
pcontext.setApplicationMode(PortletMode.VIEW);
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterInputSet.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterInputSet.java 2010-05-14
10:17:46 UTC (rev 3092)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterInputSet.java 2010-05-14
10:38:42 UTC (rev 3093)
@@ -60,6 +60,8 @@
protected static String CAPTCHA = "captcha";
+ private boolean captchaInputAvailability;
+
public UIRegisterInputSet(String name) throws Exception{
super(name);
@@ -91,9 +93,20 @@
if (useCaptcha)
{
addUIFormInput(new UICaptcha(CAPTCHA, CAPTCHA,
null).addValidator(MandatoryValidator.class).addValidator(CaptchaValidator.class));
+ this.captchaInputAvailability = true;
}
}
+ public void setCaptchaInputAvailability(boolean availability)
+ {
+ this.captchaInputAvailability = availability;
+ }
+
+ public boolean getCaptchaInputAvailability()
+ {
+ return this.captchaInputAvailability;
+ }
+
private String getUserName(){
return getUIStringInput(USER_NAME).getValue();
}
Show replies by date