home mail me! syndication

overthinkings

by Ruben Daniels

How to integrate crappy banner javascript with your neat ajax application

Many banner companies are using dynamic javascript loading to insert their banners in a website. Most of these companies grew big before the Ajax term was coined and recognized as the future technology of the web. So the scripts they are using assume the page is loading while the script is inserted; they use document.write() to add html to the page. As many of you might know, using document.write on an already loaded page will clear all it’s html and leave you with a white page containing only the banner. In this week’s snippet I’ll show you how to work around this.
Read the rest of this entry »

Dynamically loading jml

This weeks snippet shows how you can fetch some jml (Javeline Markup Language) from the server and run it in your jpf application. This is a good way to dynamically load parts of a big webapp or website.

First we set up the basic calls to retrieve the jml. I’ve added some handling for the error and timeout states to make sure we don’t create errors when the user is disconnected from the internet.

function callback(data, state, extra){
    if (state == jpf.ERROR || state == jpf.TIMEOUT)
        return alert("comm error:" + extra.message);

}

new jpf.http().getXml("somejml.xml", callback);

The final step is to parse the loaded jml data. We use the W3C DOM call, document.createElement to instantiate the element. Javeline Platform allows you to pass jml as a string to this function.

var jmlNode = jpf.document.createElement(data);
jpf.document.documentElement.appendChild(jmlNode);

Together it looks like this:

function callback(data, state, extra){
    if (state == jpf.ERROR || state == jpf.TIMEOUT)
        return alert("comm error:" + extra.message);

    var jmlNode = jpf.document.createElement(data);
    jpf.document.documentElement.appendChild(jmlNode);
}

new jpf.http().getXml("somejml.xml", callback);

It’s that simple.

—–

If you are new to Javeline Platform don’t hesitate to try it out. The new ajax.org website contains the downloads and reference guide which will get your started.

How to synchronize states between a window and a button

My colleague Lukasz is working on www.onedayapps.com, which is meant as a demo site for jpf (javeline platform). This site has a button which is selected when a window is shown, and deselected when it isn’t.

In this weeks snippet i’ll explain how to get this done easily. Lets start out with creating a simple two state button and window:

<j:button state="true">test window</j:button>
<j:window title="Test window" icon="application.png">
   Test
</j:window>

One solution is to use events. We can add an onclick event on the button and an onclose event on the window like this:

<j:button id="btnState"
   state   = "true"
   onclick = "winTest.show()">test window</j:button>
<j:window id="winTest"
   onclose = "btnTest.setValue(false)"
   title   = "Test window"
   icon    = "application.png">Test</j:window>

An easier way to do this, is to make use of bidirectional property binding. This means you connect one property to another such that when one changes, the other one changes as well. Let me show you:

<j:button
   value = "[winTest.visible]"
   state = "true">test window</j:button>
<j:window id="winTest"
   title = "Test window"
   icon  = "application.png">Test</j:window>

That’s all. Now you have a button and a window that are synchronized. When you close the window, the button is not pressed anymore.

—–

If you are new to Javeline Platform don’t hesitate to try it out. The new ajax.org website contains the downloads and reference guide which will get your started.

Ondisk and Online connecting to the right service url

This is the first snippet i’m writing. Hopefully I’ll manage to get one up every week. A snippet is a really short post about something useful or interesting.

This time it’s about setting up your JPF (Javeline Platform) application in such a way that it’s easy to double click and open from your disk, but also still work online. Because online can be many places; i.e. the test server, acceptance server or the live server, it’s important that relative paths are used there. But locally an absolute path needs to be used.

Start by specifying everywhere in the application relative paths, in teleport but also using data instructions. Then in the appsettings element you can specify a baseurl for all relative paths used throughout your appliaction. Now the magic comes in when using dynamic properties using the { } syntax.

<j:appsettings baseurl="{jpf.host ? jpf.host + '/' : 'http://test.example.com/'}"/>

The baseurl is set based to jpf.host if it’s set (it’s not set for the file:// protocols), otherwise it uses the url to the test server. That’s all. I hope this will be helpful in your future projects.

—-

If you are new to Javeline Platform don’t hesitate to try it out. The new ajax.org website contains the downloads and reference guide which will get your started.

document.elementFromPoint

A quick note to give some kudos to Mozilla. It seems they implemented document.elementFromPoint in Firefox 3. This makes drag&drop in Firefox very fast. My docking example runs fastest i’ve seen so far, in FF3. Happy, happy, joy joy!

Thanks in advance.

Property Binding


fig 1. Property Bindings.

With property binding you can define the way a property is calculated. This statement is usually based on a javascript expression including one or more properties on other objects. The value of the property will always be kept up to date. This means that when one of the dependent properties changes, the property is recalculated. See fig 1. for a graphical explanation.

Let me give you an example to make it a bit straightforward. This example sets the visibility of the slider based on the state of the checkbox.
Read the rest of this entry »

MVC and Javeline PlatForm


fig 1. Model-view-controller.

I’m not someone that knows the intricate details of design patterns. Whilst trying to tell people how Javeline PlatForm works I’ve often used the MVC design pattern to describe the functions. It’s even in the JumpStart Guide. In writing this article I talked to Arnold Daniels, who friendly explained to me that I was completely wrong. He simply explained to me the basics of MVC, which instantly made it clear to me why it’s nearly impossible, if not impracticle to apply this design pattern to widget based GUI systems. Read the rest of this entry »

Presentation @JTeam, Amsterdam

We had a nice presentation at JTeam’s Tech Meeting today. It wasn’t recorded on video, but I do want to share the slides, and the demo’s. JTeam is a Java oriented company that works a lot with the Spring Framework. They have quite some experience with GWT. For us a challenge to show them the benefits of Javeline PlatForm (JPF). We tried to show in particular how JPF can be used in a real production application.
Read the rest of this entry »

What is Javeline PlatForm, and how does it compare?

It has been buzzing around the community lately. A great deal of attention has come my way as well. Today I received an interesting question from Yuvaraj Thiagarajan. He wants to know what Javeline PlatForm is exactly, and how it relates to other frameworks. Rather than answering it in the comments, I wanted to give a thorough answer in this article.

Read the rest of this entry »

Licensing Q&A

I received a licensing question from Yuvaraj Thiagarajan. Here is the question and my answer:

Read the rest of this entry »

« Previous entries · Next entries »


Movies online

movies online, click here