Saturday, November 26, 2005

Tagneto 0.3.1 Released

Tagneto 0.3.1 was released yesterday. It is available for download from the SourceForge site.

Release Notes:
  • Added source examples to website/documentation for ease of reference.
  • Dynamic Script Request API document and SvrScript implementation of the API.
  • Broke up Srvr.js into 3 files: SvrScript.js, SvrReq.js and SvrFrame.js.
  • No more warnings when building in Eclipse. Most warnings were from autogenerated JAXB files.
  • Fixed tagneto/src/test/RunTest.bat and RunTest.sh.
  • Added ant lib to make it easy to build tagneto directly from cvs source checkout in Eclipse.
  • Added notes on how to build Tagneto on the Where page.

Monday, November 21, 2005

Dynamic Script Request API

I updated the Tagneto website with a document describing the Dynamic Script Request API, and Tagneto's support of it through the Srvr.js library. The goal of the API is to make it possible to reliably use dynamically added SCRIPT SRC elements to load data and UI. It also makes it possible to send up more data to the server via multipart requests. This should make it easier to access web APIs across server domains (something XMLHTTPRequest normally cannot do). The limitation being the cross server web API must return JavaScript.

This document is another revision of the API first described in this post.

The changes to Srvr.js to support this API are not in the 0.3.0 release of Tagneto. Either grab from CVS or a later version of Tagneto (if available).

Wednesday, November 16, 2005

Using On-Demand JavaScript for Everything

I really like using On-Demand JavaScript (dynamically creating a SCRIPT tag and attaching to the HEAD) for loading new data or UI, particularly since it gets around the domain restrictions of XMLHTTPRequest. There is also no need to deal with messy XML to JavaScript transformations.

The challenges:
  1. GET URL length restrictions.
  2. Data has to be JavaScript.
  3. Knowing when script load is complete.
Tagneto can help deal with these issues. The approach and issues are slightly different for retrieving UI (View) vs. Data (Model):

On Demand UI

1. GET URL length restrictions

This normally shouldn't be an issue for retrieving UI, particularly if the UI does not depend on particular request or user data (see Why document). If it is an issue, please see the approach mapped out below in On Demand Data.

2. Data has to be JavaScript

It is particularly tricky to encode HTML as JavaScript. Tagneto's ctrl: tags make this easier. An example, to create a JavaScript function that returns an HTML string based on some input parameters.

Sample.js:
<ctrl:function name="getHelloWorld" parameters="name, planet">
<b>Hello &ctrl:out-value:planet;, this is <ctrl:out value="name/>.</b>
</ctrl:function>
After running this file through Tagneto's view assembly tool, Sample.js will look something like this (the actual result is a little more complex and efficient than string concatenations::
function getHelloWorld(name, planet)
{
return '<b>Hello ' + planet + ', this is ' + name + .</b>';
}

Now Sample.js is ready to be dynamically included in the page.

3. Knowing when script load is complete

(Update 1/21/2006: the original post referred to a Srvr JS library. That library was renamed/changed and now is the Dsr library. This post was changed to reference the new library.)

The script can be dynamically added to the page using a method in Dsr.js:
Dsr.sendAndPoll('Sample.js', 'getHelloWorld', sampleLoadedListener);
where sampleLoadedListener is an object that could look like this:
var sampleLoadedListener = {
onLoad: function()
{
document.getElementById('outDiv').innerHTML = getHelloWorld();
},
onError: function(status, statusText, response)
{
alert('status: ' + status + ', error: ' + response);
},
onTimeout: function() { alert('timeout'); },
timeout: 30
};
sampleLoadedListener.onLoad will be called once getHelloWorld is detected as being defined.

On Demand Data

This section is bit more experimental. It is just a first thought, probably needs more work. I think I'll need to make changes to Dsr to have it play nice with this model, perhaps even provide convenience method to handle multi part URLs.

1. GET URL length restrictions

(UPDATE 1/21/2006: The API described below has been significantly changed. See the Dynamic Script Request API for the new version. The Dsr.js library now implements the DSR API.)

It seems like URLs can only be at maximum around 1KB, so this can be problematic if you need to send a large amount back to the server. What about using multiple requests (parts) to post the data back? The server would collect the parts, and on the final part, do the action. Some spec is needed for GET parameters on the part URLs:
?part=currentPartNumber.totalParts
&succes=methodName
&amp;amp;amp;amp;amp;error=methodName
&partComplete=methodName
[&actual data to give to server]
An example URL (broken into multiple lines for readability):

?part=1.4
&success=myDataLoaded
&error=myError
&partComplete=myPartComplete
&name=foo
&quantity=3
&....


1.4 means this is part 1 of a 4 part request.

myDataLoaded is a JavaScript function already defined in the page, and it takes one parameter, the actual JavaScript response data from the server after the server finishes collecting all the parts and processing the requests.

myError
is a JavaScript function already defined in the page that would take perhaps an error object/message as the only parameter.

partComplete
is a JavaScript function already defined in the page that would take the part number that was just completed by the server. The server's response would call this method as the very last line in the response.

As the JavaScript gets notification of a successful part being processed
(via the partComplete function), it would attach the next part as a SCRIPT element to the page.

The method callback parameters only need to be sent up as part of the first part of the total request.

2. Data has to be JavaScript

Frameworks like DWR or JSON (in the Java world) may be able to help with dynamic data (based on request or user data). If it is static data, custom tags using Tagneto's org.tagnetic.core.tags.define.DefineInclude tag handler or the view:xmldatasource tag could be used to transform XML data into JavaScript.

3. Knowing when script load is complete

Completion is known by the calling of the success/partComplete/error functions. Srvr.Script should be changed to allow the checkString to be optional, and to provide a wrapper around this approach.

CVS source update to make building easier

I updated the CVS source last night to make it easier for people who try to build the source from a CVS checkout. Changes:
  • No missing dependencies
  • tagneto/src/test/RunTests.bat should now run all the tests (still have to check RunTests.sh)
  • Fixed warnings when building in Eclipse (warnings mostly from the autogenerated JAXB code that is used to parse tagneticconfig files).
You will only see these changes if you get the source from CVS.

http://tagneto.org/who

Entry for allowing comments about the following page:

http://tagneto.org/who

Comments may be modified/purged periodically as the content of the page referenced above changes.

Comments for http://tagneto.org/when

Entry for allowing comments about the following page:

http://tagneto.org/when

Comments may be modified/purged periodically as the content of the page referenced above changes.

Comments for http://tagneto.org/how/reference/js

Entry for allowing comments about the following page:

http://tagneto.org/how/reference/js

Comments may be modified/purged periodically as the content of the page referenced above changes.

Comments for http://tagneto.org/how/reference/tagneticconfig/

Entry for allowing comments about the following page:

http://tagneto.org/how/reference/tagneticconfig/

Comments may be modified/purged periodically as the content of the page referenced above changes.

Comments for http://tagneto.org/how/reference/tags/CtrlTags.html

Entry for allowing comments about the following page:

http://tagneto.org/how/reference/tags/CtrlTags.html

Comments may be modified/purged periodically as the content of the page referenced above changes.

Comments for http://tagneto.org/how/reference/tags/HtmlTags.html

Entry for allowing comments about the following page:

http://tagneto.org/how/reference/tags/HtmlTags.html

Comments may be modified/purged periodically as the content of the page referenced above changes.

Comments for http://tagneto.org/how/reference/js/DynamicScriptRequest.html

Entry for allowing comments about the following page:

http://tagneto.org/how/reference/js/DynamicScriptRequest.html

Comments may be modified/purged periodically as the content of the page referenced above changes.

Comments for http://tagneto.org/how/reference/tags/ViewTags.html

Entry for allowing comments about the following page:

http://tagneto.org/how/reference/tags/ViewTags.html

Comments may be modified/purged periodically as the content of the page referenced above changes.

Comments for http://tagneto.org/how/quickstart/AlternateSyntax.html

Entry for allowing comments about the following page:

http://tagneto.org/how/quickstart/AlternateSyntax.html

Comments may be modified/purged periodically as the content of the page referenced above changes.

Comments for http://tagneto.org/how/quickstart/Overlays.html

Entry for allowing comments about the following page:

http://tagneto.org/how/quickstart/Overlays.html

Comments may be modified/purged periodically as the content of the page referenced above changes.

Comments for http://tagneto.org/how/quickstart/CustomTag.html

Entry for allowing comments about the following page:

http://tagneto.org/how/quickstart/CustomTag.html

Comments may be modified/purged periodically as the content of the page referenced above changes.

Comments for http://tagneto.org/how/quickstart/Xml.html

Entry for allowing comments about the following page:

http://tagneto.org/how/quickstart/Xml.html

Comments may be modified/purged periodically as the content of the page referenced above changes.

Comments for http://tagneto.org/how/quickstart/Html.html

Entry for allowing comments about the following page:

http://tagneto.org/how/quickstart/Html.html

Comments may be modified/purged periodically as the content of the page referenced above changes.

Comments for http://tagneto.org/how

Entry for allowing comments about the following page:

http://tagneto.org/how

Comments may be modified/purged periodically as the content of the page referenced above changes.

Comments for http://tagneto.org/where

Entry for allowing comments about the following page:

http://tagneto.org/where

Comments may be modified/purged periodically as the content of the page referenced above changes.

Comments for http://tagneto.org/why

Entry for allowing comments about the following page:

http://tagneto.org/why

Comments may be modified/purged periodically as the content of the page referenced above changes.

Comments for http://tagneto.org/what

Entry for allowing comments about the following page:

http://tagneto.org/what

Comments may be modified/purged periodically as the content of the page referenced above changes.

Comments for http://tagneto.org/

Entry for allowing comments about the following page:

http://tagneto.org/

Comments may be modified/purged periodically as the content of the page referenced above changes.

Tuesday, November 15, 2005

Tagneto 0.3.0 Released

I just released version 0.3.0 of Tagneto. From tagneto.org:

Tagneto is a web developer tool and JavaScript libraries to aid MVC development of XML user interfaces, with HTML web applications (DHTML, AJAX, RIA, Web 2.0, etc...) being the primary target. It is available under the GNU Lesser General Public License (LGPL).

Tagneto includes a "View Assembly" web developer tool written in Java (1.4+ supported). It does not require Java to run on a web server or to be installed on the end user's computer. The Java tool is an HTML/XML parser that allows the web developer to assemble the HTML/XML source into the final set of pages that will be used as the web application. The source does not have to be valid HTML or XML, but the tags that Tagneto handles do have to be well-formed, as defined by one of the supported syntaxes. Similar technologies to the View Assembly tool would be JSP/ASP/PHP. Read the Why document to understand the motivation for Tagneto and how it is different (it will also work with JSP/ASP/PHP).

Tagneto also comes with some JavaScript (JS) libraries that aid building the Controller in JavaScript ("JavaScript" is used on this web site, even though ECMAScript is the proper name). The helper JS libraries are not required to use the View assembly part of the tool.

Tagneto was designed to support internationalization (I18N) and localization (L10N), both in the output pages and in the syntax and wording of the actual Tagneto tags. However, the I18N and L10N support has the least amount of testing, so you may find issues.

For more information on Tagneto features (like non-invasive source configuration, overlays, custom tags), please read the What page.