struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 19623] New: - Mapping multiple action to the same uri
Date Sat, 03 May 2003 11:24:46 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19623>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19623

Mapping multiple action to the same uri

           Summary: Mapping multiple action to the same uri
           Product: Struts
           Version: 1.1 RC1
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Unknown
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: fcadili@skylink.it


Suppose you have to write an application that insert some data in a database through a user

iteration of 3 jsp pages.

With the struts framwork we have to define 3 public address that maps to 3 action maps, 3
Action 
Form etc. To avoid this we must do a lot of hard coding.

For instance consider this sample organization:

public entry to the function:
  /data/insert/index.jsp

private resource:

  /WEB-INF/data/insert/step1.jsp
  /WEB-INF/data/insert/step2.jsp
  /WEB-INF/data/insert/step3.jsp
  /WEB-INF/data/insert/success.jsp

controller (application logic):
  /data/insert/insert.do

Now all the views related to the page (step1 - step3) handle different data, and the control
flow is 
step1 through step3 to collect the input data, and a final step, started with the step3.jsp

submition, that inserts all the data into the database.

All the input pages sumbit their data to /data/insert/insert.do via POST. Besides we want
to check 
that all the data are posted from a valid input path.

We could do with:

  <action-mappings>
     <action    path="/data/insert/insert.do"
               type="org.apache.struts.webapp.insert.Step1Action"
	       protocol="GET"
	       resolver="/data/insert/insert.do"
        <forward name="next-step" path="/WEB-INF/data/insert/step1.jsp" />
   </action>

   <action    path="/data/insert/insert.do"
               type="org.apache.struts.webapp.insert.Step1Action"
	       protocol="POST"
	       resolver="/data/insert/insert.do"
	       button="org.apache.struts.webapps.Submit1"
               name="step1Form"
               scope="request"
               input="/WEB-INF/data/insert/step1.jsp">
        <forward name="next-step" path="/WEB-INF/data/insert/step2.jsp" />
   </action>

  <action-mappings>
    <action    path="/data/insert/insert.do"
               type="org.apache.struts.webapp.insert.Step2Action"
	       protocol="POST"
	       resolver="/data/insert/insert.do"
	       button="org.apache.struts.webapps.Submit2"
               name="step1Form"
               scope="request"
               input="/WEB-INF/data/insert/step2.jsp">
        <forward name="next-step" path="/WEB-INF/data/insert/step3.jsp" />
   </action>

    <action    path="/data/insert/insert.do"
               type="org.apache.struts.webapp.insert.Step3Action"
	       protocol="POST"
	       resolver="/data/insert/insert.do"
	       button="org.apache.struts.webapps.Submit3"
               name="step3Form"
               scope="request"
               input="/WEB-INF/data/insert/step3.jsp">
        <forward name="next-step" path="/WEB-INF/data/insert/success.jsp" />
   </action>

   <resolver   path="/data/insert/insert.do">
     <input    path="/data/insert/" />
     <input    path="/data/insert/index.jsp" />
     <input    path="/data/insert/insert.do" />
   </resolver>

   </resolver>
  </action-mappings>


The resolver class

The one to one mapping from an action path and an Action class exists only if the resolver

attribute is not used. The resolver class has is used to resolve the mapping where more Action

class have the same path (that is are bound to the same "servlet").

Inside the same mapping this attributes are used to discriminate:

1. protocol (GET or POST)
2. button (that point to a class of type Object, usually a static class. We use the toString()
method).

The resolver class bounds input paths to refferer URI to garantee some application consistency.

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Mime
View raw message