Package org.apache.click

Examples of org.apache.click.Context$ContextStack


     *
     * @param parameters the href parameters
     * @return the HTML href attribute
     */
    protected String getHref(Map parameters) {
        Context context = getContext();
        String uri = ClickUtils.getRequestURI(context.getRequest());

        HtmlStringBuffer buffer =
                new HtmlStringBuffer(uri.length() + (parameters.size() * 20));

        buffer.append(uri);
        if (parameters != null && !parameters.isEmpty()) {
            buffer.append("?");
            Iterator i = parameters.entrySet().iterator();
            while (i.hasNext()) {
                Map.Entry entry = (Map.Entry) i.next();
                String name = entry.getKey().toString();
                String value = entry.getValue().toString();

                buffer.append(name);
                buffer.append("=");
                buffer.append(ClickUtils.encodeUrl(value, context));
                if (i.hasNext()) {
                    buffer.append("&");
                }
            }
        }

        return context.getResponse().encodeURL(buffer.toString());
    }
View Full Code Here


        } else if ("#".equals(getPath())) {
            return getContext().getResponse().encodeURL(getPath());

        } else {
            Context context = getContext();
            return context.getResponse().encodeURL(context.getRequest().getContextPath() + "/" + getPath());
        }
    }
View Full Code Here

     * @param src the new src attribute
     */
    public void setSrc(String src) {
        if (src != null) {
            if (src.charAt(0) == '/') {
                Context context = getContext();
                String contextPath = context.getRequest().getContextPath();

                // Guard against adding duplicate context path
                if (!src.startsWith(contextPath + '/')) {
                    HtmlStringBuffer buffer =
                        new HtmlStringBuffer(contextPath.length() + src.length());
View Full Code Here

    protected static Menu loadRootMenu(AccessController accessController) {
        if (accessController == null) {
            throw new IllegalArgumentException("Null accessController parameter");
        }

        Context context = Context.getThreadLocalContext();

        Menu menu = new Menu("rootMenu");
        menu.setAccessController(accessController);

        ServletContext servletContext = context.getServletContext();
        InputStream inputStream =
            servletContext.getResourceAsStream(DEFAULT_CONFIG_FILE);

        if (inputStream == null) {
            inputStream = ClickUtils.getResourceAsStream("/menu.xml", Menu.class);
View Full Code Here

        }

        // Check if the Context has been set
        if (Context.hasThreadLocalContext()) {

            Context context = Context.getThreadLocalContext();
            ConfigService configService = ClickUtils.getConfigService(context.getServletContext());

            boolean isProductionModes = configService.isProductionMode()
                || configService.isProfileMode();

            if (isProductionModes && ClickUtils.isEnableResourceVersion(context)) {
View Full Code Here

     * to perform the lookup.
     *
     * @return the application LogService instance
     */
    public static LogService getLogService() {
        Context context = Context.getThreadLocalContext();
        ServletContext servletContext = context.getServletContext();
        ConfigService configService = getConfigService(servletContext);
        LogService logService = configService.getLogService();
        return logService;
    }
View Full Code Here

         *
         * @param value the cookie's value
         * @param name the cookie's name
         */
        protected void setCookie(String value, String name) {
            Context context = getContext();
            if (value == null) {
                ClickUtils.setCookie(context.getRequest(), context.getResponse(),
                        name, value, 0, "/");
            } else {
                ClickUtils.setCookie(context.getRequest(), context.getResponse(),
                        name, value, -1, "/");
            }
        }
View Full Code Here

     *
     * @param value the SubmitLink value parameter
     * @return the SubmitLink HTML href attribute
     */
    public String getHref(Object value) {
        Context context = getContext();
        String uri = ClickUtils.getRequestURI(context.getRequest());

        HtmlStringBuffer buffer =
                new HtmlStringBuffer(uri.length() + getName().length() + 40);

        String prefix = getParameterPrefix();

        buffer.append(uri);
        buffer.append("?");
        buffer.append(ACTION_LINK);
        buffer.append("=");
        buffer.append(getName());
        if (value != null) {
            buffer.append("&");
            if (StringUtils.isNotBlank(prefix)) {
                // Value parameter is prefixed when SubmitLink is included
                // inside a Form
                buffer.append(prefix);
            }
            buffer.append(VALUE);
            buffer.append("=");
            buffer.append(ClickUtils.encodeUrl(value, context));
        }

        if (hasParameters()) {
            Iterator i = getParameters().keySet().iterator();
            while (i.hasNext()) {
                String name = i.next().toString();
                if (!name.equals(ACTION_LINK) && !name.equals(VALUE)) {
                    Object paramValue = getParameters().get(name);
                    if (paramValue instanceof String[]) {
                        String[] paramValues = (String[]) paramValue;
                        for (int j = 0; j < paramValues.length; j++) {
                            renderParameter(name, paramValues[j], prefix,
                                buffer, context);
                        }
                    } else {
                        renderParameter(name, paramValue, prefix, buffer,
                            context);
                    }
                }
            }
        }

        return context.getResponse().encodeURL(buffer.toString());
    }
View Full Code Here

    /**
     * This method binds the submitted request value to the SubmitLink's
     * value.
     */
    public void bindRequestValue() {
        Context context = getContext();

        clicked = getName().equals(context.getRequestParameter(ACTION_LINK));

        if (clicked) {
            // SubmitLink parameters are prefixed when included inside a Form
            String prefix = getParameterPrefix();

            HttpServletRequest request = context.getRequest();
            Enumeration paramNames = request.getParameterNames();

            boolean hasParentForm = hasParentForm();

            while (paramNames.hasMoreElements()) {
View Full Code Here

     * @see org.apache.click.Control#getHtmlImports()
     *
     * @return the HTML head import statements for the control
     */
    public String getHtmlImports() {
        Context context = getContext();
        HtmlStringBuffer buffer = new HtmlStringBuffer(400);

        buffer.append(ClickUtils.createHtmlImport(HTML_IMPORTS, context));

        if (isSortable()) {
View Full Code Here

TOP

Related Classes of org.apache.click.Context$ContextStack

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.