[Logo] Mentawai Recipes
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Moderation Log] Moderation Log   [Register] Register / 
[Login] Login 
Turning FORM data into POJOs and POJOs into FORM data  XML
Forum Index » Official Recipes
Author Message

Joined: 10/01/2008 08:20:15
Messages: 39

Let's say you have a HTML form sending username, email, password, age, etc. and you want to build a User object out of these form parameters. Just use the VOFilter and all the values from the action input will be used to create a new User object.

In the ApplicationManager:

That's it! Mentawai tries the best it can to convert and inject all the values in the action input inside a new User object. Then inside your action you can just do:

Or if you don't want to use the VOFilter you can use the input.getObject method. This method also allows you to pass an already created User object.

Now to turn a POJO into FORM data you can use the OVFilter, that does the opposite of the VOFilter: It gets all properties from a POJO and place them in the action output so they can be easily displayed inside an HTML FORM.

In the ApplicationManager:

The POJO will come from the action output with the key "user". Then all its properties will be extracted and placed in the action output.

In your JSP page, just use the Mentawai form tags so that the values will appear automatically for you to edit:

Actually you don't need the OVFilter. If you only have the User object in the action output, you can use the mtw:bean tag to place a bean in the page context:

Another way to do the same thing is:

You choose!
Forum Index » Official Recipes
Go to:   
Powered by JForum 2.1.8 © JForum Team