Package org.apache.tapestry5.json

Examples of org.apache.tapestry5.json.JSONArray


        javascriptSupport.addInitializerCall(functionName, parameter);
    }

    public void addInit(String functionName, String... parameters)
    {
        JSONArray array = new JSONArray();

        for (String parameter : parameters)
        {
            array.put(parameter);
        }

        addInit(functionName, array);
    }
View Full Code Here


    private void addInitFunctionInvocation(String functionName, Object parameters)
    {
        assert InternalUtils.isNonBlank(functionName);
        assert parameters != null;

        JSONArray list = new JSONArray().put(parameters);
        JSONObject wrapper = new JSONObject().put(functionName, list);

        addScript("Tapestry.init(%s);", wrapper);
    }
View Full Code Here

        trainForEmptyCoreStack(linker, stackSource, pathConstructor);

        JSONObject spec1 = new JSONObject("clientId", "chuck");
        JSONObject spec2 = new JSONObject("clientId", "fred");

        JSONObject aggregated = new JSONObject().put("setup", new JSONArray(spec1, spec2));

        linker.setInitialization(InitializationPriority.IMMEDIATE, aggregated);

        replay();
View Full Code Here

        DocumentLinker linker = mockDocumentLinker();
        JavaScriptStackSource stackSource = mockJavaScriptStackSource();
        JavaScriptStackPathConstructor pathConstructor = mockJavaScriptStackPathConstructor();
        trainForEmptyCoreStack(linker, stackSource, pathConstructor);

        JSONObject aggregated = new JSONObject().put("setup", new JSONArray("chuck", "charley"));

        linker.setInitialization(InitializationPriority.IMMEDIATE, aggregated);

        replay();
View Full Code Here

        DocumentLinker linker = mockDocumentLinker();
        JavaScriptStackSource stackSource = mockJavaScriptStackSource();
        JavaScriptStackPathConstructor pathConstructor = mockJavaScriptStackPathConstructor();
        trainForEmptyCoreStack(linker, stackSource, pathConstructor);

        JSONObject aggregated = new JSONObject().put("setup", new JSONArray().put("chuck"));

        linker.setInitialization(InitializationPriority.NORMAL, aggregated);

        replay();
View Full Code Here

        linker.setInitialization(InitializationPriority.NORMAL, spec2);
        linker.setInitialization(InitializationPriority.IMMEDIATE, spec1);

        linker.commit(reply);

        JSONObject expected = new JSONObject().put("inits", new JSONArray(spec1, spec2));

        assertEquals(reply, expected);
    }
View Full Code Here

    @Test
    public void add_multiple_string_init_parameters()
    {
        JavaScriptSupport js = mockJavaScriptSupport();

        JSONObject spec = new JSONObject().put("foo", new JSONArray().put(new JSONArray("fred", "barney")));

        js.addScript("Tapestry.init(%s);", spec);

        replay();
View Full Code Here

    {
        String parameterValue = request.getParameter(elementName + "-values");

        this.tracker.recordInput(this, parameterValue);

        JSONArray values = new JSONArray(parameterValue);

        // Use a couple of local variables to cut down on access via bindings

        List<Object> selected = this.selected;

        if (selected == null)
            selected = newList();
        else
            selected.clear();

        ValueEncoder encoder = this.encoder;

        int count = values.length();
        for (int i = 0; i < count; i++)
        {
            String value = values.getString(i);

            Object objectValue = encoder.toValue(value);

            selected.add(objectValue);
        }
View Full Code Here

            writer.attributes("disabled", "disabled");
    }

    void beginRender(MarkupWriter writer)
    {
        JSONArray selectedValues = new JSONArray();

        for (OptionModel selected : selectedOptions)
        {

            Object value = selected.getValue();
            String clientValue = encoder.toClient(value);

            selectedValues.put(clientValue);
        }

        JSONArray naturalOrder = new JSONArray();

        for (String value : this.naturalOrder)
        {
            naturalOrder.put(value);
        }

        String clientId = getClientId();

        javascriptSupport.addScript("new Tapestry.Palette('%s', %s, %s);", clientId, reorder, naturalOrder
                .toString(compactJSON));

        writer.element("input", "type", "hidden", "id", clientId + "-values", "name", getControlName() + "-values",
                "value", selectedValues);
        writer.end();
View Full Code Here

    public void addValidation(Field field, String validationName, String message, Object constraint)
    {
        String fieldId = field.getClientId();

        JSONArray specs;

        if (validations.has(fieldId))
            specs = validations.getJSONArray(fieldId);
        else
        {
            specs = new JSONArray();
            validations.put(fieldId, specs);
        }

        JSONArray thisSpec = new JSONArray();

        thisSpec.put(validationName);
        thisSpec.put(message);

        if (constraint != null)
            thisSpec.put(constraint);

        specs.put(thisSpec);
    }
View Full Code Here

TOP

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

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.