Package org.apache.tapestry5.json

Examples of org.apache.tapestry5.json.JSONObject


        "class", "t-autocomplete-menu");
        writer.end();

        Link link = resources.createEventLink(EVENT_NAME);

        JSONObject config = new JSONObject();
        config.put("paramName", PARAM_NAME);
        config.put("indicator", loaderId);

        if (resources.isBound("minChars"))
            config.put("minChars", minChars);

        if (resources.isBound("frequency"))
            config.put("frequency", frequency);

        if (resources.isBound("tokens"))
        {
            for (int i = 0; i < tokens.length(); i++)
            {
                config.accumulate("tokens", tokens.substring(i, i + 1));
            }
        }

        // Let subclasses do more.
        configure(config);
View Full Code Here


     * not formatted correct.
     */
    JSONObject onParse(@RequestParameter(INPUT_PARAMETER)
    String input)
    {
        JSONObject response = new JSONObject();

        try
        {
            Date date = format.parse(input);

            response.put(RESULT, date.getTime());
        }
        catch (ParseException ex)
        {
            response.put(ERROR, ex.getMessage());
        }

        return response;
    }
View Full Code Here

     * the result.
     */
    JSONObject onFormat(@RequestParameter(INPUT_PARAMETER)
    String input)
    {
        JSONObject response = new JSONObject();

        try
        {
            long millis = Long.parseLong(input);

            Date date = new Date(millis);

            response.put(RESULT, format.format(date));
        }
        catch (NumberFormatException ex)
        {
            response.put(ERROR, ex.getMessage());
        }

        return response;
    }
View Full Code Here

        "src", icon.toClientURL(),

        "alt", "[Show]");
        writer.end(); // img

        JSONObject spec = new JSONObject();

        spec.put("field", clientId);
        spec.put("parseURL", resources.createEventLink("parse").toAbsoluteURI());
        spec.put("formatURL", resources.createEventLink("format").toAbsoluteURI());

        support.addInitializerCall("dateField", spec);
    }
View Full Code Here

        this.environment = environment;
    }

    public void addZone(String clientId, String showFunctionName, String updateFunctionName)
    {
        JSONObject spec = new JSONObject("element", clientId);

        addFunction(spec, "show", showFunctionName);
        addFunction(spec, "update", updateFunctionName);

        FormSupport formSupport = environment.peek(FormSupport.class);

        if (formSupport != null)
        {
            JSONObject parameters = new JSONObject(RequestConstants.FORM_CLIENTID_PARAMETER, formSupport.getClientId(),
                    RequestConstants.FORM_COMPONENTID_PARAMETER, formSupport.getFormComponentId());
            spec.put("parameters", parameters);
        }

        javascriptSupport.addInitializerCall("zone", spec);
View Full Code Here

            spec.put(key, showFunctionName.toLowerCase());
    }

    public void linkZone(String linkId, String elementId, Link eventLink)
    {
        JSONObject spec = new JSONObject("linkId", linkId, "zoneId", elementId, "url", eventLink.toAbsoluteURI());

        javascriptSupport.addInitializerCall("linkZone", spec);
    }
View Full Code Here

        addFormFragment(clientId, false, showFunctionName, hideFunctionName);
    }

    public void addFormFragment(String clientId, boolean alwaysSubmit, String showFunctionName, String hideFunctionName)
    {
        JSONObject spec = new JSONObject("element", clientId);

        addFunction(spec, "show", showFunctionName);
        addFunction(spec, "hide", hideFunctionName);

        if (alwaysSubmit)
            spec.put("alwaysSubmit", true);

        javascriptSupport.addInitializerCall("formFragment", spec);
    }
View Full Code Here

        javascriptSupport.addInitializerCall("formFragment", spec);
    }

    public void addFormInjector(String clientId, Link link, InsertPosition insertPosition, String showFunctionName)
    {
        JSONObject spec = new JSONObject("element", clientId, "url", link.toAbsoluteURI());

        if (insertPosition == InsertPosition.BELOW)
            spec.put("below", true);

        addFunction(spec, "show", showFunctionName);

        // Always has at least two properties.
View Full Code Here

        e.addClassName("t-zone");

        Link link = resources.createEventLink(EventConstants.ACTION, context);

        JSONObject spec = new JSONObject();

        if (InternalUtils.isNonBlank(update))
            spec.put("update", update.toLowerCase());

        spec.put("element", clientId);
        spec.put("url", link.toAbsoluteURI());

        renderSupport.addInit("progressiveDisplay", spec);

        return initial;
    }
View Full Code Here

        ContentType contentType = new ContentType(InternalConstants.JSON_MIME_TYPE, outputEncoding);

        MarkupWriter writer = factory.newPartialMarkupWriter(pageContentType);

        JSONObject reply = new JSONObject();

        // ... and here, the pipeline eventually reaches the PRQ to let it render the root render command.

        partialMarkupRenderer.renderMarkup(writer, reply);

        PrintWriter pw = response.getPrintWriter(contentType.toString());

        if (compactJSON)
            reply.print(pw);
        else
            reply.prettyPrint(pw);

        pw.close();
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.json.JSONObject

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.