Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Friday, 28 December 2007

Portlet SimpleFormController Cheat Sheet

It's holiday season so I've finally found a bit of time to create a version of the SimpleFormController cheat sheet for the portlet MVC. Once again, remember that this cheat sheet should be used in conjunction with the API and source code. It is not meant to be a comprehensive translation of the source code. Rather, it is meant to highlight important areas where your own implementation should hook in to the standard workflow.

When compared to the servlet, you can see that the portlet workflow differs mainly in the seperation of the action phase and render phase, as per the JSR-168 spec. Some main points of comparison to note:

  • showNewForm() and showForm() will be called during the render phase (depicted on the LHS of the diagram).
  • The 3 main stages of submission (backing object phase, bind and validate phase, process form submission phase) are found in the action phase (depicted on the RHS of the diagram).
  • In the servlet version, we often need to bind the original form on sucessView, and we did this by calling showForm() during onSubmit(). The same thing is achieved in the portlet version by calling showForm() during onSubmitRender()

I've tweaked the colors slightly, so hopefully they will turn out a bit better on grayscale printers. The servlet version of the cheat sheet has been updated to keep the two cheat sheets consistent.

Hope you will will find this useful. Please leave comments and let me know if anything is wrong, or if there are any suggestions. Happy new year!

Portlet SimpleFormController Cheat Sheet Servlet SimpleFormController Cheat Sheet

Wednesday, 4 July 2007

SimpleFormController Cheat Sheet

I felt I didn't have a good understanding of Spring MVC until I understood the lifecycle of the controller. Not being able to find any good resources that showed the workflow step by step, I created this flowchart of the SimpleFormController.

In a single page cheat sheet format, I've found it handy to keep it on my desk. For the beginner, it should be used in conjunction with the API, and nothing beats firing up a debugger and stepping through the code yourself. Once you understand the SimpleFormController, you can easily understand the WizardFormController or create your own custom controller.

I hope someone will find this useful. Please leave comments and let me know if anything is wrong, or if there are any suggestions. Cheers!

SimpleFormController Cheat Sheet