Sample Text

Unordered List

Saturday, September 12, 2009

Recently, I got to work on SimpleFormController (Spring Framework class for handling web Form) with DisplayTag . It took me a while to get used to SimpleFormController. I should also mention that at first look it might seem lot of mess instead of trying to solve your problem, hey won't you get that feeling whenever you are trying to use any new technology??

I had to use debugger to understand the flow of control from various method. But you can follow this cheat sheet for complete flow diagram for SimpleFormController. You can inherit lot of methods based on your requirements, however following methods are the usual ones.

formBackingObject : will be called by createCommand method from SimpleFormController. On form request, if sessionForm is set to true the model object created by formBackingObject is put in session. On form submit, the object is taken from session and not created once again.

Here, you can also include a check to see if the request is for DisplayTag pagination or actual form submission and you don't have to form submit logic for pagination requests.

isFormSubmission: Default implementation of this method returns true when request method is "POST". You can override this to change its behavior. You would have to do this when you want to use DisplayTag pagination. I have given the sample code below.

referenceData: I didn't have to implement this method for my hands on.

DisplayTag:

DispalyTag provides lot of feature for high-level web presentation patterns like paging, cropping, sorting and exporting etc. The implementation with spring is pretty neat. All you have to do is add below dependency in your pom.xml