Package org.apache.tapestry5.json

Examples of org.apache.tapestry5.json.JSONArray


        {
            JSONObject spec = new JSONObject();

            DateFormatSymbols symbols = new DateFormatSymbols(locale);

            spec.put("months", new JSONArray(symbols.getMonths()));

            StringBuilder days = new StringBuilder();

            String[] weekdays = symbols.getWeekdays();
View Full Code Here


            }
        };

        resources.triggerEvent(EventConstants.PROVIDE_COMPLETIONS, new Object[] { input }, callback);

        JSONArray vector = new JSONArray();

        for(OptionModel optionModel : model.getOptions()) {
      JSONObject jsonObject = new JSONObject();
      jsonObject.put("id", toClient(optionModel.getValue()));
      jsonObject.put("description", optionModel.getLabel());
      vector.put(jsonObject);
        }   
       
        System.out.println(model);

        return new TextStreamResponse("text/html", vector.toString());

    }
View Full Code Here

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

        for (OptionModel selected : selectedOptions)
        {
            Object value = selected.getValue();
            String clientValue = encoder.toClient(value);
            selectedValues.put(clientValue);
        }

        String clientId = getClientId();

        writer.element("Select",
           
                        "multiple","multiple",
                       
                       "id", clientId,
                      
                       "class", CSSClassConstants.INVISIBLE,
                      
                       "name", getControlName());
       
        for(Object object: getSelected())
        {

            OptionModel model = valueToOptionModel.get(object);
           
            writer.element("Option",
               
                            "value",model.getValue(),
                           
                            "selected", "selected");
           
            writer.write(model.getLabel());
            writer.end();

        }
            
        writer.end();
       
        String script = "new Tapestry.DgDpPalette('%s', %s)";
       
    
        JSONArray array = new JSONArray();
        for(OptionModel option : model.getOptions())
        {
          array.put(option.getValue() + "-" + getClientId() + "-option");
        }
       
        javascriptSupport.addScript(script,clientId, array);
    }
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

        return encoder.toClient(value);
    }

    void setupRender()
    {
        addRowTriggers = new JSONArray();

        pushContext();

        iterator = source == null ? Collections.EMPTY_LIST.iterator() : source.iterator();
View Full Code Here

        add(configuration, String.class, JSONArray.class, new Coercion<String, JSONArray>()
        {
            public JSONArray coerce(String input)
            {
                return new JSONArray(input);
            }
        });

        add(configuration, String.class, JSONObject.class, new Coercion<String, JSONObject>()
        {
View Full Code Here

        head.element("meta");
        head.element("script");

        DocumentLinkerImpl linker = new DocumentLinkerImpl(true, "1.2.3", false);

        linker.setInitialization(InitializationPriority.IMMEDIATE, new JSONObject().put("fred", new JSONArray("barney",
                "wilma", "betty")));

        linker.updateDocument(document);

        assertEquals(document.toString(), readFile("pretty_print_initialization.txt"));
View Full Code Here

        JSONObject spec = new JSONObject();

        DateFormatSymbols symbols = new DateFormatSymbols(locale);

        spec.put("months", new JSONArray(symbols.getMonths()));

        StringBuilder days = new StringBuilder();

        String[] weekdays = symbols.getWeekdays();
View Full Code Here

                { F.flow(1, 2, 3), Boolean.class, true },

                { F.flow(1, 2, 3), List.class, Arrays.asList(1, 2, 3) },

                { "[1, true]", JSONArray.class, new JSONArray(1, true) },

                { "{ 'fred': 1, 'barney': 2}", JSONObject.class, new JSONObject().put("fred", 1).put("barney", 2) },

                // TAP5-98:
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.