views:

96

answers:

4

Hi folks,

I'm studying Computer Science in Germany and recently stumbled upon Web Services and Google Web Toolkit.

I thought: "Great, define buttons, input fields, panels, ... just hit compile and it works"

Then i thought: "Why hit compile? ..."

Question: Is there a technology where I can define buttons, panel, input fields, ... on the fly? Like GWT but without the compile process. Running the whole business logic on the server (over AJAX or something) and the browser just be the input/output interface.

Hopefully made my question clear.

Best regards, Andre

+1  A: 

The point of GWT is that you can write your client-side browser code in Java. This is an advantage or disadvantage depending on how much you like Java.

If you just program plain Javascript (e.g. using JSON or XML) to communicate with the server, then no compilation step is necessary.

But if you want to use Java, a compilation step will be necessary, as the browser only understands Javascript. (Unless you want to use Applets but that is a different type of solution..)

Adrian Smith
Thank you. I know but, can't this client side javascript run as java on the server? (i know its possible) -> Are there any libraries that can do this?
Bigbohne
Yes JavaScript can be run on the server, but not for things like rendering buttons and forms and browser elements - those exist on the client only.
matt b
+1  A: 

Yes: Run GWT in development mode (it will still compile to bytecode - but that's very quick compared to compiling/translating to JavaScript). I don't think it's a big problem to hit compile once in a while to get the real javascript code, is it?

Chris Lercher
oh! thx. musst have missed that feature
Bigbohne
A: 

Is there a technology where I can define buttons, panel, input fields, ... on the fly?

That would be HTML? Ok, it doesn't have panels, but you can use div's or (if you must) tables for that. If you want all the logic on the server, you don't need any programming done for the client. HTML would be perfect.

Like GWT but without the compile process.

That means the browser would have to be able to execute your code: JavaScript. (You do know that Java and JavaScript have similar names, but are completely different languages?)

I don't think I understand your question, hope this helps.

Ishtar
A: 

Although I can't really understand the question (I mean, the real question behind the question), an alternative to GWT is JSF, which does exactly what you asked, and more. Check out a JSF2 implementation: I recommend Primefaces (http://www.primefaces.org/showcase/ui/home.jsf).

You create your pages using a special markup (XML that contains HTML and JSF tags), and on the server side you have your supporting beans (which are annotated POJOs, by the way).

I think this is the best way to go if you have complex business logic in the background, as it integrates in the whole Java EE universe (but you can also use JSF on its own, in a simple servlet container like Tomcat).

You don't have to compile JSF pages, the Faces servlet processes them on the fly and generates the appropriate HTML + Javascript, where necessary. This makes advanced features like composite components possible (that's one reason to ditch JSPs IMHO). And the best part is that you still have full access to the low level bits, so you can do (but don't have to!) custom Javascript if you'd like to, overwrite CSS styles, and you can even develop your own tag library if you find that there's something missing from the JSF libraries you choose.

Gabor Kulcsar