Package org.apache.tapestry5.json

Examples of org.apache.tapestry5.json.JSONObject


        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.toURI());

        jsSupport.addInitializerCall("progressiveDisplay", spec);

        return initial;
    }
View Full Code Here


        F.flow(stackLibraries).each(linkLibrary);
        F.flow(otherLibraries).each(linkLibrary);

        for (InitializationPriority p : InitializationPriority.values())
        {
            JSONObject init = inits.get(p);

            if (init != null)
                linker.setInitialization(p, init);
        }
    }
View Full Code Here

        assert priority != null;
        assert parameter != null;
        assert InternalUtils.isNonBlank(functionName);
        addCoreStackIfNeeded();

        JSONObject init = inits.get(priority);

        if (init == null)
        {
            init = new JSONObject();
            inits.put(priority, init);
        }

        JSONArray invocations = init.has(functionName) ? init.getJSONArray(functionName) : null;

        if (invocations == null)
        {
            invocations = new JSONArray();
            init.put(functionName, invocations);
        }

        invocations.put(parameter);
    }
View Full Code Here

        if (this.zone != null)
        {
            Link link = resources.createEventLink(CHANGE_EVENT);

            JSONObject spec = new JSONObject("selectId", getClientId(), "zoneId", zone, "url", link.toURI());

            javascriptSupport.addInitializerCall("linkSelectToZone", spec);
        }
    }
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").toURI());
        spec.put("formatURL", resources.createEventLink("format").toURI());

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

                boolean hasChildren = !node.isLeaf() && node.getHasChildren();
                boolean expanded = hasChildren && expansionModel.isExpanded(node);

                String clientId = jss.allocateClientId(resources);

                JSONObject spec = new JSONObject("clientId", clientId);

                e.attribute("id", clientId);

                spec.put("leaf", node.isLeaf());

                if (hasChildren)
                {
                    Link expandChildren = resources.createEventLink("expandChildren", node.getId());
                    Link markExpanded = resources.createEventLink("markExpanded", node.getId());
                    Link markCollapsed = resources.createEventLink("markCollapsed", node.getId());

                    spec.put("expandChildrenURL", expandChildren.toString())
                            .put("markExpandedURL", markExpanded.toString())
                            .put("markCollapsedURL", markCollapsed.toString());

                    if (expanded)
                        spec.put("expanded", true);
                } else
                {
                    if (selectionModel != null)
                    {
                        // May need to address this in the future; in other tree implementations I've constructed,
                        // folders are selectable, and selections even propagate up and down the tree.

                        Link selectLeaf = resources.createEventLink("select", node.getId());

                        spec.put("selectURL", selectLeaf.toString());
                        if (selectionModel.isSelected(node))
                        {
                            spec.put("selected", true);
                        }
                    }
                }

                jss.addInitializerCall("treeNode", spec);
View Full Code Here

    Object onMarkExpanded(String nodeId)
    {
        expansionModel.markExpanded(model.getById(nodeId));

        return new JSONObject();
    }
View Full Code Here

    Object onMarkCollapsed(String nodeId)
    {
        expansionModel.markCollapsed(model.getById(nodeId));

        return new JSONObject();
    }
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.