File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes Java web framwork supporting MVP programming model (as ASP.NET)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Java web framwork supporting MVP programming model (as ASP.NET)?" Watch "Java web framwork supporting MVP programming model (as ASP.NET)?" New topic
Author

Java web framwork supporting MVP programming model (as ASP.NET)?

Tom Jonsson
Greenhorn

Joined: May 24, 2008
Posts: 2
Is there any java web framework that are similar to the ASP.NET programming model with a "code-behind class" (as it is called in ASP.NET) that can refer to the elements in the page by its Id, and can retrieve or inject the values (or enable/disable parts of the page) ?
(can JSF be used for that, maybe in combination with something else, such as Facelets or Seam?)
If so, please provide some link to an example.

I think there are waaaay too many java frameworks too choose from, and do not have time to spend lots of time to learning them. Though, I have been browsing around some frameworks looking for examples, but most of them seem to be based on having java beans in a web page that pulls the values into the web page, but I rather would like a "Presenter" class (MVP pattern) to include the presentation logic, and retrieve and inject (and enable/disable content) the values into the web page.

One of the consequences of the MVP pattern is that you are able to reuse the presentation logic (e.g. the code that are invoking the application/business layer and then determines whether or not some gui item should be displayed or not).
http://en.wikipedia.org/wiki/Model_View_Presenter

Below is an example of how the MVP pattern could be used with a Swing JFrame GUI, and how I would like the same presenter to be reused with some web framework:

<pre>

</pre>

/ Tom
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61419
    
  67

"tomjo", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eelco Hillenius
author
Ranch Hand

Joined: Apr 23, 2008
Posts: 37
You can interpret that pattern in multiple ways. Wicket would suit one of these interpretations. JSF would in a very different way.

If you don't want to spend time comparing framework, why not just go for what 'the industry' proposes as the standard: JSF? No-one forces you to check out the alternatives.

I think JSF and ASP.NET are quite similar anyway.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Eelco Hillenius:
... why not just go for what 'the industry' proposes as the standard: JSF?


The only "industry" proposing JSF as a Standard is Sun. I'd steer as far clear of JSF as you can. Is there any particular reason you want something similar to ASP.NET?


GenRocket - Experts at Building Test Data
Tom Jonsson
Greenhorn

Joined: May 24, 2008
Posts: 2
Originally posted by Eelco Hillenius:
...I think JSF and ASP.NET are quite similar anyway.


Well, can you for example hide parts of a JSF page from a java class ("code-behind") or is it necessary to use some kind of if statements within the JSF page between the html tags ?

With the old kind of JSP programming (and old ASP) you would do something like this:


Nowadays though, regarding the Java (standard stuff from Sun) there seem to be a new syntax to use, called "JSTL conditional actions" but the difference does not seem to be very big.
Still, you would be implementing the logic mixed between the html elements, aren't you ?

If you can not control the items in a JSF page from outside of the page, then I do not think JSF is very similar to ASP.NET.
To me, that would be like saying that pulling (JSF) is similar to pushing (ASP.NET), or saying that dependency injection is similar to dependency lookup (aka Service locator).
ASP.NET can inject text into the html tags, while Java looks up the text to be displayed from within the html elements by invoking javabean methods.

Originally posted by Gregg Bolinger:
...Is there any particular reason you want something similar to ASP.NET?


Well, I simply think that the MVP pattern (as it can be implemented with ASP.NET and Windows Form and a common view that can be implemented by both) with a Presenter that can be shared between different GUI's is the cleanest way for implementing a separation of concerns, with all the presentation logic located in the presenter, while having simple html elements in the page without any logic.

It has been about seven years since the first version of ASP.NET, and java people have implemented about 35 frameworks (listed at wikipedia) but still no framework that can implement the presentation logic from outside of the page, as in ASP.NET, but they are all based on having presentation logic within the web pages ?
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

Originally posted by Gregg Bolinger:


The only "industry" proposing JSF as a Standard is Sun. I'd steer as far clear of JSF as you can. Is there any particular reason you want something similar to ASP.NET?

You would steer of JSF even if you have Seam? what do you think of it?
Eelco Hillenius
author
Ranch Hand

Joined: Apr 23, 2008
Posts: 37
Originally posted by Tom Jonsson:

implemented about 35 frameworks (listed at wikipedia) but still no framework that can implement the presentation logic from outside of the page, as in ASP.NET, but they are all based on having presentation logic within the web pages ?


No, that's not true. Wicket, GWT and a few others support that. In fact, there is NO presentation logic in web pages at all in Wicket. You can read that in the first chapter which you can download for free.
Eelco Hillenius
author
Ranch Hand

Joined: Apr 23, 2008
Posts: 37
Originally posted by tomjo:
I think there are waaaay too many java frameworks too choose from, and do not have time to spend lots of time to learning them


I don't want to pick a fight, but you can't on the one hand say you don't want to spend time learning about other frameworks and then in the same breath make strong assumptions (like that they don't support code behind constructs). If you don't want to learn, fine, go for a standard (JSF). Otherwise, invest a few days, read a few chapters of the various books available, and play with a couple of frameworks and step into discussions informed.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Eelco Hillenius:


I don't want to pick a fight, but you can't on the one hand say you don't want to spend time learning about other frameworks and then in the same breath make strong assumptions (like that they don't support code behind constructs). If you don't want to learn, fine, go for a standard (JSF). Otherwise, invest a few days, read a few chapters of the various books available, and play with a couple of frameworks and step into discussions informed.


+1
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java web framwork supporting MVP programming model (as ASP.NET)?