Package org.apache.click

Examples of org.apache.click.Context


    /**
     * 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


         *
         * @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 ActionLink value parameter
     * @return the ActionLink 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);

        buffer.append(uri);
        buffer.append("?");
        buffer.append(ACTION_LINK);
        buffer.append("=");
        buffer.append(getName());
        if (value != null) {
            buffer.append("&");
            buffer.append(VALUE);
            buffer.append("=");
            buffer.append(ClickUtils.encodeUrl(value, context));
        }

        if (hasParameters()) {
            for (String paramName : getParameters().keySet()) {
                if (!paramName.equals(ACTION_LINK) && !paramName.equals(VALUE)) {
                    Object paramValue = getParameters().get(paramName);

                    // Check for multivalued parameter
                    if (paramValue instanceof String[]) {
                        String[] paramValues = (String[]) paramValue;
                        for (int j = 0; j < paramValues.length; j++) {
                            buffer.append("&amp;");
                            buffer.append(paramName);
                            buffer.append("=");
                            buffer.append(ClickUtils.encodeUrl(paramValues[j],
                                context));
                        }
                    } else {
                        if (paramValue != null) {
                            buffer.append("&amp;");
                            buffer.append(paramName);
                            buffer.append("=");
                            buffer.append(ClickUtils.encodeUrl(paramValue,
                                                               context));
                        }
                    }
                }
            }
        }

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

     * This method binds the submitted request value to the ActionLink's
     * value.
     */
    @Override
    public void bindRequestValue() {
        Context context = getContext();
        if (context.isMultipartRequest()) {
            return;
        }

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

        if (clicked) {
            bindRequestParameters(context);
        }
    }
View Full Code Here

     * @return true to continue Page event processing or false otherwise
     */
    @Override
    public boolean onProcess() {
        if (isDisabled()) {
            Context context = getContext();

            // Switch off disabled property if control has incoming request
            // parameter. Normally this means the field was enabled via JS
            if (context.hasRequestParameter(getName())) {
                setDisabled(false);
            } else {
                // If field is disabled skip process event
                return true;
            }
View Full Code Here

    public List<Element> getHeadElements() {

        if (headElements == null) {
            headElements = super.getHeadElements();

            Context context = getContext();
            String versionIndicator = ClickUtils.getResourceVersionIndicator(context);

            headElements.add(new CssImport("/click/tree/tree.css", versionIndicator));

            if (isJavascriptEnabled()) {
View Full Code Here

     * <p/>
     * <b>Note</b> Tree only stores a value in the Session when JavaScript
     * is enabled and set to {@link #JAVASCRIPT_SESSION_POLICY}.
     */
    public void cleanupSession() {
        Context context = getContext();
        if (context.hasSession()) {
            context.getSession().removeAttribute(SessionHandler.JS_HANDLER_SESSION_KEY);
        }
    }
View Full Code Here

     *
     * @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("&amp;");
                }
            }
        }

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

    public List<Element> getHeadElements() {

        if (headElements == null) {
            headElements = super.getHeadElements();

            Context context = getContext();
            String versionIndicator = ClickUtils.getResourceVersionIndicator(context);

            headElements.add(new CssImport("/click/TabbedPanel.css", versionIndicator));
        }
View Full Code Here

     *
     * @see Page#onInit()
     */
    public void onInit() {
        addModel("mode", getMode());
        Context context = getContext();
        if (getError() != null) {
            ErrorReport errorReport =
                new ErrorReport(error,
                                getPageClass(),
                                false,
                                context.getRequest(),
                                context.getServletContext());

            addModel("errorReport", errorReport);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.click.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.