Thanks Rick for the example. It has really helped me as I am certainly a
noob.

I'd love it if you (or anyone) could clarify something for me. Firstly, some
basic info on my system: I have system wide settings including an SMTP
server and a list of users that can access the system. These are stored in a
SystemSettings class.

I took your advice and used a DispatchAction for system-related updates. I
called it SystemAction. It contains 2 methods: setUpForEdit() and edit(). My
related form bean contains a dispatch property which defaults to
"setUpForEdit". This seems to work fine.

My system configuration JSP lists users in a select box. Your example lists
users as static text with an edit link for each user. This allows you to use
<c:url > to figure include the user ID. However, I have one edit link next
to my select box.

I understand I have to use javascript to set the user ID and then submit /
forward to my user JSP. My questions are:

1. Is there some standard way of handling this with struts / other tag
libraries?

2. Assuming not, I would like to develop my own (I will have a lot of select
boxes with add / edit / delete links alongside them in my application).
Would this be possible, given the reliance on embedding javascript and
knowing what parameters to pass to the target page?

I know these are kind of general questions but I'm finding it hard to be
more specific since I am such a noob. Hopefully you'll be able to confirm
that what I'm attempting to do is fairly common and maybe point me in the
right direction.

Thanks,
Kent


-----Original Message-----
From: Rick Reumann [mailto:[EMAIL PROTECTED] 
Sent: Friday, 8 July 2005 1:45 AM
To: Struts Users Mailing List
Subject: Re: Refresher for newbies (part 2)

After reading the initial newbie post, you then might come across a 
situation where you need to have some things like "lists" on the page 
that aren't related to your ActionForm. For example, in the User example 
just given, imagine you need the person using the form to select a 
"Department" that the user belongs in. You thus need a way to make sure 
that a List of department is available on the page for the user to 
select from.

Now before we get a ton of responses about how "here's why I came up 
with this for Struts, and here's my solution...", I understand that many 
of the ideas that many of you have come up with our very ingenious and 
very practical once you understand the framework. I believe, however, 
for someone new to Struts that it's better to Keep Things Simple and 
keep things fairly consistent with what they are used to. For this 
reason I suggest you do things this way....

In your DispatchAction simply provide a prep( HtttpServletRequest 
request) method.

In there you simply do any preparation of things your form might need. 
*NOTE* *NOTE* NOTE*: This is NOT, NOT, NOT where you do things like 
populate the form with user information etc. This is only where you 
would do things like provide lists for drop down so they are in scope.

The next more advanced question is "well what happens if you are using 
validation and validation fails, how are these going to be in scope?"

I believe the answer is quite simple... just call validate from your 
Action class versus relying on Struts to call it based on your struts 
config setting!

I have more on this here 
http://www.reumann.net/struts/articles/request_lists.jsp

The benefit to the prep() and the calling validate manually is 
everything is quite simple... you are using a standard DispatchAction 
which is easy for people to understand PLUS everything is all in one 
place. When dealing with editing Users you can look in your 
UserDispatchAction and see what's going on. No need to look at a bunch 
of xml config settings, AspectJ inserts, or some other hidden stuff.

Granted yes, the newer frameworks handle all of this more gracefully, 
but the problem is not "that big of a deal" with Struts. I've written 
some pretty complex applications and the above has been working fine and 
it becomes so simple to do.

-- 
Rick


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

Reply via email to