Title: WebWork2 newbie biting off more than I can chew...

Hi Gang!

I'm still fairly new to WW2 and am using it for a contract project I'm working on. What I'm trying to do is pretty complex so I'm hoping to verify whether or not the framework has the built-in capability to support what I'm trying to do. If so, any pointers in the right direction would be greatly appreciated. I'll try to explain what I need to accomplish as clearly as possible without putting it in the application's context (sorry, I'm under NDA).

Description of process:

A dynamically generated web page is being submitted. This page contains groups of fields that are represented by different Java classes (All derived from the same Abstract base class). When my WW Action is called, my Action's execute() method will load the instance of the object that represents the form being submitted and it contains a List of AbstractBaseClass containing the classes that were represented on the form. I'm using Hibernate as my persistence layer and will have all the info I'll need to retrieve the form instance from the DB in a hidden field in the form being submitted.

The 2 challenges, based on the above process, that I'm facing are as follows:

1) I'm used to extending ActionSupport and having WW2 "automagically" set all my attributes for me. This won't work since the attributes which need to be set will be the attributes contained in the List collection that will be retrieved from the DB via Hibernate. My thought on this is that each class contained in the List will have it's own implementation of a "getFormFields" method which would extract the field values from the request, and then I'd iterate through the list calling "getFormFields" on each object in the list - I'm assuming WW2 can't do anything automatically for me at this level. If that's not the case, I'd love to hear and better ways to implement this. If that's the only way to do what I need, which WW2 is the best class to extend for this purpose?

2) Validation - rather than using a validation interceptor, I'd still like to be able to use the Validation framework with a separate validation.xml file for each of the classes that could possibly be contained in the above mentioned list. However, I'm pretty sure the validationStack won't work for me here since the form being validated has a non-static structure. Once "getFormFields" from step #1 has been called, then I'd call something like "doValidate()" which would use XWork's validation framework to validate that populated object using it's class-specific validation rules.

I figure #1 is possible, worst case, by passing around the request object and extracting what I need from it. Unfortunately, I'm not so sure about #2. I'm going to take a look at com.opensymphony.xwork.validator.ValidationInterceptor when I get a chance to see how it's working it magic but I thought I'd fire this off in case anyone's done something similar.

Thanks in advance!
Peter

Reply via email to