Skip to content

1.1 Java, Javascript and ActionLists

Daniel Ockeloen edited this page Feb 28, 2015 · 2 revisions

1.1 Java, Javascript and ActionLists

The whole idea of the toolkit is to make it easy to send html, css and code to different attached screens that are seen by the application. But that does imply you need to be able to tell the system what to send or how to react to a action by the user. In the toolkit we use there are 3 places where you can program this interaction. The first is in directly in java this is the most serverside method and fits with the whole idea that the server app is in control of all the screens. It allows you to interact directly with screens with regular java methods. For example when a new screen is found a method is called on your Html5Application object and you can do a action in this example load a div to a screen

public void onNewScreen(Screen s) {
	setContent(s,"divone", "helloworld"); // fill divone with the text helloworld.
}

The second method is using javascript. I won't explain it here directly since thats the normal method you can just google for but using the load command you can load div's and javascript's. These javascripts can be called and they can do whatever they want. We advice to limit javascript where you can but the reality is that the html5 world isn't complete without javascript and the toolkit doesn't try to stop you doing so.

Where the first way (java) is aimed at developers and allows a large amount of interaction with backend servers and other running parts of the application (which remember is running in the server not the client) and the second is javascript aimed at clientside interaction we added a third method called a actionlist. This is a very lightweight scripting system where you can define actions on events that happen. For example the above java method called for each new screen coming in can be 'overridden' by a actionlist called 'newscreen.maf' in your actionlist dir. If that is found the java method is not called but the actionlist is called and executed instead. Here is a example of a actionlist with the same effect

 --- actionlists/newscreen.maf ---
 setContent(screen,divone,"helloworld")
 ----------------------------------

We will try in explaining to show how todo the different things you can do in the different methods where possible.