Package org.exoplatform.webui.application.portlet

Examples of org.exoplatform.webui.application.portlet.PortletRequestContext


*/
public class CaptchaValidator extends AbstractValidator implements Serializable {

    @Override
    protected boolean isValid(String value, UIFormInput uiInput) {
        PortletRequestContext ctx = PortletRequestContext.getCurrentInstance();
        PortletRequest req = ctx.getRequest();
        PortletSession session = req.getPortletSession();

        Captcha captcha = (Captcha) session.getAttribute(Captcha.NAME);

        return ((captcha != null) && (captcha.isCorrect(value)));
View Full Code Here


        // Never use captcha if skipCaptcha is true. Otherwise read value from portlet property
        boolean useCaptcha;
        if (skipCaptcha) {
            useCaptcha = false;
        } else {
            PortletRequestContext pcontext = (PortletRequestContext) WebuiRequestContext.getCurrentInstance();
            PortletPreferences pref = pcontext.getRequest().getPreferences();
            useCaptcha = Boolean.parseBoolean(pref.getValue(UIRegisterEditMode.USE_CAPTCHA, "true"));
        }

        if (useCaptcha) {
            addUIFormInput(new UICaptcha(CAPTCHA, CAPTCHA, null).addValidator(MandatoryValidator.class).addValidator(
View Full Code Here

@Serialized
public class UIRegisterEditMode extends UIForm {
    public static final String USE_CAPTCHA = "useCaptcha";

    public UIRegisterEditMode() {
        PortletRequestContext pcontext = (PortletRequestContext) WebuiRequestContext.getCurrentInstance();
        PortletPreferences pref = pcontext.getRequest().getPreferences();
        boolean useCaptcha = Boolean.parseBoolean(pref.getValue(USE_CAPTCHA, "true"));
        addUIFormInput(new UIFormCheckBoxInput<Boolean>(USE_CAPTCHA, USE_CAPTCHA, useCaptcha).setValue(useCaptcha));
    }
View Full Code Here

        @Override
        public void execute(Event<UIRegisterEditMode> event) throws Exception {
            // TODO Auto-generated method stub
            UIRegisterEditMode uiForm = event.getSource();
            boolean useCaptcha = uiForm.getUIFormCheckBoxInput(USE_CAPTCHA).isChecked();
            PortletRequestContext pcontext = (PortletRequestContext) WebuiRequestContext.getCurrentInstance();
            PortletPreferences pref = pcontext.getRequest().getPreferences();
            pref.setValue(USE_CAPTCHA, Boolean.toString(useCaptcha));
            pref.store();

            // Show/hide the captcha input in UIRegisterInputSet
            UIComponent 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);

        }
View Full Code Here

        super.processAction(context);

        if (context.getProcessRender()) {
            // Invalidate the capcha
            if (context instanceof PortletRequestContext) {
                PortletRequestContext prc = (PortletRequestContext) context;
                prc.getRequest().getPortletSession().removeAttribute(Captcha.NAME);
            }
            context.addUIComponentToUpdateByAjax(getChild(UIRegisterInputSet.class));
        }
    }
View Full Code Here

                postRegistrationService.sendMailAfterSuccessfulRegistration(user);
            }

            // Invalidate the capcha
            if (context instanceof PortletRequestContext) {
                PortletRequestContext prc = (PortletRequestContext) context;
                prc.getRequest().getPortletSession().removeAttribute(Captcha.NAME);
            }
        }
View Full Code Here

    private final String windowId;

    private final String id;

    public UIGroovyPortlet() throws Exception {
        PortletRequestContext context = (PortletRequestContext) WebuiRequestContext.getCurrentInstance();
        PortletRequest prequest = context.getRequest();
        template_ = prequest.getPreferences().getValue("template", DEFAULT_TEMPLATE);
        windowId = prequest.getWindowID();
        id = windowId + "-portlet";
    }
View Full Code Here

@Serialized
public class UIApplicationRegistryEditMode extends UIForm {
    public static final String SHOW_IMPORT = "showImport";

    public UIApplicationRegistryEditMode() {
        PortletRequestContext pcontext = (PortletRequestContext) WebuiRequestContext.getCurrentInstance();
        PortletPreferences pref = pcontext.getRequest().getPreferences();
        boolean isShowImport = Boolean.parseBoolean(pref.getValue(SHOW_IMPORT, "true"));
        addUIFormInput(new UIFormCheckBoxInput<Boolean>(SHOW_IMPORT, SHOW_IMPORT, isShowImport).setValue(isShowImport));
    }
View Full Code Here

        @Override
        public void execute(Event<UIApplicationRegistryEditMode> event) throws Exception {
            // TODO Auto-generated method stub
            UIApplicationRegistryEditMode uiForm = event.getSource();
            boolean isShowImport = uiForm.getUIFormCheckBoxInput(SHOW_IMPORT).isChecked();
            PortletRequestContext pcontext = (PortletRequestContext) WebuiRequestContext.getCurrentInstance();
            PortletPreferences pref = pcontext.getRequest().getPreferences();
            pref.setValue(SHOW_IMPORT, Boolean.toString(isShowImport));
            pref.store();
            UIPortalApplication portalApp = Util.getUIPortalApplication();
            if (portalApp.getModeState() == UIPortalApplication.NORMAL_MODE)
                pcontext.setApplicationMode(PortletMode.VIEW);

        }
View Full Code Here

        @Override
        public void execute(Event<UIRegisterEditMode> event) throws Exception {
            // TODO Auto-generated method stub
            UIRegisterEditMode uiForm = event.getSource();
            boolean useCaptcha = uiForm.getUIFormCheckBoxInput(USE_CAPTCHA).isChecked();
            PortletRequestContext pcontext = (PortletRequestContext) WebuiRequestContext.getCurrentInstance();
            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);

        }
View Full Code Here

TOP

Related Classes of org.exoplatform.webui.application.portlet.PortletRequestContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.