Package org.exoplatform.webui.application

Examples of org.exoplatform.webui.application.WebuiRequestContext


    *    configuration XML file and the parent WebuiRequestContext is restored
    *   
    */
   public void render(RenderRequest req, RenderResponse res) throws Exception
   {
      WebuiRequestContext parentAppRequestContext = WebuiRequestContext.getCurrentInstance();
      PortletRequestContext context = createRequestContext(req, res, parentAppRequestContext);
      WebuiRequestContext.setCurrentInstance(context);
      try
      {
         if (!context.hasProcessAction())
View Full Code Here


   static public class SelectTabActionListener extends EventListener<UIFormTabPane>
   {
      public void execute(Event<UIFormTabPane> event) throws Exception
      {
         WebuiRequestContext context = event.getRequestContext();
         String renderTab = context.getRequestParameter(UIComponent.OBJECTID);
         if (renderTab == null)
            return;
         event.getSource().setSelectedTab(renderTab);
      }
View Full Code Here

            // Should renew the selectedNode. Don't reuse the cached selectedNode
            UserNode selectedNode = Util.getUIPortal().getSelectedUserNode();
            UserNodeFilterConfig filterConfig = createFilterConfig();
            UserNode resolvedNode = resolveNode(selectedNode, filterConfig);
            if (resolvedNode == null) {
                WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
                context.getUIApplication().addMessage(new ApplicationMessage("UIPortalManagement.msg.node.deleted", null));
                event.getRequestContext().addUIComponentToUpdateByAjax(uiWorkingWS);
                return;
            }

            uiApp.setModeState(UIPortalApplication.APP_BLOCK_EDIT_MODE);
View Full Code Here

        private final Logger log = LoggerFactory.getLogger(SendActionListener.class);

        public void execute(Event<UIForgetPassword> event) throws Exception {
            UIForgetPassword uiForm = event.getSource();
            UILogin uilogin = uiForm.getParent();
            WebuiRequestContext requestContext = event.getRequestContext();
            PortalRequestContext portalContext = PortalRequestContext.getCurrentInstance();
            MailService mailSrc = uiForm.getApplicationComponent(MailService.class);
            OrganizationService orgSrc = uiForm.getApplicationComponent(OrganizationService.class);
            String userName = uiForm.getUIStringInput(Username).getValue();
            String email = uiForm.getUIStringInput(Email).getValue();
            uiForm.reset();

            User user = null;

            String tokenId = null;

            // User provided his username
            if (userName != null) {
                user = orgSrc.getUserHandler().findUserByName(userName);
                if (user == null) {
                    requestContext.getUIApplication().addMessage(
                            new ApplicationMessage("UIForgetPassword.msg.user-not-exist", null));
                    return;
                }
            }

            // User provided his email address
            if (user == null && email != null) {
                Query query = new Query();
                // Querying on email won't work. PLIDM-12
                // Note that querying on email is inefficient as it loops over all users...
                query.setEmail(email);
                PageList<User> users = orgSrc.getUserHandler().findUsers(query);
                if (users.getAll().size() > 0) {
                    user = users.getAll().get(0);
                } else {
                    requestContext.getUIApplication().addMessage(
                            new ApplicationMessage("UIForgetPassword.msg.email-not-exist", null));
                    return;
                }
            }

            email = user.getEmail();

            // Create token
            RemindPasswordTokenService tokenService = uiForm.getApplicationComponent(RemindPasswordTokenService.class);
            Credentials credentials = new Credentials(user.getUserName(), "");
            tokenId = tokenService.createToken(credentials);

            String portalName = URLEncoder.encode(Util.getUIPortal().getName(), "UTF-8");

            ResourceBundle res = requestContext.getApplicationResourceBundle();
            String headerMail = "headermail";
            String footerMail = "footer";
            try {
                headerMail = res.getString(uiForm.getId() + ".mail.header") + "\n\n"
                        + res.getString(uiForm.getId() + ".mail.user") + user.getUserName() + "\n"
                        + res.getString(uiForm.getId() + ".mail.link");
                footerMail = "\n\n\n" + res.getString(uiForm.getId() + ".mail.footer");
            } catch (MissingResourceException e) {
                log.error(e.getMessage(), e);
            }
            HttpServletRequest request = portalContext.getRequest();
            String host = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort();
            String activeLink = host + requestContext.getRequestContextPath() + "/public/" + portalName + "?"
                    + ComponentURL.PORTAL_COMPONENT_ID + "=UIPortal&portal:action=RecoveryPasswordAndUsername&tokenId="
                    + tokenId;
            String mailText = headerMail + "\n" + activeLink + footerMail;
            try {
                mailSrc.sendMessage(res.getString("UIForgetPassword.mail.from"), email,
                        res.getString("UIForgetPassword.mail.subject"), mailText);
            } catch (Exception e) {
                requestContext.getUIApplication().addMessage(
                        new ApplicationMessage("UIForgetPassword.msg.send-mail-fail", null));
                requestContext.addUIComponentToUpdateByAjax(uilogin);

                return;
            }

            uilogin.getChild(UILoginForm.class).setRendered(true);
            uilogin.getChild(UIForgetPasswordWizard.class).setRendered(false);
            uilogin.getChild(UIForgetPassword.class).setRendered(false);
            requestContext.getUIApplication()
                    .addMessage(new ApplicationMessage("UIForgetPassword.msg.send-mail-success", null));
            requestContext.addUIComponentToUpdateByAjax(uilogin);
        }
View Full Code Here

        public void execute(Event<UIChangePassword> event) throws Exception {
            UIChangePassword uiForm = event.getSource();
            String password = uiForm.getUIStringInput(PASSWORD).getValue();
            String newpassword = uiForm.getUIStringInput(NEW_PASSWORD).getValue();
            String confirmnewpassword = uiForm.getUIStringInput(CONFIRM_NEW_PASSWORD).getValue();
            WebuiRequestContext request = event.getRequestContext();
            UIApplication uiApp = request.getUIApplication();
            OrganizationService orgService = uiForm.getApplicationComponent(OrganizationService.class);
            uiForm.reset();
            boolean isNew = true;
            if (!orgService.getUserHandler().authenticate(user_.getUserName(), password)) {
                uiApp.addMessage(new ApplicationMessage("UIResetPassword.msg.Invalid-account", null));
                isNew = false;
            }
            if (!newpassword.equals(confirmnewpassword)) {
                uiApp.addMessage(new ApplicationMessage("UIResetPassword.msg.password-is-not-match", null));
                isNew = false;
            }

            UIMaskWorkspace uiMaskWorkspace = uiApp.getChildById(UIPortalApplication.UI_MASK_WS_ID);
            if (isNew) {
                user_.setPassword(newpassword);
                orgService.getUserHandler().saveUser(user_, true);
                uiMaskWorkspace.createEvent("Close", Phase.DECODE, request).broadcast();
                uiApp.addMessage(new ApplicationMessage("UIResetPassword.msg.change-password-successfully", null));
            }
            request.addUIComponentToUpdateByAjax(uiMaskWorkspace);
        }
View Full Code Here

    public static class SaveActionListener extends EventListener<UIResetPassword> {
        public void execute(Event<UIResetPassword> event) throws Exception {
            UIResetPassword uiForm = event.getSource();
            String newpassword = uiForm.getUIStringInput(NEW_PASSWORD).getValue();
            String confirmnewpassword = uiForm.getUIStringInput(CONFIRM_NEW_PASSWORD).getValue();
            WebuiRequestContext request = event.getRequestContext();
            UIApplication uiApp = request.getUIApplication();
            UIMaskWorkspace uiMaskWorkspace = uiApp.getChildById(UIPortalApplication.UI_MASK_WS_ID);
            OrganizationService orgService = uiForm.getApplicationComponent(OrganizationService.class);
            RemindPasswordTokenService tokenService = uiForm.getApplicationComponent(RemindPasswordTokenService.class);

            uiForm.reset();
            boolean setPassword = true;

            if (!newpassword.equals(confirmnewpassword)) {
                uiApp.addMessage(new ApplicationMessage("UIResetPassword.msg.password-is-not-match", null));
                setPassword = false;
            }

            Token token = tokenService.deleteToken(uiForm.getTokenId());
            if (token == null || token.isExpired()) {
                uiApp.addMessage(new ApplicationMessage("UIForgetPassword.msg.expration", null));
                setPassword = false;
            }

            if (setPassword) {
                user_.setPassword(newpassword);
                orgService.getUserHandler().saveUser(user_, true);
                uiMaskWorkspace.createEvent("Close", Phase.DECODE, request).broadcast();
                uiApp.addMessage(new ApplicationMessage("UIResetPassword.msg.change-password-successfully", null));
            }
            request.addUIComponentToUpdateByAjax(uiMaskWorkspace);
        }
View Full Code Here

    public UIContainerList(InitParams initParams) throws Exception {
        // setComponentConfig(UIContainerConfigOptions.class, null);
        selectedCategory_ = null;
        if (initParams == null)
            return;
        WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
        Param param = initParams.getParam("ContainerConfigOption");
        categories_ = (List<SelectItemCategory>) param.getMapGroovyObject(context);
        if (categories_ == null)
            return;
        setSelectedCategory(categories_.get(0));
View Full Code Here

        public void execute(Event<UIPageCreationWizard> event) throws Exception {
            UIPageCreationWizard uiWizard = event.getSource();
            uiWizard.setShowActions(false);
            UIPortalApplication uiPortalApp = uiWizard.getAncestorOfType(UIPortalApplication.class);
            UIWorkingWorkspace uiWorkingWS = uiWizard.getAncestorOfType(UIWorkingWorkspace.class);
            WebuiRequestContext context = Util.getPortalRequestContext();

            if (uiWizard.isSelectedNodeExist()) {
                uiPortalApp.addMessage(new ApplicationMessage("UIPageCreationWizard.msg.NameNotSame", null));
                uiWizard.viewStep(FIRST_STEP);
                uiWizard.updateWizardComponent();
View Full Code Here

            if (uiMaskWorkspace == null || !uiMaskWorkspace.isShow()) {
                return;
            }
            uiMaskWorkspace.setUIComponent(null);
            uiMaskWorkspace.setWindowSize(-1, -1);
            WebuiRequestContext rContext = event.getRequestContext();
            rContext.getJavascriptManager().require("SHARED/uiMaskWorkspace", "maskWS")
                    .addScripts("maskWS.hide('" + uiMaskWorkspace.getId() + "');");
            rContext.addUIComponentToUpdateByAjax(uiMaskWorkspace);
        }
View Full Code Here

                prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
                prContext.setFullRender(true);
            }

            UIMaskWorkspace uiMaskWorkspace = uiForm.getParent();
            WebuiRequestContext rContext = event.getRequestContext();
            uiMaskWorkspace.createEvent("Close", Phase.DECODE, rContext).broadcast();
            if (!uiForm.getId().equals("CreatePortal") && uiPortalApp.getModeState() != UIPortalApplication.NORMAL_MODE) {
                rContext.getJavascriptManager().require("SHARED/portalComposer", "portalComposer")
                        .addScripts("portalComposer.toggleSaveButton();");
            }
        }
View Full Code Here

TOP

Related Classes of org.exoplatform.webui.application.WebuiRequestContext

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.