Running a JEE application

Monkey Forums/Monkey Programming/Running a JEE application

Vinians(Posted 2011) [#1]
Hi people!
What I need is create a HTML5 application that call server application in Java. Is that possible ? Obs. the server application can be created with C/Java or other. ...


FlameDuck(Posted 2011) [#2]
Not readily. But there are a couple of 3rd party ajax modules in monkey. So if your J2EE is using something like Jersey, Restlet or Apache CXF then calling for example a JAX-RS web service is fairly trivial. There are also a couple of 3rd party JSON and XML parsers lying around.

So yes you can, but doing so is a non-trivial task.


Vinians(Posted 2011) [#3]
@FlameDuck Can you point me an example please? Just a simple one. What I need is to send some information out of my IPad using HTML 5 to be processed by another application. Thanks in advance!


skid(Posted 2011) [#4]
Here is some monkey code to tell the google you like boobs:


Import dom

Function Main()
	Print "hello"
	window.location.href="http://google.com/search?q=boobs"
End




To keep things simple you can add an iframe to your monkey html container and changes it's href instead to talk to a server.


FlameDuck(Posted 2011) [#5]
Can you point me an example please?
Sorry, I don't have one. A simple one is even trickier as what you're trying to do isn't exactly simple.

As for the webservice, you can try something like the enunciate "IfYouWannaBeCool" example, or if you don't want to write your own, sites like Flickr often have open API's you can play around with.

As for talking to the webservice, as long as you only need GET requests, try something like Xaron's mnet (which comes with example code to do a http GET).

As for parsing the results, as far as I'm aware the best XML parser is skn3's "config" example, which is in the bananas folder of your Monkey distribution folder.


Samah(Posted 2011) [#6]
@FlameDuck As for parsing the results, as far as I'm aware the best XML parser is skn3's "config" example, which is in the bananas folder of your Monkey distribution folder.

Have you seen the one in Diddy?


FlameDuck(Posted 2011) [#7]
Have you seen the one in Diddy?
No. But I'm not a big fan of monolithic frameworks (as-in if I only need an xml parser, there is little reason to install a framework that does hundreds of other things as well), so it's nothing personal. :)

This is why for example Spring Framework is split into modules (spring-core, spring-aop, spring-ws, spring-web, spring-security etc.) so you only get the dependencies you need. :)


Samah(Posted 2011) [#8]
Diddy is split into modules, it just has the convenience "import all" module like Mojo.

The Diddy XML parser can be imported by itself. It's dependent on ArrayList and the assertion stuff, and there's one or two constants in functions.monkey that you can move if you need to.

Self contained modules are good, but sometimes there's unavoidable dependencies. :(


ziggy(Posted 2011) [#9]
@FlameDuck: Take into account the agressive dead code eliminator of the compiler and importing a big monolithic framework will have no impact in the generated program as it will only import any bits used in the code.
diddy modules are pretty much self-contained and very independent, you can import just the ones you want to use, or import all of them and let the compiler just import really what you're using.


therevills(Posted 2011) [#10]
What Ziggy said ;)

Import diddy.xml



Skn3(Posted 2011) [#11]
The diddy one is probably better... and well it is at least better supported :)


Samah(Posted 2011) [#12]
@Skn3 The diddy one is probably better... and well it is at least better supported :)

<3


Vinians(Posted 2011) [#13]
Nice guys! So I can import Dom and call the JEE program and send parameter, but its possible to get the response from that program?