Hi Régis (and others),

We just did a simple D3 integration into our Tapestry 5.4 Beta 6
application and with RequireJS/jQuery/etc being provided by Tapestry now it
seems a pretty simple integration.

For our Java class (with stuff removed to just show invoking the module):

@Import(stylesheet = { "css/large-expenditures.less" } )

public class LargestExpenditures

{

    @Inject

    private JavaScriptSupport javaScriptSupport;


    @Inject

    private ComponentResources resources;


    public void afterRender()

    {

        String url = resources.createEventLink("ajax").toAbsoluteURI();


        javaScriptSupport.require("reports/LargestExpenditures").invoke(
"initialize").with(url);

    }


    JSONObject onAjax()

    {

        JSONObject json = new JSONObject();

        // Build up JSON...

        return json;

    }

}

For src/main/resources/META-INF/modules/reports/LargestExpenditures.coffee,
we just have it import/require the D3 JS, which we stored under
src/main/resources/META-INF/modules/d3 as d3.js and d3.min.js (in case we
need to debug via the non-minified in the future).  The CoffeeScript, again
with stuff removed to show the basics:

define ["jquery", "underscore", "t5/core/ajax", "d3/d3.min"],
    ($, _, ajax, d3) ->
        initialize = (url) ->
            # D3 setup...

            # Invoke T5 AJAX Handler...
            ajax url,
                success: (response) =>
                    # Handle response...

        # Exports
        { initialize }

In your 'initialize' function, have it call all the d3 goodies and fetch
the data, etc.  T5.4 invokes 'initialize' in afterRender().

mrg



On Mon, Jul 7, 2014 at 10:19 AM, Régis Legrand <legrand.re...@gmail.com>
wrote:

> Hi to all,
>
> We (got5) have released a new tapestry module project, tapestry5-d3,
> available here:
> https://github.com/got5/tapestry5-d3
>
> Its aim is to allow to develop tapestry components based on d3js.
> Feel free to give us your advices/remarks.
>
>
> Regards,
> Régis.
>

Reply via email to