You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Stephiems <st...@trexart.com.au> on 2009/04/30 10:35:34 UTC

[s2] multiple submit buttons using action and method

I'm having a problem with the action and method values on the s:submit tag.

I have a form where I have two submits, Save and Pay Now. Save submits to
the actions save() method and Pay Now submits to the actions pay() method.
In the pay() method I have some of my own validation, if it passes, I
forward it on to another action to make a payment, if it doesn't pass, I
return it to the screen they were just on and display an error message.

When they are directed back to the original page and shown the error
message, if they now press the Save submit, they are redirected to the pay()
method as if they had pressed the Pay Now button, instead of going to the
save() method.

I've also had problems with this tag where I've had to name the action and
the method, not just the method, or else they don't work correctly either.

I think I've possibly found a bug, but I wanted to check to make sure I
haven't done anything wrong before reporting it.

Cheers,
Stephanie
-- 
View this message in context: http://www.nabble.com/-s2--multiple-submit-buttons-using-action-and-method-tp23311584p23311584.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [s2] multiple submit buttons using action and method

Posted by Stephiems <st...@trexart.com.au>.
<action name="ListCustomerData" class="action.ListCustomerDataAction">
<result name="success">/customerDataList.jsp</result>
<result name="input">/customerDataList.jsp</result>
<result name="error">/error.jsp</result>
<result name="makePayment" type="redirectAction">MakePayment!input</result>
</action>

Then with the save() method in ListCustomerDataAction I return SUCCESS.

With the pay() method I do some value checking..just to make sure some
elements have been selected to pay and that the amount is greater then zero.
If it is ok I return makePayment, if it isn't ok I return INPUT. I've also
tried returning SUCCESS since really they are the same. Both had the same
response, which I guess is expected.

Was there any other configuration you needed from me?


newton.dave wrote:
> 
> *and* configuration.
> 
> Stephiems wrote:
>> Oh, sorry, I was experimenting and changed the code:
>> 
>> Here is what I have for the submits, all the rest is the same:
>> 
>> <s:submit id="saveButton" name="saveButton"
>> value="%{getText('button.label.save')}" action="ListCustomerData"
>> method="save" cssClass="button"/> 
>> <s:submit id="payNowButton" name="payNowButton"
>> value="%{getText('button.label.paynow')}" action="ListCustomerData"
>> method="pay" cssClass="button"/>
>> 
>> Thanks
>> 
>> 
>> newton.dave wrote:
>>> Stephiems wrote:
>>>> Both submits go to the same action, just different methods, so I can't
>>>> have
>>>> different forms. I might have to change how it works. I don't like it
>>>> as
>>>> it
>>>> is, but that is what the client wanted, and as much as I tried to get
>>>> them
>>>> to chanage, in the end I have to do what they want.
>>>>
>>>> Here is basically what I'm doing:
>>>>
>>>> JSP (not the full jsp, I've taken out as much as the unnecessary stuff
>>>> as
>>>> possible):
>>>>
>>>> <s:form name="displ" action="ListCustomerData">
>>>>   <s:submit id="saveButton" name="saveButton"
>>>>             value="%{getText('button.label.save')}" cssClass="button"/> 
>>>  >   <s:submit id="payNowButton" name="payNowButton"
>>>>             value="%{getText('button.label.paynow')}"
>>>> action="ListCustomerData"
>>>>             method="pay" cssClass="button"/></p>
>>>> </s:form>
>>>>
>>>> in my ListCustomerData action I have a save() function and pay()
>>>> function.
>>>>
>>>> Again, just to repeat, this only seems to happen if I press the pay,
>>>> find
>>>> an
>>>> error
>>>>
>>>> I might just have to make it so the pay isn't a submit button, maybe
>>>> have
>>>> a
>>>> sort of 'shopping cart' running total at the top of the screen where
>>>> they
>>>> can click on the link to go to the make payment screen.. But, I do
>>>> still
>>>> believe that what I'm trying to do should work. 
>>> *and* configuration.
>>>
>>> I only see a method defined for the "pay" submit button; does the 
>>> ListCustomerData action coniguration specify the "save" method?
>>>
>>> Dave
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-s2--multiple-submit-buttons-using-action-and-method-tp23311584p23327661.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [s2] multiple submit buttons using action and method

Posted by Dave Newton <ne...@yahoo.com>.
*and* configuration.

Stephiems wrote:
> Oh, sorry, I was experimenting and changed the code:
> 
> Here is what I have for the submits, all the rest is the same:
> 
> <s:submit id="saveButton" name="saveButton"
> value="%{getText('button.label.save')}" action="ListCustomerData"
> method="save" cssClass="button"/> 
> <s:submit id="payNowButton" name="payNowButton"
> value="%{getText('button.label.paynow')}" action="ListCustomerData"
> method="pay" cssClass="button"/>
> 
> Thanks
> 
> 
> newton.dave wrote:
>> Stephiems wrote:
>>> Both submits go to the same action, just different methods, so I can't
>>> have
>>> different forms. I might have to change how it works. I don't like it as
>>> it
>>> is, but that is what the client wanted, and as much as I tried to get
>>> them
>>> to chanage, in the end I have to do what they want.
>>>
>>> Here is basically what I'm doing:
>>>
>>> JSP (not the full jsp, I've taken out as much as the unnecessary stuff as
>>> possible):
>>>
>>> <s:form name="displ" action="ListCustomerData">
>>>   <s:submit id="saveButton" name="saveButton"
>>>             value="%{getText('button.label.save')}" cssClass="button"/> 
>>  >   <s:submit id="payNowButton" name="payNowButton"
>>>             value="%{getText('button.label.paynow')}"
>>> action="ListCustomerData"
>>>             method="pay" cssClass="button"/></p>
>>> </s:form>
>>>
>>> in my ListCustomerData action I have a save() function and pay()
>>> function.
>>>
>>> Again, just to repeat, this only seems to happen if I press the pay, find
>>> an
>>> error
>>>
>>> I might just have to make it so the pay isn't a submit button, maybe have
>>> a
>>> sort of 'shopping cart' running total at the top of the screen where they
>>> can click on the link to go to the make payment screen.. But, I do still
>>> believe that what I'm trying to do should work. 
>> *and* configuration.
>>
>> I only see a method defined for the "pay" submit button; does the 
>> ListCustomerData action coniguration specify the "save" method?
>>
>> Dave
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
> 


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


Re: [s2] multiple submit buttons using action and method

Posted by Stephiems <st...@trexart.com.au>.
Oh, sorry, I was experimenting and changed the code:

Here is what I have for the submits, all the rest is the same:

<s:submit id="saveButton" name="saveButton"
value="%{getText('button.label.save')}" action="ListCustomerData"
method="save" cssClass="button"/> 
<s:submit id="payNowButton" name="payNowButton"
value="%{getText('button.label.paynow')}" action="ListCustomerData"
method="pay" cssClass="button"/>

Thanks


newton.dave wrote:
> 
> Stephiems wrote:
>> Both submits go to the same action, just different methods, so I can't
>> have
>> different forms. I might have to change how it works. I don't like it as
>> it
>> is, but that is what the client wanted, and as much as I tried to get
>> them
>> to chanage, in the end I have to do what they want.
>> 
>> Here is basically what I'm doing:
>> 
>> JSP (not the full jsp, I've taken out as much as the unnecessary stuff as
>> possible):
>> 
>> <s:form name="displ" action="ListCustomerData">
>>   <s:submit id="saveButton" name="saveButton"
>>             value="%{getText('button.label.save')}" cssClass="button"/> 
>  >   <s:submit id="payNowButton" name="payNowButton"
>>             value="%{getText('button.label.paynow')}"
>> action="ListCustomerData"
>>             method="pay" cssClass="button"/></p>
>> </s:form>
>> 
>> in my ListCustomerData action I have a save() function and pay()
>> function.
>> 
>> Again, just to repeat, this only seems to happen if I press the pay, find
>> an
>> error
>> 
>> I might just have to make it so the pay isn't a submit button, maybe have
>> a
>> sort of 'shopping cart' running total at the top of the screen where they
>> can click on the link to go to the make payment screen.. But, I do still
>> believe that what I'm trying to do should work. 
> 
> *and* configuration.
> 
> I only see a method defined for the "pay" submit button; does the 
> ListCustomerData action coniguration specify the "save" method?
> 
> Dave
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-s2--multiple-submit-buttons-using-action-and-method-tp23311584p23327366.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [s2] multiple submit buttons using action and method

Posted by Dave Newton <ne...@yahoo.com>.
Stephiems wrote:
> Both submits go to the same action, just different methods, so I can't have
> different forms. I might have to change how it works. I don't like it as it
> is, but that is what the client wanted, and as much as I tried to get them
> to chanage, in the end I have to do what they want.
> 
> Here is basically what I'm doing:
> 
> JSP (not the full jsp, I've taken out as much as the unnecessary stuff as
> possible):
> 
> <s:form name="displ" action="ListCustomerData">
>   <s:submit id="saveButton" name="saveButton"
>             value="%{getText('button.label.save')}" cssClass="button"/> 
 >   <s:submit id="payNowButton" name="payNowButton"
>             value="%{getText('button.label.paynow')}" action="ListCustomerData"
>             method="pay" cssClass="button"/></p>
> </s:form>
> 
> in my ListCustomerData action I have a save() function and pay() function.
> 
> Again, just to repeat, this only seems to happen if I press the pay, find an
> error
> 
> I might just have to make it so the pay isn't a submit button, maybe have a
> sort of 'shopping cart' running total at the top of the screen where they
> can click on the link to go to the make payment screen.. But, I do still
> believe that what I'm trying to do should work. 

*and* configuration.

I only see a method defined for the "pay" submit button; does the 
ListCustomerData action coniguration specify the "save" method?

Dave


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


Re: [s2] multiple submit buttons using action and method

Posted by Stephiems <st...@trexart.com.au>.
Both submits go to the same action, just different methods, so I can't have
different forms. I might have to change how it works. I don't like it as it
is, but that is what the client wanted, and as much as I tried to get them
to chanage, in the end I have to do what they want.

Here is basically what I'm doing:

JSP (not the full jsp, I've taken out as much as the unnecessary stuff as
possible):

<s:form name="displ" action="ListCustomerData">
                    <display:table name="dataList" id="table" pagesize="30"
decorator="checkboxDecorator" form="displ" defaultsort="4" uid="item"
                        excludedParams="itemsToPay agingCategory
priorAgingCategory totalAmount" class="borderedtable" cellspacing="0"
cellpadding="3">
                            <display:column property="checkbox" title="" />
                            <display:column property="invoiceNumber"
titleKey="label.invoiceNumber" sortable="true" />
                            <display:column property="type"
titleKey="label.type" sortable="true" />
                            <display:column property="issueDate"
titleKey="label.issueDate" format="{0,date,dd/MM/yyyy}" sortable="true" />
                            <display:column property="dueDate"
titleKey="label.dueDate" format="{0,date,dd/MM/yyyy}" sortable="true" />
                            <display:column property="purchaseOrder"
titleKey="label.purchaseOrder" sortable="true" />
                            <display:column property="amountAsDecimal"
titleKey="label.amount" format="{0,number,$#,##0.00}"
style="text-align:right" sortable="true" />
                        </display:table>
                        <s:text name="format.money"><s:param name="value"
value="itemsTotalAmountDisplay"/></s:text>
                        <s:submit id="saveButton" name="saveButton"
value="%{getText('button.label.save')}" cssClass="button"/> <s:submit
id="payNowButton" name="payNowButton"
value="%{getText('button.label.paynow')}" action="ListCustomerData"
method="pay" cssClass="button"/></p>
        </s:form>

Then in my ListCustomerData action I have a save() function and pay()
function.

Again, just to repeat, this only seems to happen if I press the pay, find an
error

I might just have to make it so the pay isn't a submit button, maybe have a
sort of 'shopping cart' running total at the top of the screen where they
can click on the link to go to the make payment screen.. But, I do still
believe that what I'm trying to do should work. 

Cheers,
Stephanie


newton.dave wrote:
> 
> Stephiems wrote:
>> I'm having a problem with the action and method values on the s:submit
>> tag.
>> 
>> I have a form where I have two submits, Save and Pay Now. Save submits to
>> the actions save() method and Pay Now submits to the actions pay()
>> method.
>> In the pay() method I have some of my own validation, if it passes, I
>> forward it on to another action to make a payment, if it doesn't pass, I
>> return it to the screen they were just on and display an error message.
>> 
>> When they are directed back to the original page and shown the error
>> message, if they now press the Save submit, they are redirected to the
>> pay()
>> method as if they had pressed the Pay Now button, instead of going to the
>> save() method.
>> 
>> I've also had problems with this tag where I've had to name the action
>> and
>> the method, not just the method, or else they don't work correctly
>> either.
>> 
>> I think I've possibly found a bug, but I wanted to check to make sure I
>> haven't done anything wrong before reporting it.
> 
> Can you show the JSP and configuration? I've used the "method" parameter 
> with the submit tag without any issues.
> 
> Dave
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-s2--multiple-submit-buttons-using-action-and-method-tp23311584p23327212.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [s2] multiple submit buttons using action and method

Posted by Dave Newton <ne...@yahoo.com>.
Stephiems wrote:
> I'm having a problem with the action and method values on the s:submit tag.
> 
> I have a form where I have two submits, Save and Pay Now. Save submits to
> the actions save() method and Pay Now submits to the actions pay() method.
> In the pay() method I have some of my own validation, if it passes, I
> forward it on to another action to make a payment, if it doesn't pass, I
> return it to the screen they were just on and display an error message.
> 
> When they are directed back to the original page and shown the error
> message, if they now press the Save submit, they are redirected to the pay()
> method as if they had pressed the Pay Now button, instead of going to the
> save() method.
> 
> I've also had problems with this tag where I've had to name the action and
> the method, not just the method, or else they don't work correctly either.
> 
> I think I've possibly found a bug, but I wanted to check to make sure I
> haven't done anything wrong before reporting it.

Can you show the JSP and configuration? I've used the "method" parameter 
with the submit tag without any issues.

Dave


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


RE: [s2] multiple submit buttons using action and method

Posted by "Kofford, C Todd" <tk...@ku.edu>.
You may want to re-consider the design of having multiple submit buttons
on the same page. This can be tricky for users that like to use the
"enter" key instead of the mouse click, and make it hard for the user to
figure out which submit button was executed. I won't even get into
browser issues.

Todd Kofford
tkofford@ku.edu
University of Kansas - IT


-----Original Message-----
From: Kishan G. Chellap Paandy
[mailto:kishanchellapaandy_g@spanservices.com] 
Sent: Thursday, April 30, 2009 6:38 AM
To: Struts Users Mailing List
Subject: RE: [s2] multiple submit buttons using action and method

Hi Stephiems,

Are you using same action class for pay() and save()?
If you are using different actions, then have you tried to associate
each submit with a form/s:form?
Do you have mentioned any action in your current form/s:form?

Since you are not getting an error, it may because of the above problem
or a problem similar to that. 

Thank you.
Regards,
Kishan.G
 
Senior Software Engineer.
www.spansystems.com




-----Original Message-----
From: Stephiems [mailto:stephanie@trexart.com.au] 
Sent: Thursday, April 30, 2009 2:06 PM
To: user@struts.apache.org
Subject: [s2] multiple submit buttons using action and method


I'm having a problem with the action and method values on the s:submit
tag.

I have a form where I have two submits, Save and Pay Now. Save submits
to
the actions save() method and Pay Now submits to the actions pay()
method.
In the pay() method I have some of my own validation, if it passes, I
forward it on to another action to make a payment, if it doesn't pass, I
return it to the screen they were just on and display an error message.

When they are directed back to the original page and shown the error
message, if they now press the Save submit, they are redirected to the
pay()
method as if they had pressed the Pay Now button, instead of going to
the
save() method.

I've also had problems with this tag where I've had to name the action
and
the method, not just the method, or else they don't work correctly
either.

I think I've possibly found a bug, but I wanted to check to make sure I
haven't done anything wrong before reporting it.

Cheers,
Stephanie
-- 
View this message in context:
http://www.nabble.com/-s2--multiple-submit-buttons-using-action-and-meth
od-tp23311584p23311584.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


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


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


RE: [s2] multiple submit buttons using action and method

Posted by "Kishan G. Chellap Paandy" <ki...@spanservices.com>.
Hi Stephiems,

Are you using same action class for pay() and save()?
If you are using different actions, then have you tried to associate
each submit with a form/s:form?
Do you have mentioned any action in your current form/s:form?

Since you are not getting an error, it may because of the above problem
or a problem similar to that. 

Thank you.
Regards,
Kishan.G
 
Senior Software Engineer.
www.spansystems.com




-----Original Message-----
From: Stephiems [mailto:stephanie@trexart.com.au] 
Sent: Thursday, April 30, 2009 2:06 PM
To: user@struts.apache.org
Subject: [s2] multiple submit buttons using action and method


I'm having a problem with the action and method values on the s:submit
tag.

I have a form where I have two submits, Save and Pay Now. Save submits
to
the actions save() method and Pay Now submits to the actions pay()
method.
In the pay() method I have some of my own validation, if it passes, I
forward it on to another action to make a payment, if it doesn't pass, I
return it to the screen they were just on and display an error message.

When they are directed back to the original page and shown the error
message, if they now press the Save submit, they are redirected to the
pay()
method as if they had pressed the Pay Now button, instead of going to
the
save() method.

I've also had problems with this tag where I've had to name the action
and
the method, not just the method, or else they don't work correctly
either.

I think I've possibly found a bug, but I wanted to check to make sure I
haven't done anything wrong before reporting it.

Cheers,
Stephanie
-- 
View this message in context:
http://www.nabble.com/-s2--multiple-submit-buttons-using-action-and-meth
od-tp23311584p23311584.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


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