views:

435

answers:

5
+1  A: 

When i see your topic title i thought:

You cant use Ajax in stead of a taglib. AJAX is javascript on the client and the taglib is java code on the server.

After reading your post i thought, ah he whats to do what [link text][1] does

But then not entrily the same.

[1]: http://code.google.com/webtoolkit/ GWT

Peter
A: 

Peter,

Thanks for your answer.

But the main idea is not exactly like Google Web Tools, in GWT you are coding Web application like you were coding AWT or SWING applications. The goal of GWT is very cool, but it's like you have to learn a "new way" of coding Web Application, my idea is simple "binding" Java from HTML, where your Web designer can make what he wants and Developer can code without worry how to fit his Java in the application.

Example: You got a CRUD and it's ready to work, but for many (or just one) reason, your boss says: "We have to change some fields from string to number". That's a hell, you have to change the database, change the data transfer object, change the bean, change the validator and ... change all HTMLs with access to this objects, all javascripts and put the style in the all the fields.
In other using only AJAX with Java Annotation you have only to change the annotation, and it's done, the HTML don't have to know the "implementation", all HTML have to do is ask JAVA.

Henrique
A: 

First impression is ... yuck, someone who picks this up will have no idea what they're looking at without learning your (new, different, non-standard) way of doing things. You could do something similar by implementing a tag that takes a bean (value object) and maybe does some minor reflection/annotation inspection to emit the proper html, and you'll save yourself a lot of heartache down the line.

Make your value objects implement a simple interface that your tag will use to extract and format the html, and you can probably get 80-90% of where you're trying to go with 1/2 the work or less.

Niniki
A: 

First impression was, WTF. After reading further, I get a impression that you are trying to address the 'separation of concerns'problem in a different way. Some observations on your approach.

  1. Requires client side scripting to be enabled and hence fails accessibility guide lines.
  2. Reinventing the wheel: Many web frameworks like Tapestry, Wicket try to address these issues and have done a commendable work.
  3. On your comment on binding Java to HTML, the code example doesn't convey the idea very clearly. formalize() seems to create the UI, that implies you have UI (HTML) coded into java (Bad Idea? probably not NakedObjects attempts to you domain models for UI, probably yes if one were to write a page specific code)
  4. validate() is invoked on onSubmit(), Why would I want it to be processed asynchronously!! That aside, using obstrusive java script is way out of fashion (seperation of concerns again)
  5. Your argument on taglibs preventing WYSIWIG, though justifiable, is not entirely valid. Tags cannot be used to compose other tags, each tag is a unique entity that either deals with behaviour or emits some html code. Your argument is valid for the second case. However, if I understand your formalize() correctly, you are doing the same!

Nice to hear some new ideas and Welcome to SO. Also, please use the edit question option until you earn enough reputation to add comments. Adding answers is not the right way!

questzen
A: 

This idea has some merit, if I understand it correctly.

You could use AOP to modify a servlet that would actually be called for the page. The servlet would then return the html, using the annotations.

This way the programmers don't see the html generation, and if you have a standard javascript library for it, then it may work.

But, just because it works doesn't mean that you should do it.

As was mentioned, there are many frameworks out there that can hide the javascript from programmers, such as JSF, which is basically taglibs and a different navigation scheme.

I remember using the beehive project to do something similar, it was annotation driven so I could basically do everything in java and it generated the javascript, years ago. :)

James Black