Package org.apache.tapestry5.services

Examples of org.apache.tapestry5.services.ClientDataSink


        }

        // Let subclasses do more.
        configure(config);

        renderSupport.addInit("autocompleter", new JSONArray(id, menuId, link.toAbsoluteURI(), config));
    }
View Full Code Here


        "class", "t-autocomplete-menu");
        writer.end();

        Link link = resources.createEventLink(EVENT_NAME);

        JSONObject config = new JSONObject();
        config.put("paramName", PARAM_NAME);
        config.put("indicator", loaderId);

        if (resources.isBound("minChars"))
            config.put("minChars", minChars);

        if (resources.isBound("frequency"))
            config.put("frequency", frequency);

        if (resources.isBound("tokens"))
        {
            for (int i = 0; i < tokens.length(); i++)
            {
                config.accumulate("tokens", tokens.substring(i, i + 1));
            }
        }

        // Let subclasses do more.
        configure(config);
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

        Map input = CollectionFactory.newMap();

        input.put("fred", "flintstone");
        input.put("barney", "rubble");

        ClientDataSink sink = encoder.createSink();

        sink.getObjectOutputStream().writeObject(input);

        String clientData = sink.getClientData();

        ObjectInputStream ois = encoder.decodeClientData(clientData);

        Map output = (Map) ois.readObject();
View Full Code Here

    @Test
    public void checks_for_eof() throws Exception
    {
        String[] values = {"fred", "barney", "wilma"};

        ClientDataSink sink = encoder.createSink();

        ObjectOutputStream os = sink.getObjectOutputStream();

        for (String value : values)
            os.writeObject(value);

        os.close();

        String clientData = sink.getClientData();

        ObjectInputStream ois = encoder.decodeClientData(clientData);

        for (int i = 0; i < 3; i++)
        {
View Full Code Here

        if (persistedValues.isEmpty()) return;

        // Otherwise, time to update clientData from persistedValues

        ClientDataSink sink = clientDataEncoder.createSink();

        ObjectOutputStream os = sink.getObjectOutputStream();

        try
        {
            os.writeInt(persistedValues.size());

            for (Map.Entry<Key, Object> e : persistedValues.entrySet())
            {
                os.writeObject(e.getKey());
                os.writeObject(e.getValue());
            }
        }
        catch (Exception ex)
        {
            throw new RuntimeException(ex.getMessage(), ex);
        }
        finally
        {
            InternalUtils.close(os);
        }

        clientData = sink.getClientData();
    }
View Full Code Here

        Map input = CollectionFactory.newMap();

        input.put("fred", "flintstone");
        input.put("barney", "rubble");

        ClientDataSink sink = encoder.createSink();

        sink.getObjectOutputStream().writeObject(input);

        String clientData = sink.getClientData();

        ObjectInputStream ois = encoder.decodeClientData(clientData);

        Map output = (Map) ois.readObject();
View Full Code Here

    @Test
    public void checks_for_eof() throws Exception
    {
        String[] values = { "fred", "barney", "wilma" };

        ClientDataSink sink = encoder.createSink();

        ObjectOutputStream os = sink.getObjectOutputStream();

        for (String value : values)
            os.writeObject(value);

        os.close();

        String clientData = sink.getClientData();

        ObjectInputStream ois = encoder.decodeClientData(clientData);

        for (int i = 0; i < 3; i++)
        {
View Full Code Here

    private void addCombinedScriptLink(Element container, List<String> scripts)
    {
        try
        {
            ClientDataSink dataSink = clientDataEncoder.createSink();

            ObjectOutputStream stream = dataSink.getObjectOutputStream();

            stream.writeInt(scripts.size());

            for (String scriptURL : scripts)
            {
                // Each scriptURL will be prefixed with the context path, which isn't needed to build the combined virtual
                // asset (in fact, it gets in the way).

                stream.writeUTF(scriptURL.substring(contextPathLength));
            }

            String virtualURL = fullAssetPrefix + RequestConstants.VIRTUAL_FOLDER + dataSink.getClientData() + ".js";

            container.element("script", "src", virtualURL);
        }
        catch (IOException ex)
        {
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.services.ClientDataSink

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.