Home

David Geary is excited about the new Apache Commons Chain module. He has written up information on how you can use JavaServer Faces and Chains together, and walks us through an example.

Finally, this is an interesting example from JSF's perspective. JSF, like Spring MVC, uses value bindings to directly wire HTML components to JavaBean properties. In first-generation frameworks like Struts, it was up to you to write code to do that: actions and forms to shuttle data from web form to JavaBean property. With JSF, you are freed from implementing all of that infrastructure. Can I get an Amen? See this blog entry for more details.

JSF subsumes controller functionality that, in a Struts world, is on the shoulders of the developer, namely shuttling values from web forms to bean properties and vice versa. That begs the question: does JSF need infrastructure like Struts actions and forms? In all likeliehood, you will want some infrastructure around your JSF "actions", regardless of whether your framework is shuttling values for you. For JSF developers, Apache Commons Chain is a solid implementation of that infrastructure.

the jakarta guys have made quite a big deal out of chain, but in actual fact, it is such a simple idea and implementation

By simple you mean *good* and usefull, right.

Somone said that majority of Java developers know Struts, and next version of Struts is based on CoR; as implemented here.http://wiki.apache.org/struts/StrutsChain - based on Jakarta Commons Chain. CoR is a GoF, so no, it's no big deal.It may be a good idea for people to spend some time on CoR.I myself use it instead of IoC.

...Somone said that majority of Java developers know Struts, and next version of Struts is based on CoR; as implemented here.http://wiki.apache.org/struts/StrutsChain - based on Jakarta Commons Chain. CoR is a GoF, so no, it's no big deal.It may be a good idea for people to spend some time on CoR.I myself use it instead of IoC..V

I am active Struts user and consider Struts to be very suitable technology for many page oriented scenarios, but I think that extending Struts too far does not do much good. I guess a different technology should be applied, at this moment I am convinced that Tapestry is the right technology for creating sophisticated Browser based UIs. Learning curve is somehow steep, but in the end Tapestry ideology makes much more sense that JSF/Struts.

Before getting any further, I've never written a full application with tapestry, I've only read tutorials and sample code.

Isn't tapestry an even-driven framework like JSF, but it uses it's own view technology? I think struts is an ok framework for use in a corporate environment, but it doesn't do enough for the developer to make it really useful.

After spending a lot of time with struts (forms and actions - not much abstraction over the servlet spec) and ATG (forms with multiple executions points, in may ways more similar to webwork, also with IoC built in), I realised that neither had really gotten it "right". Struts didn't do enough and ATG did too much and was too heavy (some great ideas, but lask-lustre implementation), so I start to write my own framework. In the end, it turned out similar to JSF, but it worked with jsps because it used the standard contexts.

After spending a little time with JSF, I'm probably going to leave my own framework aside and move over. I'm disappointed that they chose to make it so difficult to use with jsp. A JSP file in a JSF application looks much too complicated to hand over to a designer. This appears to be one of the greatest strengths of tapestry, the view looks just like normal html and any designer could work on it.

I think the idea of managed beans and event-driven application flow will be the best way forward, but even after JSF, there still isn't a single framework that has managed to get it right. Frameworks like wicket go way to far towards swing-style frontends, but struts and webwork don't go far enough. My kingdom for an MVC framework that meets all my requirements!

Before getting any further, I've never written a full application with tapestry, I've only read tutorials and sample code.Isn't tapestry an even-driven framework like JSF, but it uses it's own view technology?

Yes it is an event driven FW and it does use own presentation technology. IMO its strength is in ‘right’ balance between component orientation and closeness to the basics (HTML). I could not ‘get’ Tapestry for a long time and was happy Struts user, but decided to really put Tapestry to test out of frustration with JSF. I was not disappointed.

I am eager to see 3.1 because 3.0 has very annoying requirement of placing all the application components under WEB-INF that makes a nightmare for multilingual applications.

I suggest you to give Tapestry a spin, especially if you are Eclipce user(Spindle plugin). I use it with Idea and miss few Tapestry support features here and there

Thanks for the code. It's an interesting approach but I don't feel that's the way to go. I welcomed the fact that in JSF a command action is linked to a method (like a .Net delegate) instead of to a class. The last is of course the case in Struts. I've seen too many Struts applications where I have to chain(!) together in my mind a lot of GOF-Command classes to see a meaningful coherent picture of the functionality. The intended boon of being able to stick another rendering or view on top these Command classes does not materialize often enough in my experience for this un-object-oriented approach (let's face it: the Command pattern taken too far leads to functional decomposition and procedural programming) to pay off.Another defect of the Command pattern imo is the fact that the command classes need to reflect the granularity of the pages or screens, which is contradictory to their role of being client-agnostic.

I'd like to see, in a hazy picture that is either far in the future or a fata morgana :-), in the client-agnostic part something that is meaningful at the functional analysis level; for instance Usecase, or UnitOfWork, or BusinessProcess. But how does this thing get its data without knowledge of screens, forms, pages, sessions, contexts or the like? It could be a continuation that is coded as if it already has got all it's data-variables. But since these variables are futures the continuation just blocks, and is persisted, on reading or assigning variables that are not bound. These future variables are bound by an executing request thread, a JSF managed bean method for instance, and the Usecase continuation proceeds as far as it can...

(Unlike the use of continuations in this previous TSS thread I envision a continuation of being oblivious at what point it will block and wait for another screen/page/form)

After seeing a fairly junior developer bang out about six complex database pages in a day with .NET, I started thinking about my own productivity rates. Despite my Computer Science degree and a Principal Architect title, I don't think I can keep pace with my junior .NET friend when it comes to banging out web apps.

JSF clearly seems to be an answer to the .NET threat. But I wonder if we're poised to succeed here. Has anyone else measured their productivity rates with JSF? How many days per screen does it take you? I've tried Suns new JSF IDE but it is terrible. It looks nice at first but once I tried building some real screens with it I gave up due to the bugs and design flaws.

It seems to me that we need to quickly decide upon the recommended tools/strategy for developing web apps with Java. Is it JSF and Chains???

Unfortunately you're right. There needs to be greater emphasis on tools for java application development. I work with a guy that used to be a die-hard CLI junkie. Then he got married, had a child and learn to appreciate GUIs!

We all know it's rare to have a GUI development tool that creates maintainable code, but there are lots of small peojects, or components of large projects that could be handled quickly with better tools.

I drew a lot of inspiration for my framework from dbforms where the idea was to allow a developer to create applications as quickly as possible, but instead of jdbc I used hibernate which made it easier to work in terms of objects rather than tables. I think part of the java community's problem is that people have become very hung-up on patterns, especially MVC. JSP taglibs may not adhere to MVC2, but they do allow developers to create true components, for example Displaytag is one of the few j2ee components that can be dropped into an application and run.

In answer to the comment about sandra, html interfaces will still be required for some time to come until RIA becomes more popular and a leader begins to emerge. I'll hold on to my kingdom until then ;)

Has anyone else measured their productivity rates with JSF? How many days per screen does it take you? I've tried Suns new JSF IDE but it is terrible. It looks nice at first but once I tried building some real screens with it I gave up due to the bugs and design flaws.It seems to me that we need to quickly decide upon the recommended tools/strategy for developing web apps with Java. Is it JSF and Chains???

I have been using JSF for a while, and find it very productive, and easy to use. I hand-code pages, but find I can do this pretty quickly.

What I like is that JSF is so simple - you mostly code data binding and events just as if you were writing a client-side GUI.

I can't compare it to other web GUI frameworks because I haven't used them, apart from some minor struts experience a while ago.

1 developer bang out about six complex database pages in a day ...2 How many days per screen does it take you?3 Is it JSF and Chains???

1. I used to teach people how to do more than 3 pages per day average in Struts w/ OO ( but one day I had somone do 12!). The 30 tutorials are short videos downloadable from Struts wiki. But 6 pages a day.... wow. PHP beats both easily. Because a lot of the apps are out there allready, so you just add a few pages, the rest is there. DHTML battle is over, PHP Won! Congrats. RiA is the next battle. I can teach people to do 3 screens per day in JDNC. Not bad.2. This is the most important question in sofware, one that we should ask many times a day.3. No..V

A colleague of mine showed the way that you can build pages using Rational Application Developer (née WSAD). It looked a lot like .Net: a code-behind like Page class is generated that contains references to values and has action handling methods.(This does not seem to support composition of pages out of common page fragments like menu's, search boxes etc. But in that it is similar to ASP.Net I think. Unless you build your menu's etc. into components.)He showed RAD in combination with Service Data Objects. Which seemed a viable way to get .Net like productivity. Not a coincidence since SDO's are very similar to ADO.Net Datasets.These components provide GMail-like server interaction without replacing the page... Interesting.

So that's interesting.

Of course Oracle is in its 11th preview of ADF-Faces. The IDE support is not there yet, but this also provides components that do the trick of not replacing the page. Partial Page rendering they call it.Oracle does not encompass data+metadata in a Dataset/SDO-like object but uses XML instead to define the metadata. They have started JSR 227 for this. But I get the impression this is not making a lot of progress (not getting support from IBM and BEA might have something to do with that).

I have not developed extensively in either RAD or ADF-Faces so I can't give any definite information on wether this productivity materializes. Or wether the developer has the ability to extend or change when needed. Instead of, as usual, these productivity tools leading to total dependence on the productivity-tool vendors having foreseen anything you might encounter in requirements and environmental constraints.

PHP beats both easily. Because a lot of the apps are out there allready, so you just add a few pages, the rest is there. DHTML battle is over, PHP Won! Congrats. RiA is the next battle. I can teach people to do 3 screens per day in JDNC. Not bad.2. This is the most important question in sofware, one that we should ask many times a day.3. No..V

Yes, but JSF is not just about HTML pages, like PHP. See the recent article here about WML+JSF. Also, speed of coding of pages alone is surely not the key measure of a good development toolkit.

(I have to admit a bias against PHP: after a recent battle trying to install a large PHP app, which involved multiple recompilations of apache, postgresql and PHP, then struggling to find the appropriate PHP plugins and modules from out-of-date archives, I would be very cautious in recommending PHP for anything complex).

we're definitely comparing apples and pears, php is quick and dirty, hence the vast number of php applications available. However, probably the greatest expense in any server application is maintenence and not initial development. JSF applications will be more maintainable than php applications.

Matt Raible claimed to have had problems with the RI implementation of JSF, what milage have others had? Is it really ready for action or do you think its worth waiting for the api to mature first?

we're definitely comparing apples and pears, php is quick and dirty, hence the vast number of php applications available. However, probably the greatest expense in any server application is maintenence and not initial development.

I agree with this point, but not your conclusion. JSF may be more maintainable than PHP, but compared to a real OO system? Reuse and maintainability are much more important than how fast you can bang out the first 6 screens. It's more about how fast it is to make a common change to 25 screens in your second application release.

I've joined a shop where they've been doing a lot of .NET work, and they're very interested in what I'm showing them with WebWork / Spring / Hibernate, because you can define a domain model and reusable controller code. They've had to build their own front controller framework for .NET because the code-behind page controller model just doesn't scale or lend itself to maintainability. .NET's dataset data structures also give you no where to hang domain model logic, etc. JSF, in copying .NET, is leading developers into the same problems that have been found by .NET developers. Why do you think Microsoft is introducing a front controller framework in the next version of .NET? It's a shame that Java web developers skipped ahead of this pattern only to have Sun's JCP take a step backward.

I think that virtually all the current frameworks are missing one essential element and thats hydrating objects when dealing with a web client. IMO, there needs to be a layer that deals solely with accepting values from the client and converting the string values into objects. There needs to be validation at that point which is not application specific, the application validation shouldn't occur until the objects have been hydrated and sent to the controller.

JSF does this better than all other frameworks using it's concept of managed beans. Unfortunately it isn't as strong as struts or webwork once the objects have been created/populated.

There is probably scope for a project that deals with this this level of a web application that could be plugged in before a controller. JSF could do the job, but it is too complicated for the role, it is a heavy price to pay.

JSF could do the job, but it is too complicated for the role, it is a heavy price to pay.

Sorry if I am asking an obvious question (I am relatively new to web GUI coding), but why do you say JSF is complicated, and a heavy price to pay? I have been coding in it for a while, and although there is a lot going on 'underneath the hood', it seems to be very simple to use.

jsf is good at mapping request params to beans on the server side, probably the best tool out there. but it also contains other functionality that is unnecessary which i don't need.

i don't think jsf is good enough on its own, it still needs to be backed up struts/webwork. but when it is supported by one of those frameworks, it becomes very useful because it addresses their weaknesses too.

I think that virtually all the current frameworks are missing one essential element and thats hydrating objects when dealing with a web client. IMO, there needs to be a layer that deals solely with accepting values from the client and converting the string values into objects.

I'm not sure if this is close to what you're looking for but I've had good experiences with WebWork2+Freemarker. Objects were easily mapped to place-holders in the HTML without having to explicitly convert them to Strings, and we could receive beans that encapsulated the request instead of Strings.

I think that virtually all the current frameworks are missing one essential element and thats hydrating objects when dealing with a web client. IMO, there needs to be a layer that deals solely with accepting values from the client and converting the string values into objects. There needs to be validation at that point which is not application specific, the application validation shouldn't occur until the objects have been hydrated and sent to the controller.JSF does this better than all other frameworks using it's concept of managed beans. Unfortunately it isn't as strong as struts or webwork once the objects have been created/populated.There is probably scope for a project that deals with this this level of a web application that could be plugged in before a controller. JSF could do the job, but it is too complicated for the role, it is a heavy price to pay.

Seriously, check out WebWork. The type conversion framework is excellent. Hell, it can even create Collections for you and populate them with new instances of your beans so the properties can be set from request parameters! OGNL makes all of this much easier and more powerful.

How do you define a bean to work on, like a managed bean in jsf, with webwork. I understand how it can work on beans in one of the three standard contexts, but how can you get it to create an object of a given type to populate a form without calling another action first?

Jason &amp; Calen,How do you define a bean to work on, like a managed bean in jsf, with webwork. I understand how it can work on beans in one of the three standard contexts, but how can you get it to create an object of a given type to populate a form without calling another action first?If my question isn't clear, I'll elaborate for you.

If you have a Collection that comes back null from the getMyCollection() and you tell WebWork what type it is in the:

MyAction-conversion.properties

file for your Action, it will create a new Collection implementation for you (actually an XWorkList or XWorkMap) which will create the objects for you when you go to set its properties.

Any other kind of reference will just be automatically handled by type conversion with no hand-holding. If you've got a type converter registered for a type and it finds that you're trying to set a value to that type in a property of a bean - any bean as long as it can find it in the context which usually means a property of the Action or one of it's properties, etc.

WebWork type conversion and validation take a LOT of the crappy cut-n-paste boilerplate code out of your Actions so your Action can focus on just doing its work (Interceptors take the rest of the boilerplate out, of course :-) ).

is there a demo app in the distribution that has an example of mapping a collection for example? this tends to be a common requirement and usually the kind of thing that gets hacked together by developers, it'd be good to see a code sample of that in action...

The problem with commons-chain is that your code has to implement a framework-specific interface, org.apache.commons.chain.Command.

There's also the many different ways to assemble a chain. This is the kind of thing that HiveMind exists for, to combine configuration data (what commands to execute, and what order), with an interface.

Coding up a ChainFactory service implementation in HiveMind would be easy (easier than the PipelineFactory, which already exists).

So you have a configuration that identifies each command in the chain, and gets them into the correct execution order. HiveMind can build an implementation that iterates down the list, invoking a method on each object in the chain until true is returned (or non-null, or non-zero, depending on the return type).

Although the typical case is that the service interface has a single method, that would not be required. In effect, each method is its own chain.

So, you can inject into your code this stack of commands, and its represented in your application as an object that implements the common interface, which is defined by your application.

In fact, I need something like this for Tapestry 3.1, but I'm busy writing some labs right now.

The problem with commons-chain is that your code has to implement a framework-specific interface, org.apache.commons.chain.Command.

And what is wrong with that?Application code calls framework specific code (even in Tapestry) here and there anyway. As long as FW specific code is kept in appropriate layer and all the business logic is in POJOs or SessionBeans it is fine to extend/implement FW specific classes and interfaces.

#2. Why would you think that PHP is harder to maintain than JSF? Have you see the code JSF UI generates?

I think sofware developers should not be mnolitic; but should know more than one aproach. Any design patern can be implemented in almost any langage.

I think.. that the way PHP developers aproach the project, methodology and design helps them a lot. They are big on re-use . They use SQL (not _oQL). They don't do JSF. They do quick releases. But that is water under the bridge:http://www.opensourcecms.com/index.php?option=content&task=view&id=388PHP Won! Aginst any tech stack; especialy ASP and JSF. Maybe there is a battle for the distant 2nd place... Tapestry, who cares? Why care?

I focus on Flex vs Avalon vs Laszlo vs JDNC. RiA is next, and you want to have some experience to project to the clients. (It be a lie to say I know of RiA; when you don't have an application to show for it)If you still have to do DHTML apps ... and you do not start with PHP, you are doing your client a dis-service.

.V

(now I hope to get Struts-Chain working w/JDNC at sandraSF.com but that is my problem)

I have experience in all these platforms, and should say that you can create good architecture on any of them. However Java is more mature and there are many tools and frameworks for Java applications, much more that for .NET and PHP application.

For example, you can use1. Hibernate and Struts for Java2. NEO (or NHibernate) for .NET3. Smarty, Propel for PHP

Yes, .NET is the fastest way to create simple web application. But this will be a mess and support will be a pain.

To create good architecture, you will spend almost the same time using .NET, Java or anything else. I don't think the difference will be more than 10-20%.

There many tools and frameworks for Java, .NET has better API and more productive language (C#), PHP is scripting language... Each platform has it strength.

Because by default PHP mingles UI code with business logic. JSF has a clean and simple separation of these.

Have you see the code JSF UI generates?

I assume you mean the code that a JSF UI designer generates. Well, as I hand-code my JSF, I am the code generator. The code is simple. Component events and properties are linked to methods in backing beans. What is complicated about that?

I will try to explain why most should use PHP for a DHTML application. Lets say you are a tech lead, and the gig is to write one of:1. CMS Portal2. eCommerce3. eLeraning4. Forums5. XYZ

As a good tech lead you think effective and are not religious about tech stack; you want to maximise "Return of Sofware" (a good book to read). This means you like cheap operating costs and lowest possible development cost and low risk.

And you Google on serveral open source projects in:A. PHPB. J2EEC. .NET

A. You find that there are many 1-5 projects in platform A.(the link I gave). Each of the projects is 80-90% of what you need. So you think... I can save 80% and reduce risk! Cool!Then you see that some of the projects have 1,000's of customers in production(ex: Drupal) Cool; low risk in proudction track record. You surf some of the client using proucts in the category. They are listed for PHP. 1,000's per application.

B and C. You find... a few applications on those platforms. Likely you will have to develop from scratch. Few reference sites that you can surf. (I know, I wrote a portal in Struts and installed at clients).You have to develop and you know that accorindg to this: http://www.standishgroup.com/sample_research/chaos_1994_1.phpmost proejcts fail. So you want your organization to be profitalbe and not risk a career on a dizaster and have to sue the vendors.

You HAVE to select LAMP!

Yes, if this was the 90's and we started even w/PHP (and we did not do PetStore and EJB and.... etc. ) maybe you can argue that PHP does not have an arcitectualr or tech stack or methodolody advantage. But as a scientific person, you can just look at the #'s. How many proudction application per each PHP open source project there are (there are a dozen buletin boards).So you just chose A and deploy day one. Then you spend a few weeks with to add 10-20% missing and you leverage people that did other proudction sucess proejcts in the product you chose.

OVER, the fat lady sang taps.

Look at any J2EE project home page and they are using PHP in fourms, maybe in front page. Sandra, Spring, etc. The score is something like 10,000 production sites for A and 30 for B+C.This means that we should be learning from them. What ever their aproach is... they are more eficent. Darwin rules, thank god for that.

You could write something from scratch in JSP, it be a waste of money, the business is looking for solutions and applications. Else they will ofshore you. (Did you read Haravrd Businees Review article "IT ivesment offers no Advantage"? If somone missed it, google and read it. And cry.

A good arcitect delivers a track record; a bad one.. talks a lot. Yes, you do PetStore + EJB + ORM + JSF + Generators + XP(no requirements) and then you draw a UML and .. right, no thanks. Yah, PetStore. Doing technlogy for technlogy sake is... masturbation. PHP guys are scoring w/ chicks! Look how many pregnant!!!! Even the clients are asking for PHP.

Game over, thanks for playing, we LOST!

I switched to where we (Java) have an advantage on PHP and VB/C# and Flex/Laszlo; that is JNLP+JDNC. But feel free to try to wake up Frankenstin, he is dead.

So you want your organization to be profitalbe and not risk a career on a dizaster and have to sue the vendors.You HAVE to select LAMP!

Well, if anyone told me I HAD to use MySQL (the M of LAMP) for all my projects, I would have some very rude words for them. At least give me LAPP (PostgreSQL!)

You could write something from scratch in JSP, it be a waste of money, the business is looking for solutions and applications.

Given the typical quality of much PHP code I have seen I would be very cautious about re-using it.

You seem to imply that form coding speed is everything. It isn't. It's a very small part of any substantial web application. There are other important aspects, such as CSS design, testing, integrating with databases. However, form coding with JSP and/or JSF is FAST, and leads to very clear logic. There is little difference in speed between using these technologies and PHP. However, systems like JSF save even more time, because of converters and validators - these can save huge amounts of code. Also, some of the other technologies you mention (EJB and ORM) are there to save time. If used in the right context they can provide robust solutions that would otherwise involve huge amounts of coding.

One good way to get 'off-shored' is to patch together lots of quick-fix applications which turn out to be unmaintainable in the long term.

Sorry if I am ranting about this, but I have seen so many disastrous projects that have resulted from trying to build up large applications from either scripting languages or other innapropriate technologies. Of course you CAN build large apps in PHP or VB or whatever, but few seem to manage it successfully and the results are frequently an unmanagable mess. Part of my job is to try and fix such messes, so I am biased!

>However, systems like JSF save even more time, because of >converters and validators - these can save huge amounts >of code. Actually there are even more convertors and validators in PHP ;-)Dmitry

Not built in as part of the 'standard distribution'. Not part of an agree spec, so that you have a guaranteed API you can code to. Not multi-vendor. And they can't added to a web page as just as a single tag.

Honestly, I do wonder how many of the PHP supporters have actually tried coding a few forms with something like JSF (or other popular Java web interface systems). I think they would be astonished at how quick and simple it is - far simpler than PHP, and far less verbose.

TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations technology projects - with its network of technology-specific websites, events and online magazines.