Package org.apache.tapestry.json

Examples of org.apache.tapestry.json.JSONObject


        return _registration;
    }

    Object onActionFromJSON()
    {
        JSONObject response = new JSONObject();

        response.put("content", "Directly coded JSON content");

        return response;
    }
View Full Code Here


    @Test
    public void add_script_and_update()
    {
        PartialRenderPageRenderSupport prs = new PartialRenderPageRenderSupport("");

        JSONObject reply = new JSONObject();


        prs.update(reply);


        assertEquals(reply.toString(), "{}");


        prs.addScript("x = %d;", 10);

        prs.update(reply);

        assertEquals(reply.getString("script"), "x = 10;");
    }
View Full Code Here

    @Test
    public void add_links()
    {
        PageRenderSupport support = mockPageRenderSupport();

        JSONObject template = new JSONObject("{ zones: [], links: [['client1', 'zone1'], ['client2', 'zone2']] }");

        support.addScript(ZONE_INITIALIZER_STRING, template.getJSONArray("zones"), template.getJSONArray("links"));

        replay();

        ClientBehaviorSupportImpl setup = new ClientBehaviorSupportImpl(support);
View Full Code Here

    @Test
    public void add_zones()
    {
        PageRenderSupport support = mockPageRenderSupport();

        JSONObject template = new JSONObject("{ zones: [ {div:'client1'}, {div:'client2'} ], links:[] }");

        support.addScript(ZONE_INITIALIZER_STRING, template.getJSONArray("zones"), template.getJSONArray("links"));

        replay();

        ClientBehaviorSupportImpl setup = new ClientBehaviorSupportImpl(support);
View Full Code Here

    public void zones_with_functions()
    {
        PageRenderSupport support = mockPageRenderSupport();


        JSONObject template = new JSONObject(
                "{ zones: [ {div:'client1', show:'showme'}, {div:'client2', update:'updateme'} ], links:[] }");

        support.addScript(ZONE_INITIALIZER_STRING, template.getJSONArray("zones"), template.getJSONArray("links"));

        replay();

        ClientBehaviorSupportImpl setup = new ClientBehaviorSupportImpl(support);
View Full Code Here

    @Test
    public void zone_function_names_are_converted_to_lower_case()
    {
        PageRenderSupport support = mockPageRenderSupport();

        JSONObject template = new JSONObject(
                "{ zones: [ {div:'client1', show:'showme'}, {div:'client2', update:'updateme'} ], links:[] }");

        support.addScript(ZONE_INITIALIZER_STRING, template.getJSONArray("zones"), template.getJSONArray("links"));

        replay();

        ClientBehaviorSupportImpl setup = new ClientBehaviorSupportImpl(support);
View Full Code Here

    }

    public void renderContribution(IMarkupWriter writer, IRequestCycle cycle,
            FormComponentContributorContext context, IFormComponent field)
    {
        JSONObject profile = context.getProfile();
       
        if (!profile.has(ValidationConstants.CONSTRAINTS)) {
            profile.put(ValidationConstants.CONSTRAINTS, new JSONObject());
        }
        JSONObject cons = profile.getJSONObject(ValidationConstants.CONSTRAINTS);
       
        // TODO: Should find some way to provide this globally and cache.
        DecimalFormatSymbols symbols = new DecimalFormatSymbols(context.getLocale());
       
        accumulateProperty(cons, field.getClientId(),
View Full Code Here

    public void renderContribution(IMarkupWriter writer, IRequestCycle cycle,
            FormComponentContributorContext context, IFormComponent field)
    {
        context.addInitializationScript(field, "dojo.require(\"dojo.validate.web\");");
       
        JSONObject profile = context.getProfile();
       
        if (!profile.has(ValidationConstants.CONSTRAINTS)) {
            profile.put(ValidationConstants.CONSTRAINTS, new JSONObject());
        }
        JSONObject cons = profile.getJSONObject(ValidationConstants.CONSTRAINTS);
       
        accumulateProperty(cons, field.getClientId(),
                new JSONLiteral("[dojo.validate.isEmailAddress,false,true]"));
       
        accumulateProfileProperty(field, profile,
View Full Code Here

    public void renderContribution(IMarkupWriter writer, IRequestCycle cycle,
            FormComponentContributorContext context, IFormComponent field)
    {
        String pattern = _matcher.getEscapedPatternString(_pattern);
       
        JSONObject profile = context.getProfile();
       
        if (!profile.has(ValidationConstants.CONSTRAINTS)) {
            profile.put(ValidationConstants.CONSTRAINTS, new JSONObject());
        }
        JSONObject cons = profile.getJSONObject(ValidationConstants.CONSTRAINTS);
       
        accumulateProperty(cons, field.getClientId(),
                new JSONLiteral("[tapestry.form.validation.isValidPattern,\""
                        + pattern + "\"]"));
       
View Full Code Here

    }

    public void renderContribution(IMarkupWriter writer, IRequestCycle cycle,
            FormComponentContributorContext context, IFormComponent field)
    {
        JSONObject profile = context.getProfile();
       
        if (!profile.has(ValidationConstants.CONSTRAINTS)) {
            profile.put(ValidationConstants.CONSTRAINTS, new JSONObject());
        }
        JSONObject cons = profile.getJSONObject(ValidationConstants.CONSTRAINTS);
       
        accumulateProperty(cons, field.getClientId(),
                new JSONLiteral("[dojo.validate.isText,{"
                        + "maxlength:" + _maxLength + "}]"));
       
View Full Code Here

TOP

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