Archive for the 'spring' Category

31
May
07

JAX India 2007 – Bangalore day 3

Below is the coverage of todays sessions and my takeaways. The slides for all presentations are available here.

JSF and AJAX : Best of Friends (by Craig McClanahan, SUN Microsystems)

  • The motive was to convey various means of achieving AJAX while using JSF. Though all means are workarounds in my opinion. JSF specification should have built-in support for AJAX. It lost out in this front because of the delay in finalizing the specification and AJAX peaking up during the same time.
  • The means are : (a) DIY (Do It Yourself) (b) Use JSF components with native AJAX (c) Wrap client side JS libraries (d) Make non-JSF calls to the web server.
  • DIY – Most JSF components have JS event methods. Leverage that along with own JS methods and XMLHttpRequest or other client side JS toolkit like Dojo, Prototype or Scriptaculus. Involves lot of work. Implementing page refresh might be tricky.
  • JSF with native AJAX – Components take care of making async calls and updating DOM. Simpler to use. Loads of OSS and commercial ajaxified JSF components available. e.g ADFFaces, MyFaces, etc
  • Wrap JS libs – Strongly suggested Jmaki which wraps different client side AJAX libraries like dojo, prototype etc.
  • Make non-JSF calls – You can choose to use any of the AJAX libraries and make them talk to a servlet directly instead of going thru the JSF life cycle. Handling the component tree update will be tricky.
  • choose any of the above options based on whether you need to keep the component tree in sync with the DOM updates.

Should you adopt/migrate to Struts 2.0? (by Harshad Oak, Rightrix Solutions)

  • Provides an overview of new features of Struts in 2.0 release. Its basically like Struts 1 + WebWork = Struts 2.
  • Features include annotation support, interceptors through servlet filters, convention over configuration, derive method name from URL, concept of value stack, new tag libraries, a Guice based minimal DI container to integration with Spring, no form beans etc
  • Integration points for Spring, AJAX frameworks like dojo, GWT etc.
  • Package names now contain com.opensymphony.*.
  • Migration from Struts 1 to Struts 2 is difficult because of such drastic changes but migration from Webwork is lot easier.

My opinion – its a mess now, it is dieing. The code code sample he shown looked lot messier, a result of merging two frameworks. The author himself seemed directionless like the framework and mostly tried to highlight that the framework supports all the buzz words in web framework market these days. Guess Webwork is banking on Strut’s image now to sell itself. :( Pity for both of them. Good for us (developers) since we have two frameworks less to worry about now.

Can tools improve even a power geeks productivity? (by Craig McClanahan, SUN Microsystems)

  • Brings out the point that geeks who like playing with their good old editors using the combination of hot keys and the keyboard, can be more productive if the IDE has appropriate features.
  • Few features that makes a java IDE good are – documentation lookup, refactoring, real time debugging, unit testing support, version control support, database administration, deployment, generate boiler plate and plumbing code, allow maven / ant structuring, integrate runtime dependencies, heterogeneous programming language support, generate skeleton OR mapping and support for popular frameworks etc.
  • Demonstrated Netbeans IDE supporting these features, though he named Eclipse in the context. So i would not say that we was solely pushing the SUN product by throwing a catchy session title.

You can’t just buy an Open Source community (by Neelan Choksi, COO Interface21)

  • This talk was to highlight that all the commercial vendors taking the open source route to stay in business will not succeed. They can not buy the community by open sourcing their products e.g OpenJDK, OpenJPA, JBuilder etc etc.
  • The only sensible thing he talked about – Community is the most important factor in success of open source projects. You need to build community and their are few approaches to do that.

Otherwise the talk was complete waste of time. More focused on picking up failures from rivals and quoting Interface21 as the rightest thing to ever happen. The less you write about his presentation skills, on stage persona and language command the better it is for Interface21. An instance of catchy title but patchy content. :(

Why is everyone so excited about Ruby-on-Rails (by Neal Ford, Thoughtworks)

  • Title says it all – marketing of RoR. However i still wanted to attend to see whats inside RoR. And to be honest, i was taken aback, throughly surprised with zillions of questions shooting here n there in my mind.
  • Few features – RAD development (they mean it, needs to be seen if it works in enterprise apps), agility, instant feedback, OR mapping via ActiveRecord, no compile/deploy etc, scaffolding, testing generation, web 2.o support etc.
  • Follows standard folder structure which helps in getting rid of configuration files, making safe assumptions. Generates method code at runtime based on need.
  • Recommends Streamlines, a 3rd party scaffolding library.
  • Admits it slowness now but expects drastic improvements in next release.

my thoughts – this is a completely different way of developing web apps. Given the productivity features and all the buzz around it, i feel the time has come for a try on it for an agile development project.

SOA: The future of distributed computing? (by Neal Ford, Thoughtworks)

  • I am not a SOA fanboy but attended it since none other parallel session were any better. Not sure if i followed him properly but i guess he started with bashing SOA and ended with the note that it has the best chance to work this time for distributed computing.
  • One should download the slides from his website and go thru it. Its pretty humorous and informative at the same time.

Overall, one key point to note is that the audience is much more patient and lenient while listening to the established speakers as against the local ones. I had expected more skilled and professional audience since most of them are at architect or designer level. But few basic ethics like allowing the speaker to cover the topic before asking ahead or out of context questions, things like limiting conversations to certain iterations etc were clearly missing and thus few of the sessions were reduced to mere show-off events than for knowledge exchange.

22
Sep
06

AbstractWizardFormController – AWFC

AWFC? – here is the link.

I have realized over time that Spring framework seriously lacks ‘quality’ documentation and competent faculty. This has in many cases lead the ‘decision makers’ to tag Spring as difficult (which i think otherwise about) and explore possibilities of using ‘easier’ frameworks like Struts. I know thats debatable.

Anyways. I will explain the problems that i faced when i hit upon AWFC for the first time. I had to go the source code to really understand and solve the problem.

Requirement:
Collect data from user in two pages. Display the data in uneditable mode in 3rd page which has 3 buttons.

btn1 – post. save the data in db. Remain on the same screen.

btn2 – pdf. Generate the pdf out of the collected data and show in a new window. Redirect the current page into another screen.

btn3 – go back to previous page.

Problem:

All problems i faced were with the last page which had three buttons.

1> After saving the data if i click on pdf button i get a npe saying that command object is null.

2> On click on pdf button i am able to open the new window but i don’t see my pdf there and my current page doesnt seem to be refreshing with new URL.

3> I have a confusion over how Spring decides on the next page to display?

Solution:

1> I was using AWFC.porcessFinish() method to process the save button click. This method cleans up the command object after processing. Thats the reason i get npe after this. processFinish() should only be called when you have decided that your wizard functionality is achieved. Ideally after this wizard you should not need to command object, but for any complicated requirements if you need it, then you should create separate object and store it in session.

For intermediate processing steps one should use the AWFC.postProcessPage() method.

2> You need to include the pdf page into the wizard so that command object is available to it. We need to take two actions on click of the pdf button. So the usual way of telling the next page to Spring will not work. ie

<input type=”submit” name=”_target3″>

We now need to take control of the submit, make two submits one after other setting the “_target”, “target=_blank/_self” and URL values properly. Putting the name=”_target?” in button will make your code complicated. I would say a hidden variable should be defined to set the “_target?” properly.

<input type=”button” value=”pdf” onClick=”document.pressed=’pdf’;pdf()”>

<script>
function pdf(){
if (document.pressed == “save”) {
document.getElementById(“targetParam”).name=”_target2″;
document.getElementById(“userForm”).submit();
} else if (document.pressed == “back”) {
document.getElementById(“targetParam”).name=”_target1″;
document.getElementById(“userForm”).submit();
} else if (document.pressed == “pdf”) {
document.getElementById(“userForm”).target=”_blank”;
document.getElementById(“targetParam”).name=”_target3″;
document.getElementById(“userForm”).submit();

document.getElementById(“userForm”).target=”_self”;
document.getElementById(“userForm”).action=”menu.htm”;
document.getElementById(“userForm”).submit();
}
}
</script>
The above code change made it work as expected. Learnings about AWFC from it are,

1> Use postProcessPage() for intermediate processing

2> Use processFinish() only for ending the wizard. If data is required after it, create another object and store it.

3> Use a hidden variable to set the ‘_target’ required by Spring to decide on the next page to display.

4> In general, AWFC does provide lot of automation for you, but also puts a few restrictions which may make it a difficult choice for many real world problems. A proper analysis should be done before choosing it for use in code.

22
Aug
06

Book review : Java development with Spring Framework

I have been looking for good source of information to understand and learn the Spring framework. Just do a google and you get millions of tutorials, articles, examples, posts and blogs about Spring. I did it and got lost in the ocean of information. You need to spend some time to choose a couple of good articles from them and read on. I don’t like reading on screen and prefer a book in my hands for some serious reading. Since i was looking for a good depth in Spring knowledge, most of the articles didn’t fit the bill. So i found this book.

The Book Amazon Listing & Review

I haven’t read the complete book yet. But whatever i have read so far is very impressive. There is no nonsense in the paragraphs and the book focuses on writing the exact thing that is required to explain the features of the framework. So if you have a habit of skipping paragraphs while reading books then you will miss a lot of things.

Read the chapter 2 and 3 if you want to make your foundation strong. They are concise and to the point. From then onwards you can pick and choose the chapters to read based on the features that you need to use immediately. Chapter 1 should be skipped by people who are new to JEE world. But its a must read for experienced JEE developers, for it will help them understand the real value of Spring like frameworks. Just two chapters are good enough to give you right information to get started with strong foundation.




History

Blog Stats

  • 126,765 views

Bookmarks