Hello,

When my JSPs contain multiple buttons that trigger different behaviour I use
the DispatchAction...

Here is a snippet of html for defining a button:
         <html:button property="method" value="LongDistance Service"
        
onClick="window.location=\'dispatchSalesRequest.do?method=longDistance\'"/>
        <html:button property="method" value="CallingCard Request"
        
onClick="window.location=\'dispatchSalesRequest.do?method=callingCards\'"/>
       //...

 In my struts-config.xml I create a mapping like this:
       <action    
               path="/dispatchSalesRequest"
               type="com.algx.coe.app.action.sales.DispatchSalesOrderSetup"
               name="SalesOrderForm"
               scope="request
               input="/pg_salesOrder_edit.jsp"
               parameter="method"
               validate="true">
          <forward name="next"
path="/pg_acctCode_edit.jsp"/>
          <forward name="salesDetail"        path="/addSalesDetail.do"/>
          <forward name="calllingCards"
path="/pg_callingCard_edit.jsp"/>
          <forward name="longDistance"
path="/pg_longDistance_edit.jsp"/>
    </action>

Then in the DispatchSalesOrderSetup class I handle any pre-page processing
in an execute(...) method before 
forwarding control to the appropriate page. The great thing about the
DispatchAction class is you don't have to code any conditional logic since
it uses
reflection to map the request argument (in this case the  "method"
parameter) value to a method name in the DispatchAction subclass.

Hope this helps...

/ Darryl
> -----Original Message-----
> From: Wijewickrema , Dina E. [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, February 13, 2002 9:16 AM
> To:   'Struts Users Mailing List'
> Subject:      RE: HTML / Struts Help
> 
> Just define a hidden field in your form. Then when you press a button
> define
> an onclick event that sets the value of the hidden field.
> 
> For example:
> 
> <struts-html:hidden property="action"/>
> 
> <struts-html:submit property="Process"
> onclick="form.action.value='Process'">
> 
> -----Original Message-----
> From: Mattos, John [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 13, 2002 10:12 AM
> To: '[EMAIL PROTECTED]'
> Subject: HTML / Struts Help
> 
> 
> Hi.
> 
> I have a form that can be submitted by three different buttons, for
> example
> the buttons read
> 
> (Button Labels)
> Process
> View by Org
> View by Product
> 
> What I want to do is in the Action Class handling the submission, find out
> which button was pressed, and act accordingly, whether it's an
> actionForward
> (in the case of the "view" options) or kicking off another process (as
> will
> be done by the "process" button)
> 
> So, how can I figure out what button was pressed in that Action class? Is
> there a way to do that?
> 
> John Mattos
> Sr. Developer and Architect
> iNDEMAND
> 345 Hudson St. 16th Floor
> New York, New York
> 10014
> 
> 
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>

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

Reply via email to