Skip to main content

Posts

Showing posts with the label JavaScript

Play Framework with RequireJS and YUI

I've concluded an older post with a promise to investigate the issues of integration of Play Framework with RequireJS and YUI . Finally I've got some time to resolve all issues so I'm going to showcase a working sample multi-page project in this article. Sample project. Issues. Sample project Play Framework offers a nice official tutorial for RequireJS-support . However, it appeared that not all RequireJS features are fully supported by Play Framework yet (see below in Issues section). So it required some tuning before everything started working. I've published a sample project on github so you're welcome to look into it. Some of the issues that I faced are described in the section below. Here I'm going to show a couple of screenshots of the sample application. This is how one page of the application looks like: Below is the screenshot of the network tab of the Google Chrome developer tools showing all page resources in the production mode. You c...

YUI Cross-Domain transactions without Flash

Recently I've worked on the application making cross-domain ajax calls with YUI . While YUI offers io-xdr module for making cross-domain requests via Flash transport , it seems to me quite unnatural as it leads to unnecessary complexity. Moreover, io-xdr was marked deprecated several months ago without explicit mentioning the preferred way. An obvious alternative is using XMLHttpRequest as a transport for cross-domain requests. However, it has some limitations and undocumented pitfalls that I'd like to review in this post. Cross-Domain request using XMLHttpRequest. YUI IO Utility. YUI Datasource IO. Cross-Domain request using XMLHttpRequest Cross-domain requests can be sent using a common XMLHttpRequest object. The only requirement is that the server must be configured to properly handle those requests. Specifically, it should set the Access-Control-Allow-Origin response header according to Cross-Origin Resource Sharing specification . For more details and good tuto...

My first Play Framework application

My first Play Framework application has recently gone live. This time it was the Java version of the framework, next time I may move on to Scala finally. Nevertheless, I've learned a lot and will try to share some knowledge here. The application is meant for managing the data stored in the Dydra graph database ( RDF & SPARQL ). It's a thick client application meaning that the data loading happens in the client JavaScript layer via JSON requests, while routing and user authentication is done by means of Play Framework. Also I've made use of the RequireJS support in Play Framework for dynamic JS module loading. For the UI I've chosen a well-known YUI library . More details are following below. Application architecture. User model and authentication. Dydra database layer and SPARQL client. JavaScript logic and YUI. RequireJS module loading. Application architecture As any web application, this one can be described in terms of MVC pattern . Play Framewor...

Using JavaScript hashCode to enable Cocoon caching of POST requests

I've just faced an issue with the Cocoon caching related to POST requests. Let me describe the use case here. We use a custom XQueryGenerator to execute XQuery code over Sedna XML Database and then process the XML results in the Cocoon pipeline. For the sake of performance, I configured the pipeline caching based on the expiration timeout of 60 seconds for all XQuery invocations: <map:pipeline id="cached-services" type="expires" internal-only="true"> <map:parameter name="cache-expires" value="60"/> <map:parameter name="cache-key" value="{request:sitemapURI}?{request:queryString}"/> <map:match pattern="cached-internal-xquery/**"> <map:generate src="cocoon:/xquery-macro/{1}" type="queryStringXquery"> <map:parameter name="contextPath" value="{request:contextPath}"/> </map:generate> ...