Package org.apache.tapestry5.json

Examples of org.apache.tapestry5.json.JSONObject


        });
    }

    public void renderPartialPageMarkup() throws IOException
    {
        renderPartialPageMarkup(new JSONObject());
    }
View Full Code Here


            if (request.isXHR())
            {
                OutputStream os = response.getOutputStream("application/json;charset=UTF-8");

                JSONObject reply = new JSONObject();
                reply.in(InternalConstants.PARTIAL_KEY).put("redirectURL", link.toAbsoluteURI());

                os.write(reply.toCompactString().getBytes("UTF-8"));

                os.close();

                return;
            }
View Full Code Here

    }

    private String buildRequireJSConfig(List<ModuleConfigurationCallback> callbacks)
    {
        // This is the part that can vary from one request to another, based on the capabilities of the client.
        JSONObject config = baseConfig.copy().put("baseUrl", getBaseURL());

        // TAP5-2196: allow changes to the configuration in a per-request basis.
        for (ModuleConfigurationCallback callback : callbacks)
        {
            config = callback.configure(config);
            assert config != null;
        }

        // This part gets written out before any libraries are loaded (including RequireJS).
        return String.format("var require = %s;\n", config.toString(compactJSON));
    }
View Full Code Here

        return String.format("var require = %s;\n", config.toString(compactJSON));
    }

    private JSONObject buildBaseConfig(Map<String, JavaScriptModuleConfiguration> configuration, boolean devMode)
    {
        JSONObject config = new JSONObject();

        // In DevMode, wait up to five minutes for a script, as the developer may be using the debugger.
        if (devMode)
        {
            config.put("waitSeconds", 300);
        }

        for (String name : configuration.keySet())
        {
            JavaScriptModuleConfiguration module = configuration.get(name);
View Full Code Here

        return compressionAnalyzer.isGZipSupported() ? compressedBasePath : basePath;
    }

    private void addModuleToConfig(JSONObject config, String name, JavaScriptModuleConfiguration module)
    {
        JSONObject shimConfig = config.in("shim");

        boolean nestDependencies = false;

        String exports = module.getExports();

        if (exports != null)
        {
            shimConfig.in(name).put("exports", exports);
            nestDependencies = true;
        }

        String initExpression = module.getInitExpression();

        if (initExpression != null)
        {
            String function = String.format("function() { return %s; }", initExpression);
            shimConfig.in(name).put("init", new JSONLiteral(function));
            nestDependencies = true;
        }

        List<String> dependencies = module.getDependencies();

        if (dependencies != null)
        {
            JSONObject container = nestDependencies ? shimConfig.in(name) : shimConfig;
            String key = nestDependencies ? "deps" : name;

            for (String dep : dependencies)
            {
                container.append(key, dep);
            }
        }
    }
View Full Code Here

    @Import(stylesheet="Autocomplete.css")
    void afterRender()
    {
        Link link = resources.createEventLink(EVENT_NAME, context);

        JSONObject spec = new JSONObject("id", field.getClientId(),
                "url", link.toString()).put("minChars", minChars).put("limit", maxSuggestions);

        jsSupport.require("t5/core/autocomplete").with(spec);
    }
View Full Code Here

            }
        }
       
        resources.triggerEvent(EventConstants.PROVIDE_COMPLETIONS, newContext, callback);

        JSONObject reply = new JSONObject();

        reply.put("matches", JSONArray.from(matchesHolder.get()));

        // A JSONObject response is always preferred, as that triggers the whole partial page render pipeline.
        return reply;
    }
View Full Code Here

        return registration;
    }

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

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

        return response;
    }
View Full Code Here

            {
                this.libraryMapping = mapping;
                break;
            }
        }
        JSONObject object = new JSONObject();
        object.put("libraryName", libraryName);
        object.put("rootPackage", libraryMapping.getRootPackage());
       
        final ComponentLibraryInfo info = getInfo();
        if (info != null)
        {
            JSONObject infoJsonObject = new JSONObject();
            putIfNotNull("description", info.getDescription(), infoJsonObject);
            putIfNotNull("homepage", info.getHomepageUrl(), infoJsonObject);
            putIfNotNull("documentationUrl", info.getDocumentationUrl(), infoJsonObject);
            putIfNotNull("javadocUrl", info.getJavadocUrl(), infoJsonObject);
            putIfNotNull("groupId", info.getGroupId(), infoJsonObject);
            putIfNotNull("artifactId", info.getArtifactId(), infoJsonObject);
            putIfNotNull("version", info.getVersion(), infoJsonObject);
            putIfNotNull("sourceBrowseUrl", info.getSourceBrowseUrl(), infoJsonObject);
            putIfNotNull("sourceRootUrl", info.getSourceRootUrl(), infoJsonObject);
            putIfNotNull("issueTrackerUrl", info.getIssueTrackerUrl(), infoJsonObject);
            putIfNotNull("dependencyInfoUrl", info.getDependencyManagementInfoUrl(), infoJsonObject);
           
            if (info.getTags() != null)
            {
                for (String tag : info.getTags())
                {
                    infoJsonObject.accumulate("tags", tag);
                }
            }
           
            object.put("info", infoJsonObject);
           
View Full Code Here

            JSONArray classesJsonArray = new JSONArray();
            for (String logicalName : classes)
            {
                logicalName = logicalName.replace("core/", "");
                final String className = getClassName(logicalName, type, componentClassResolver);
                JSONObject classJsonObject = new JSONObject();
                classJsonObject.put("logicalName", logicalName);
                classJsonObject.put("class", className);
                if (info != null)
                {
                    putIfNotNull("sourceUrl", info.getSourceUrl(className), classJsonObject);
                    putIfNotNull("javadocUrl", info.getJavadocUrl(className), classJsonObject);
                }
                try
                {
                    final Description description = getClass(className);
                    if (description != null)
                    {
                        putIfNotNull("description", description.text(), classJsonObject);
                        if (description.tags().length > 0)
                        {
                            for (String tag : description.tags())
                            {
                                classJsonObject.accumulate("tag", tag);
                            }
                        }
                    }
                }
                catch (ClassNotFoundException e)
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.