struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Vargas <davargas...@gmail.com>
Subject Re: Simple two button form - Struts 1.2.x
Date Thu, 10 Dec 2009 12:54:23 GMT
Awesome, thanks. I've gotten it to do what I need.

On Thu, Dec 10, 2009 at 7:12 AM, Mark Shifman <mark.shifman@yale.edu> wrote:

> Use EventDispatchAction or just use javascript to go to the action you want
> when the button is pushed.
> mas
> davargas123 wrote:
>
>> I am putting in page that loads at the beginning of my application, and
>> all
>> it has two buttons that should end up forwarding to do one of two
>> different
>> actions. How can I distinguish between which button has been pushed inside
>> the Action class so that I can forward it to the correct page? The JSP and
>> Action are as follows, so far:
>>
>>
>> JSP:
>> <%@taglib uri="/taglib/struts-html" prefix="html"%>
>> <%@taglib uri="/taglib/struts-bean" prefix="bean"%>
>>
>>
>> <html:form method="post" action="/SSNChoose" >
>>        <bean:define id="ssnLookupForm" name="ssnLookupForm"
>> type="com.thomson.west.pubrec.optout.ui.form.SSNLookupForm" />
>>        <div style="text-align: center; font-family: arial;">
>>            <div class="productsdiv" style="margin: 0 auto; padding: 5px;
>> text-align: left;">
>>                <input type="submit" name="Single Encryption"
>> value="Single-Encryption"/>
>>                <div class="spacer">&nbsp;</div>
>>                <input type="submit" name="Batch Encryption"
>> value="Batch-Encryption"/>
>>                </div>
>>                <div class="spacer">&nbsp;</div>
>>        </div>
>> </html:form>
>>
>>
>> Java class:
>>
>> public class SSNChooseAction extends Action{
>>
>>        private static final Logger log =
>> Logger.getLogger(SSNChooseAction.class.getName());
>>
>>        public ActionForward execute( ActionMapping mapping, ActionForm
>> form,
>> HttpServletRequest request,
>>
>>  HttpServletResponse  response){
>>
>>                ActionForward fwd = null;
>>
>>                if(<Some code that can tell me which button is pressed>){
>>                        fwd = mapping.findForward("single");
>>                }else{
>>                        fwd = mapping.findForward("batch");
>>                }
>>
>>
>>                return fwd;
>>        }
>>
>> }
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message