Question

Struts2 documentation on prepare interceptor says:

A typical use of this is to run some logic to load an object from the database so that when parameters are set they can be set on this object. For example, suppose you have a User object with two properties: id and name. Provided that the params interceptor is called twice (once before and once after this interceptor), you can load the User object using the id property, and then when the second params interceptor is called the parameter user.name will be set, as desired, on the actual object loaded from the database.

I am not able to understand this what changes it making to the User object. Can anyone explain with some code? Or give a link where it explains?

Était-ce utile?

La solution

This is a typical usage of the paramsPrepareParamsStack. You can see this answer too. An example of usage this stack you can find here.

The way you initialize the action instance might vary, that's why this stack could apply. Typically you might just instantiate a User object to accept parameters instead of retrieving it from the database.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top