Package org.apache.velocity.context

Examples of org.apache.velocity.context.Context


   
    public void doView(RenderRequest request, RenderResponse response)
            throws PortletException, IOException
    {
        response.setContentType("text/html");
        Context context = getContext(request);

        Object userinfoObject = this
                .receiveRenderMessage(request, MSG_USERINFO);
        context.put(CTX_USERINFO, userinfoObject);
        context.put(CTX_FIELDS, getListOfNonSpecialFormKeys());
        context.put(CTX_OPTIONALS, getOptionalMap());
        context.put(CTX_MESSAGE, consumeRenderMessage(request, MSG_MESSAGE));
        String guid = request.getParameter("newUserGUID");
        if (guid != null)
        {
            // we'll ignore the possibility of an invalid guid for now.

            // NOTE this would be a good place to put the actual registration if
            // that's the process you want to have happen.

            ResourceBundle resource = getPortletConfig().getResourceBundle(
                    request.getLocale());
            context.put(CTX_REGED_USER_MSG, resource
                    .getString("success.login_above"));
        } else
        {
            // not a returning url, but perhaps we just got redirected from the
            // form ?
            // if this is non-null, then we know that we registered
            context.put(CTX_REGED_USER_MSG, consumeRenderMessage(request,
                    MSG_REGED_USER_MSG));
        }
        // next two control the existence of some of the fields in the form
        if (this.optionForceEmailAsUsername)
        {
            context.put(CTX_OPTION_USE_EMAIL_AS_USERNAME, "TRUE");
        }
        if (this.optionForceGeneratedPasswords)
        {
            context.put(CTX_OPTION_GENERATE_PASSWORDS, "TRUE");
        }

        super.doView(request, response);
    }
View Full Code Here


    throws PortletException, IOException
    {
        String selectedSiteName = (String)PortletMessaging.receive(request, "SSOChangePassword", "selectedName");
        if (selectedSiteName != null)
        {       
            Context context = this.getContext(request);
            context.put("currentName", selectedSiteName)
            context.put("currentUrl", (String)PortletMessaging.receive(request, "SSOChangePassword", "selectedUrl"));
            String ssoUsername = (String)PortletMessaging.receive(request, "SSOChangePassword", "ssoUsername");
            context.put("ssoUsername", ssoUsername);
        }
        StatusMessage msg = (StatusMessage)PortletMessaging.consume(request, "SSOChangePassword", "status");
        if (msg != null)
        {
            this.getContext(request).put("statusMsg", msg);           
View Full Code Here

        String change = (String)PortletMessaging.consume(request, "site", "change");
        if (change != null)
        {
            this.clearBrowserIterator(request);
        }
        Context context = this.getContext(request);       
        String selectedSite = (String)PortletMessaging.receive(request, "site", "selectedName");
        if (selectedSite != null)
        {       
            context.put("currentSite", selectedSite);
            String title = this.getTitle(request);
            if (title != null)
            {
                int pos = title.indexOf("-");
                if (pos > 1)
                {
                    title = title.substring(0, pos) + "- " + selectedSite;
                }
                else
                    title = title + " - "  + selectedSite;
            }
            else
                title = selectedSite;
            response.setTitle(title);
        }       
       
        // get relative link, TOremoveCredentialsForSiteDO: encapsulate Jetspeed links access into component
        String userChooser = SecurityUtil.getAbsoluteUrl(request, "/Administrative/choosers/users.psml");
        String groupChooser = SecurityUtil.getAbsoluteUrl(request, "/Administrative/choosers/groups.psml");
       
        context.put("userChooser", userChooser);
        context.put("groupChooser", groupChooser);
       
        StatusMessage msg = (StatusMessage)PortletMessaging.consume(request, "SSODetails", "status");
        if (msg != null)
        {
            this.getContext(request).put("statusMsg", msg);           
View Full Code Here

    throws PortletException, IOException
    {
        String selectedSiteName = (String)PortletMessaging.receive(request, "site", "selectedName");
        if (selectedSiteName != null)
        {       
            Context context = this.getContext(request);
            context.put("currentName", selectedSiteName)
            context.put("currentUrl", (String)PortletMessaging.receive(request, "site", "selectedUrl"));
           
            String realm = (String)PortletMessaging.receive(request, "site", "realm");
            context.put("currentRealm", realm)
            String userField = (String)PortletMessaging.receive(request, "site", "idField");
            context.put("currentFFID", userField)
            String pwdFiled = (String)PortletMessaging.receive(request, "site", "pwdField");
            context.put("currentFFPWD", pwdFiled);

           
           
           
        }
View Full Code Here

    /* (non-Javadoc)
     * @see org.apache.portals.bridges.velocity.GenericVelocityPortlet#doEdit(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
     */
    public void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException
    {
        Context context = getContext(request);
        PortletPreferences prefs = request.getPreferences();
        String cats = prefs.getValue("Categories", null);
        List categories = new ArrayList();
        if (cats != null)
        {
            StringTokenizer catTokenizer = new StringTokenizer(cats, ",");
            while (catTokenizer.hasMoreTokens())
            {
                String name = catTokenizer.nextToken().trim();
                CategoryInfo cat = new CategoryInfo(name);
                String keys = prefs.getValue("Keywords:" + name, "");
                cat.setKeywords(keys);
                categories.add(cat);
            }
        }
        context.put("categories", categories);
        context.put("Rows", prefs.getValue("Rows", "5"));
        context.put("Columns", prefs.getValue("Columns", "4"));
        processPage(request);
        super.doEdit(request, response);
    }
View Full Code Here

    public void doView(RenderRequest request, RenderResponse response)
            throws PortletException, IOException
    {
        response.setContentType("text/html");
        Context context = getContext(request);
        String email = request.getParameter(RP_EMAIL_ADDRESS);
        String guid = request.getParameter("guid");

        ResourceBundle resource = getPortletConfig().getResourceBundle(request.getLocale());

        if (guid != null)
        {
            if(isValidGUID(guid))
            {
                try
                {
                    updatePasswordFromGUID(guid);
                    context
                            .put(CTX_CHANGEDPW_MSG, resource.getString("forgotten.successful_pw_update"));
                } catch (Exception e)
                {
                    context.put(CTX_MESSAGE,resource.getString("forgotten.unable_to_update_pw"));
                }
            } else {
                // invalid GUID
                context
                .put(CTX_CHANGEDPW_MSG,resource.getString("forgotten.password_update_link_invalid"));
            }
        } else {
            // might be returning from initial request
            context.put(CTX_CHANGEDPW_MSG,consumeRenderMessage(request, MSG_CHANGEDPW_MSG));
        }
        context.put(CTX_EMAIL_ADDRESS, email);
        context.put(CTX_MESSAGE, consumeRenderMessage(request, MSG_MESSAGE));
        super.doView(request, response);
    }
View Full Code Here

    }

    public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
    {
        List outOfService = createList();
        Context context = getContext(request);
        context.put("outOfService", outOfService);
        context.put("count", new Integer(outOfService.size()));
        super.doView(request, response);
    }
View Full Code Here

    }

    public void doView(RenderRequest request, RenderResponse response)
            throws PortletException, IOException
    {
        Context velocityContext = getContext(request);
        PortletSession session = request.getPortletSession();

        StatisticsQueryCriteria sqc = (StatisticsQueryCriteria) session
                .getAttribute(SESSION_CRITERIA);
        AggregateStatistics stats = (AggregateStatistics) session
                .getAttribute(SESSION_RESULTS);
        if (stats == null)
        {
            if (sqc == null)
            {
                // if we get here, we're on the first startup.
                sqc = statistics.createStatisticsQueryCriteria();
                sqc.setQueryType(PortalStatistics.QUERY_TYPE_PORTLET);
                sqc.setTimePeriod("1");
                sqc.setListsize("5");
                sqc.setSorttype("count");
                sqc.setSortorder("desc");
                session.setAttribute(SESSION_CRITERIA, sqc);

                try
                {
                    statistics.forceFlush();
                    stats = statistics.queryStatistics(sqc);
                } catch (InvalidCriteriaException e)
                {
                    logger.warn("unable to complete a statistics query ", e);
                }
                session.setAttribute(SESSION_RESULTS, stats);

            }
        }
        velocityContext.put(SESSION_TOTALSESSIONS, ""
                + statistics.getNumberOfLoggedInUsers());
        velocityContext.put(SESSION_RESULTS, stats);
        velocityContext.put(SESSION_CRITERIA, sqc);
        super.doView(request, response);
    }
View Full Code Here

      File thisOutputDirectory,
      File thisDoNotReplaceDirectory, String[] excludes,
      String packageDirectory, String key, String value) throws MojoExecutionException {
    String outputName = templateName.replaceFirst("\\.java\\.t$",
        ".java");
    Context vc = new VelocityContext();
    if (key != null) {
      String keyCap = key.toUpperCase().charAt(0) + key.substring(1);
      outputName = outputName.replaceAll("KeyType", keyCap);
      vc.put("keyType", key);
      vc.put("keyTypeCap", keyCap);
      vc.put("keyObjectType", typeToObjectTypeMap.get(key));
      boolean floating = "float".equals(key) || "double".equals(key);
      vc.put("keyTypeFloating", floating ? "true" : "false");
    }
    if (value != null) {
      String valueCap = value.toUpperCase().charAt(0) + value.substring(1);
      outputName = outputName.replaceAll("ValueType", valueCap);
      vc.put("valueType", value);
      vc.put("valueTypeCap", valueCap);
      vc.put("valueObjectType", typeToObjectTypeMap.get(value));
      boolean floating = "float".equals(value) || "double".equals(value);
      vc.put("valueTypeFloating", floating ? "true" : "false");

    }
    File outputFile = new File(thisOutputDirectory, outputName);
    if (thisDoNotReplaceDirectory != null) {
      File dnrf = new File(thisDoNotReplaceDirectory, outputName);
View Full Code Here

      File thisOutputDirectory,
      File thisDoNotReplaceDirectory, String[] excludes,
      String packageDirectory, String key, String value) throws MojoExecutionException {
    String outputName = templateName.replaceFirst("\\.java\\.t$",
        ".java");
    Context vc = new VelocityContext();
    if (key != null) {
      String keyCap = key.toUpperCase().charAt(0) + key.substring(1);
      outputName = outputName.replaceAll("KeyType", keyCap);
      vc.put("keyType", key);
      vc.put("keyTypeCap", keyCap);
      vc.put("keyObjectType", typeToObjectTypeMap.get(key));
      boolean floating = "float".equals(key) || "double".equals(key);
      vc.put("keyTypeFloating", floating ? "true" : "false");
    }
    if (value != null) {
      String valueCap = value.toUpperCase().charAt(0) + value.substring(1);
      outputName = outputName.replaceAll("ValueType", valueCap);
      vc.put("valueType", value);
      vc.put("valueTypeCap", valueCap);
      vc.put("valueObjectType", typeToObjectTypeMap.get(value));
      boolean floating = "float".equals(value) || "double".equals(value);
      vc.put("valueTypeFloating", floating ? "true" : "false");

    }
    File outputFile = new File(thisOutputDirectory, outputName);
    if (thisDoNotReplaceDirectory != null) {
      File dnrf = new File(thisDoNotReplaceDirectory, outputName);
View Full Code Here

TOP

Related Classes of org.apache.velocity.context.Context

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.