I was thinking about improving action mapping, using more wildcards.
Currently wildcards are unavailable for "name" attribute of <forward>
element. Also, I was thinking of putting several forward names in one
forward element. Little by little I came up with the following list,
which better suits Struts Dialogs ;). I almost finished the conversion
of MailReader, I need to rewrite the walkthrough too. Now I am
thinking of changing the xml a little bit. Rick, it is not StrutsWorks
yet :-)

Anyway, some of these improvements can be used in "orthodox" Struts
too. Opinions?

* "type" identifies class that combines both action
  and form functionality
* new attribute "autoreload" automatically reloads 
  component after input event is processed
* new attribute "view" identifies default view for
  simple dialogs
* scope = "session" by default
* validate = "false" by default
* "input" attribute is deprecated
* "DIALOG-EVENT" (or any other) is the default event prefix; 
  can be redefined in controller element
* new optional element "event" for input phase;
  all events are redirected by default
* new optional element "render" for output phase 
  views are rendered using forward by default
* new attrubute "reload" for "forward" element:
  <forward name="*" reload="true"/>
* new attribute "debug" for "forward" element 
  to show error if input event not found:
  <forward name="*" reload="true" debug="true"/>
* wildcard for mapping name
* multiple mapping names for one forward element

Examples:
(1) Login dialog. Has only one view: logindialog.jsp, which can be
defined in the new "view" attribute. On error dialog reloads
automatically and redisplays default view with error messages. On
success redirects to user's home page.

<!-- One-page login dialog -->
<action path="/login" type = "acme.LoginDialog"
        autoreload = "true" view = "/logindialog.jsp">
  <forward name="success" path="/userhomepage.do" redirect="true"/>
</action>

By the way, Webwork has default values for success, failure and even
login. Hmm, login is probably is a bit of a stretch, but default
attributes for success and failure may be convenient.

(2) CRUD component. After any successful operation on data item
returns to the item list. On error reloads CRUD component and displays
error message. On all other events like "ON-CREATE-SUCCESS" or
"ON-EDIT" reloads the component and then displays a view corresponding
to component state.
<!-- CRUD component -->
<action path="/crud" type = "acme.CRUDComponent">
  <event>
    <forward name="ON-CANCEL, ON-CLOSE" 
             path="/cruditemlist.do"/>
    <forward name="ON-STORE-SUCCESS, ON-DELETE-SUCCESS" 
             path="/cruditemlist.do"/>
    <forward name="ON-LOAD-FAILURE, ON-DELETE-FAILURE" 
             path="/error.do"/>
    <forward name="*" reload="true" debug="true"/>
  </event>
  <render>
    <forward name="CRUD-UI-MODE-CREATE" 
             path="/crudaction-create.jsp"/>
    <forward name="CRUD-UI-MODE-EDIT" 
             path="/crudaction-edit.jsp"/>
    <forward name="CRUD-UI-MODE-READONLY" 
             path="/crudaction-noedit.jsp"/>
    <forward name="CRUD-UI-MODE-INACTIVE" 
             path="/crudaction-notactive.jsp"/>
  </render>
</action>
<!-- CRUD helper: item list -->
<action path="/cruditemlist" type = "acme.ItemList">
  <forward name = "success" path="/crudaction-list.jsp"/>
</action>

Michael.

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

Reply via email to