I have a database persistent object which I wish to maintain. I have something like the following setup:
1 - LoadObjectABCAction for loading the object. The action specifies a formbean of ObjectABC with session scope.
2 - UpdateObjectActionABC which updates the object on the database. This action also specifies a formbean of type ObjectABC with session scope.
1 - ObjectABC. This is a DynaValidatorForm bean. It has a String property called name.
1 - A validation rule which validates the name property on ObjectABC.
The intended process
1 - LoadObjectABCAction gets called and struts creates a ObjectABC which gets passed in to LoadObjectABCAction and added to the session scope. Properties on this object are then populated by loading from the database.
2 - ObjectABC is displayed for edit using a JSP page.
3 - UpdateObjectABCAction is called and the updated ObjectABC is saved to the database.
The problem is that I only want the struts validator to validate ObjectABC for UpdateObjectABCAction. However ObjectABC is delclared as the formBean for LoadObjectABCAction so that struts will create the bean for LoadObjectABCAction to populate. Unfortunately this means that the validator will validate ObjectABC when LoadObjectABCAction gets called, before it gets populated with data. This means the validation will always fail.
I could manually create the bean in LoadObjectABCAction but this defeats the object of using Dyna beans.
Is there any way round this or do I have to scrap Dyna beans in the scenario and use a 'real' bean, which gets created in LoadObjectABCAction, rather than by Struts?