Tomasz Nazar wrote:
But: I'd like to have something more prettier:
Say: /context/emplyee/17
Or even more: /context/archive/1998/employee/tomasz/tasks/7
Can you point me where to look for this? Is there any standard
option for that; some URL pattern rewriting or God knows what.
Do I have to write my own implementation of some method/class and
then parse the url, set proper parameters and pass over to Struts
(dispatcher?) ?
I suspect there are (substantially :) better ways to do what I did, but
here's one option:
- Use wildcard mappings to point to an action
- That action splits the URL based on whatever you need to accomplish (I
had a basic /admin/${table}[/${command}[/${identifier}]] structure)
- The action retrieves a previously-initialized hash of ${command} =>
command-handler-classes
- The command-handler-classes extended a base class that Did the Right
Thing for simple database cases (generic CRUD) and povided hooks for
specialized form initialization stuff (like populating a drop-down list
for foreign keys, whatever).
- Somewhere in there I had a way to instantiate appropriate classes to
represent the form and DTOs (the only form bean I have in my struts
config looks like this:
<form-beans>
<!-- Mysterious, huh? -->
<form-bean name="adminForm"
type="org.apache.struts.validator.DynaValidatorActionForm"/>
</form-beans>
Hrm... uh. Ah, here we go: I have a request processor that automagically
instantiates ActionForm subclasses based on the ${table} wildcard value.
I vaguely remember digging through source code and needing to have the
dummy entry (the action discussed above has the dummy form as its 'name'
attribute) but I don't recall why.
I was playing with Spring for IoC so ended up using that for a lot of
configuration; I could make fairly substantial changes in functionality
without having to touch the actual webapp code--neato.
Then they yelled at me for not doing billable work and I had to stop;
another couple of weeks and it would have been a poor duplicate of code
that already exists in the wild.
Sorry for the ramble--I'm motivated to work on that code again now, though!
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]