[cvs] expresso/expresso-web/expresso/doc/edg jsp.xml

JCorporate Ltd jcorp at jcorp2.servlets.net
Thu Jun 17 09:34:10 PDT 2004


Update of /home/javacorp/.cvs/expresso/expresso/expresso-web/expresso/doc/edg
In directory jcorp2.servlets.net:/tmp/cvs-serv5293/expresso-web/expresso/doc/edg

Modified Files:
	jsp.xml 
Log Message:
add description of 'universal dispatch'


Index: jsp.xml
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/expresso/doc/edg/jsp.xml,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** jsp.xml	26 Apr 2004 14:39:04 -0000	1.16
--- jsp.xml	17 Jun 2004 16:34:05 -0000	1.17
***************
*** 631,634 ****
--- 631,709 ----
  	</sect1>
  	<para />
+     <sect1>
+         <title>Universal Dispatch</title>
+         <indexterm>
+             <primary>dispatch</primary>
+             <secondary>universal</secondary>
+         </indexterm>
+         <indexterm>
+             <primary>Universal Dispatch</primary>
+         </indexterm>
+ 
+         <para>
+ Expresso's controller/state system is a finite-state machine, where each state can be determined
+             by the HTTP parameters "controller" and "state" (assumptions apply if these are missing).
+             By convention in Expresso, these parameter will take
+  precedence over the 'file' part of the URL.  Therefore, if you have a URL like
+  http://myapp/somecontroller.do?controller=blah , then the "controller" parameter will win out: instead
+  of going to the controller "somecontroller", you will end up at controller "blah".
+  </para>
+  <para>
+ This leads to a concept called "universal dispatch", where you may assume that
+  expresso will do the 'right thing' when POSTing a form.
+  For example, consider a design where you wish for the 'view' to be
+              relatively ignorant of how it is used by controllers. The view gets
+              inputs, outputs, and transitions, and lays them out.  But to where
+              does it submit the form for a POST?  We don't want the view to
+              know about where the 'action' attribute should be headed. That is
+              controlled by the controller.
+ 
+              For example, consider a scenario where one submit button
+             in a POST form
+             directs the user to controller A, while other submit buttons
+             in the form send the user to controler B.
+             What should the 'action' URL be in the HTML form tag?
+             That is where universal dispatch comes in.
+             The submit button's parameters (if you use the expresso tags) are
+             complete with controller
+             and state parameter, so the view (the JSP) does not need to know.
+             If we assume the 'prompt' page for submission (i.e.,
+             the page with the HTML form tag) came from an expresso controller,
+             the action can be omitted on the form tag.  HTTP will direct the submission
+             back to the URL from where it came, and in turn, the 'controller'
+             param will be parsed by expresso, and the submission will finally
+             be forwarded to the correct controller. Below is an example.
+             </para>
+         <para>
+ 
+         <programlisting><![CDATA[
+ <%-- form deliberately has no action attribute (assumes that this page
+         was generated by an expresso controller) --%>
+ <form method="POST" name="form1" >
+         <%-- ... various inputs and outputs ... --%>
+ 
+         <%-- button's controller param will control destination of POST --%>
+          <input type="submit" value="Add"
+             name="<expresso_el:submitname
+                 value='${controllerResponse.namedTransitions['mySubmitTrans']}'/>"
+          >
+             <expresso_el:buttonparams
+                 value="${controllerResponse.namedTransitions['mySubmitTrans']}"/>
+ </form>
+ 
+ ]]></programlisting>
+ 
+         </para>
+         <para>If you want an 'action' attribute instead of omitting it, you can put in
+         any controller you like. (Note: this feature was partially broken in v.5.5, but fixed in cvs in whatever version
+         comes after 5.5.1.) For example, you can use a randomly-chosen expresso controller
+         <programlisting><![CDATA[
+    <form method="POST" name="form1" action="<c:url value='/Download.do' />" >
+ ]]></programlisting>
+ 
+         </para>
+ 
+     </sect1>
+     <para />
  	<sect1>
  		<title>Conclusion</title>



More information about the cvs mailing list