Yeah this should work, If i can't find an alternative I most likely will take
this approach. But I was hoping to find a solution that didn't require me to
code a lot of logic using js in the client side. It seems a lot easier if I
can just specifiy the actions with a few controls and the rest is processed
at the server side.


Richard Sayre wrote:
> 
> I'm not sure if this is what your are looking for, it is doing the
> control logic on the client side. Instead of using s:submit to submit
> the form you could make 3 input buttons:
> 
> <input type="button"  onClick="doAction1()"/>
> <input type="button"  onClick="doAction2()"/>
> <input type="button"  onClick="doAction3()"/>
> 
> and the write the following javascript:
> 
> function doAction1() {
> 
>    document.getElementById("formId").action = '<s:url
> action="myAction1"'/>;
>    document.getElementById("formId").submit();
> 
> }
> 
> function doAction2() {
> 
>    document.getElementById("formId").action = '<s:url
> action="myAction2"'/>;
>    document.getElementById("formId").submit();
> 
> }
> 
> function doAction3() {
> 
>    document.getElementById("formId").action = '<s:url
> action="myAction3"'/>;
>    document.getElementById("formId").submit();
> 
> }
> 
> then in your struts.xml:
> 
> <action name="myAction1" class="MyAction" method="method1">
> .
> .
> .
> </action>
> 
> 
> <action name="myAction2" class="MyAction" method="method2">
> .
> .
> .
> </action>
> 
> 
> <action name="myAction3" class="MyAction" method="method3">
> .
> .
> .
> </action>
> 
> You don't have to use the Ajax theme on your form, you can write the
> Javascript using the DOJO library your self.  All the nessary files
> are included when you use the s:head tag
> 
> On 7/25/07, Grish <[EMAIL PROTECTED]> wrote:
>>
>> I'm still in the process of learning S2 and I was curious on what's the
>> best
>> practice in implementing a form with multiple submit buttons
>>
>> I've read that there are multiple way to implement this.
>> One way is here:
>> http://struts.apache.org/2.0.8/docs/multiple-submit-buttons.html
>> Although I was thinking I had to redo my setup of my action class and
>> have
>> all the actions point to one method - execute() and from there i would
>> check
>> a parameter to determine what my next step would be:
>>
>> public String execute() {
>>       if (method.equals(searchMethod)) {
>>          doSearch();
>>          return SUCCESS;
>>       }
>>       if (method.equals(addMethod)) {
>>          doAdd();
>>          return SUCCESS;
>>       }
>>    }
>>
>> something to that effect.
>>
>> But I also wanted to try having an action class with different methods
>> and
>> in my struts.xml the different actions would point to the different
>> methods
>> of my action class.
>>
>> My problem though is I have a form with multiple submit buttons. I tried
>> specifying the action on each submit button but the action in my form
>> overrides the action specified in the buttons. I tried removing the
>> action
>> parameter in my form but it would take the current action and still
>> override
>> the actions specified in the buttons. How do I have a form with multiple
>> submit buttons with different actions? What would be the best practice in
>> implementing this? Would implementation be any different if my submit
>> buttons are ajax themed?
>>
>> Thanks
>> --
>> View this message in context:
>> http://www.nabble.com/-S2--Multiple-Submits-with-different-actions-in-a-Form-tf4140299.html#a11776889
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/-S2--Multiple-Submits-with-different-actions-in-a-Form-tf4140299.html#a11803845
Sent from the Struts - User mailing list archive at Nabble.com.


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

Reply via email to