Sundar Narasimhan wrote:

Hi, I have a master form that displays a bunch of object.

I'd like for the user to select a radio button corresponding to one of
those objects and then click Edit.

The editaction should obviously display a form corresponding to the
selected object.

What I'm failing to understand is what I need to do? (i.e. in
order to do something like this)..
     - i need to create an editaction

Yes

     - in it's perform method I need to create/get my model class

Yes

     - write a form class with getter/setter for my model class
       (this largely reproduces methods from the model, but this
        class derives from ActionForm)?

Or use a dynamic form.

     - set each individual attribute of my model into request parameters

Why would you do this if you have the form bean from the previous step?

     - forward to the jsp that contains an input form with the
       same input parameters

You have to forward to a JSP, yes, and you use struts tags to display the form bean data set in your action class.

All this to do something as simple as display a bunch of fields? :)
I must be missing something.
Each of the steps outlined above will have to be done no matter what framework you use - you have to get the data, put it into some format that your UI can use. then display it. Go ahead and try to do this outside struts and you'll see what you would miss.

Or you could use PHP.

Is there a way to reduce the number of classes, and maybe reduce the
individual getting and setting code everywhere?

There is nothing, except for good design principles, that prevents you combining the model and action code. However, I don't know what your model is, but if the code could conceivably be reused outside your particular application, then it should be kept separate. Perhaps it's not a requirement now that your UI is to be customizable for different customers - but who knows what will be decided in the future? Or what if the database/store containing your data changes? You may have to change your actions code, and if you combine action/model you have to change more of your code, and no longer have a common code base.

Or there's nothing preventing you setting each individual data item in the request scope and displaying them with JSTL - that way you don't have a form bean. Or getting rid of the action by using a scriptlet or custom tag in your JSP to get the data from your model, and displaying it using JSTL or custom tags. There's lots you could do, but really all you're doing is moving the code around, *and* losing customizability, flexibility, maintainability and introducing potential breakage points into your code.

Paul


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to