You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Greg Lindholm <gl...@yahoo.com> on 2009/02/02 17:06:14 UTC

Re: [S2] Passng a parameter with (multiple) Submit buttons

Thanks Miguel, but that doesn't sound workable with an arbitrary number of
buttons.

Anyone else? 

I'm looking for a method of dealing with a table with each row having a
"remove" button. I need to pass a different rowId based on which button is
clicked so I know which row to remove.
I need to use a form (not a link) as there are other input fields that need
to be submitted with the request.

Is there a struts pattern for this?


Miguel-55 wrote:
> 
> You can use the method attribute in the s:submit button, combined with
> a method in your action. You could use the different method invocation
> as an implicit parameter.
> You may need to use the action wildcard feature in struts.xml
> 
> Si quieres ser más positivo, pierde un electrón
> Miguel Ruiz Velasco S.
> 
> 
> 
> On Fri, Jan 30, 2009 at 15:54, Greg Lindholm <gl...@yahoo.com> wrote:
>> I have a CRUD action and jsp page for an entity, this entity has a list
>> of attributes. I display these attributes in a table one per row.
>> What I would like to do is have a <s:submit action="removeAttr"/> button
>> on each row of the table so the user can click on the button to remove
>> the attribute.
>> In order to make this work I would need to pass the id of the attribute
>> with the submit button and I can't find a way to do this.
>>
>> Is there a (struts) way to pass a parameter with a submit button?
>>
>> I can't use a link because I need all the other form fields to be posted
>> with the request.
>>
>> The only way I can think of making this work is to add some javascript to
>> each button that would set the id in a hidden field before the submit. Is
>> there a pure struts or better way to do this?
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--Passng-a-parameter-with-%28multiple%29-Submit-buttons-tp21756353p21792399.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] Passng a parameter with (multiple) Submit buttons

Posted by Musachy Barroso <mu...@gmail.com>.
The only thing I can think of, is extending DefaultActionMapper,
extract the id from there, and add it to the mapping params, then
plugin your mapper:

<bean type="org.apache.struts2.dispatcher.mapper.ActionMapper"
name="mymapper" class="SuperMapperClass" />
<constant name="struts.mapper.class" value="mymapper"/>

musachy

On Mon, Feb 2, 2009 at 11:48 AM, Greg Lindholm <gl...@yahoo.com> wrote:
>
> Thanks Jim, but I can't use a link, I need to submit the form as there are a
> bunch of other fields that need to get posted with the request.
>
>
> Jim Kiley wrote:
>>
>> How bout:
>> <s:url id="deleteUrl" action="productList!delete">
>> <s:param name="deleteProductId" value="id" />
>> </s:url>
>> <s:a href="%{deleteUrl}">Delete</s:a>
>>
>> On Mon, Feb 2, 2009 at 11:37 AM, Greg Lindholm <gl...@yahoo.com>
>> wrote:
>>
>>>
>>> Yes Musachy, that is correct.  So is there some struts magic to do this?
>>>
>>> The only way I can think of doing this is to add some javascript to each
>>> button that would set the id as a hidden parameter before doing the
>>> submit.
>>> But I would prefer to do this without JS if possible.
>>>
>>> I guess what I'm thinking of would be an enhancement to the submit tag to
>>> allow passing an "id" in the same way you can pass the Action and Method.
>>>
>>>
>>> Musachy Barroso wrote:
>>> >
>>> > What you need to do is pass a different parameter on each submit, not
>>> > call a different method.
>>> >
>>> > musachy
>>> >
>>> > On Mon, Feb 2, 2009 at 11:06 AM, Greg Lindholm <gl...@yahoo.com>
>>> > wrote:
>>> >>
>>> >> Thanks Miguel, but that doesn't sound workable with an arbitrary
>>> number
>>> >> of
>>> >> buttons.
>>> >>
>>> >> Anyone else?
>>> >>
>>> >> I'm looking for a method of dealing with a table with each row having
>>> a
>>> >> "remove" button. I need to pass a different rowId based on which
>>> button
>>> >> is
>>> >> clicked so I know which row to remove.
>>> >> I need to use a form (not a link) as there are other input fields that
>>> >> need
>>> >> to be submitted with the request.
>>> >>
>>> >> Is there a struts pattern for this?
>>> >>
>>> >>
>>> >>>
>>> >>> On Fri, Jan 30, 2009 at 15:54, Greg Lindholm <gl...@yahoo.com>
>>> >>> wrote:
>>> >>>> I have a CRUD action and jsp page for an entity, this entity has a
>>> list
>>> >>>> of attributes. I display these attributes in a table one per row.
>>> >>>> What I would like to do is have a <s:submit action="removeAttr"/>
>>> >>>> button
>>> >>>> on each row of the table so the user can click on the button to
>>> remove
>>> >>>> the attribute.
>>> >>>> In order to make this work I would need to pass the id of the
>>> attribute
>>> >>>> with the submit button and I can't find a way to do this.
>>> >>>>
>>> >>>> Is there a (struts) way to pass a parameter with a submit button?
>>> >>>>
>>> >>>> I can't use a link because I need all the other form fields to be
>>> >>>> posted
>>> >>>> with the request.
>>> >>>>
>>> >>>> The only way I can think of making this work is to add some
>>> javascript
>>> >>>> to
>>> >>>> each button that would set the id in a hidden field before the
>>> submit.
>>> >>>> Is
>>> >>>> there a pure struts or better way to do this?
>>> >>>>
>>> >>>
>>> >
>>> >
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/-S2--Passng-a-parameter-with-%28multiple%29-Submit-buttons-tp21756353p21793012.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
>>>
>>>
>>
>>
>> --
>> Jim Kiley
>> Technical Consultant | Summa
>> [p] 412.258.3346 [m] 412.445.1729
>> http://www.summa-tech.com
>>
>>
>
> --
> View this message in context: http://www.nabble.com/-S2--Passng-a-parameter-with-%28multiple%29-Submit-buttons-tp21756353p21793203.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
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


Re: [S2] Passng a parameter with (multiple) Submit buttons

Posted by Greg Lindholm <gl...@yahoo.com>.
Thanks Jim, but I can't use a link, I need to submit the form as there are a
bunch of other fields that need to get posted with the request.


Jim Kiley wrote:
> 
> How bout:
> <s:url id="deleteUrl" action="productList!delete">
> <s:param name="deleteProductId" value="id" />
> </s:url>
> <s:a href="%{deleteUrl}">Delete</s:a>
> 
> On Mon, Feb 2, 2009 at 11:37 AM, Greg Lindholm <gl...@yahoo.com>
> wrote:
> 
>>
>> Yes Musachy, that is correct.  So is there some struts magic to do this?
>>
>> The only way I can think of doing this is to add some javascript to each
>> button that would set the id as a hidden parameter before doing the
>> submit.
>> But I would prefer to do this without JS if possible.
>>
>> I guess what I'm thinking of would be an enhancement to the submit tag to
>> allow passing an "id" in the same way you can pass the Action and Method.
>>
>>
>> Musachy Barroso wrote:
>> >
>> > What you need to do is pass a different parameter on each submit, not
>> > call a different method.
>> >
>> > musachy
>> >
>> > On Mon, Feb 2, 2009 at 11:06 AM, Greg Lindholm <gl...@yahoo.com>
>> > wrote:
>> >>
>> >> Thanks Miguel, but that doesn't sound workable with an arbitrary
>> number
>> >> of
>> >> buttons.
>> >>
>> >> Anyone else?
>> >>
>> >> I'm looking for a method of dealing with a table with each row having
>> a
>> >> "remove" button. I need to pass a different rowId based on which
>> button
>> >> is
>> >> clicked so I know which row to remove.
>> >> I need to use a form (not a link) as there are other input fields that
>> >> need
>> >> to be submitted with the request.
>> >>
>> >> Is there a struts pattern for this?
>> >>
>> >>
>> >>>
>> >>> On Fri, Jan 30, 2009 at 15:54, Greg Lindholm <gl...@yahoo.com>
>> >>> wrote:
>> >>>> I have a CRUD action and jsp page for an entity, this entity has a
>> list
>> >>>> of attributes. I display these attributes in a table one per row.
>> >>>> What I would like to do is have a <s:submit action="removeAttr"/>
>> >>>> button
>> >>>> on each row of the table so the user can click on the button to
>> remove
>> >>>> the attribute.
>> >>>> In order to make this work I would need to pass the id of the
>> attribute
>> >>>> with the submit button and I can't find a way to do this.
>> >>>>
>> >>>> Is there a (struts) way to pass a parameter with a submit button?
>> >>>>
>> >>>> I can't use a link because I need all the other form fields to be
>> >>>> posted
>> >>>> with the request.
>> >>>>
>> >>>> The only way I can think of making this work is to add some
>> javascript
>> >>>> to
>> >>>> each button that would set the id in a hidden field before the
>> submit.
>> >>>> Is
>> >>>> there a pure struts or better way to do this?
>> >>>>
>> >>>
>> >
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/-S2--Passng-a-parameter-with-%28multiple%29-Submit-buttons-tp21756353p21793012.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
>>
>>
> 
> 
> -- 
> Jim Kiley
> Technical Consultant | Summa
> [p] 412.258.3346 [m] 412.445.1729
> http://www.summa-tech.com
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--Passng-a-parameter-with-%28multiple%29-Submit-buttons-tp21756353p21793203.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] Passng a parameter with (multiple) Submit buttons

Posted by Jim Kiley <jh...@summa-tech.com>.
How bout:
<s:url id="deleteUrl" action="productList!delete">
<s:param name="deleteProductId" value="id" />
</s:url>
<s:a href="%{deleteUrl}">Delete</s:a>

On Mon, Feb 2, 2009 at 11:37 AM, Greg Lindholm <gl...@yahoo.com> wrote:

>
> Yes Musachy, that is correct.  So is there some struts magic to do this?
>
> The only way I can think of doing this is to add some javascript to each
> button that would set the id as a hidden parameter before doing the submit.
> But I would prefer to do this without JS if possible.
>
> I guess what I'm thinking of would be an enhancement to the submit tag to
> allow passing an "id" in the same way you can pass the Action and Method.
>
>
> Musachy Barroso wrote:
> >
> > What you need to do is pass a different parameter on each submit, not
> > call a different method.
> >
> > musachy
> >
> > On Mon, Feb 2, 2009 at 11:06 AM, Greg Lindholm <gl...@yahoo.com>
> > wrote:
> >>
> >> Thanks Miguel, but that doesn't sound workable with an arbitrary number
> >> of
> >> buttons.
> >>
> >> Anyone else?
> >>
> >> I'm looking for a method of dealing with a table with each row having a
> >> "remove" button. I need to pass a different rowId based on which button
> >> is
> >> clicked so I know which row to remove.
> >> I need to use a form (not a link) as there are other input fields that
> >> need
> >> to be submitted with the request.
> >>
> >> Is there a struts pattern for this?
> >>
> >>
> >>>
> >>> On Fri, Jan 30, 2009 at 15:54, Greg Lindholm <gl...@yahoo.com>
> >>> wrote:
> >>>> I have a CRUD action and jsp page for an entity, this entity has a
> list
> >>>> of attributes. I display these attributes in a table one per row.
> >>>> What I would like to do is have a <s:submit action="removeAttr"/>
> >>>> button
> >>>> on each row of the table so the user can click on the button to remove
> >>>> the attribute.
> >>>> In order to make this work I would need to pass the id of the
> attribute
> >>>> with the submit button and I can't find a way to do this.
> >>>>
> >>>> Is there a (struts) way to pass a parameter with a submit button?
> >>>>
> >>>> I can't use a link because I need all the other form fields to be
> >>>> posted
> >>>> with the request.
> >>>>
> >>>> The only way I can think of making this work is to add some javascript
> >>>> to
> >>>> each button that would set the id in a hidden field before the submit.
> >>>> Is
> >>>> there a pure struts or better way to do this?
> >>>>
> >>>
> >
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/-S2--Passng-a-parameter-with-%28multiple%29-Submit-buttons-tp21756353p21793012.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
>
>


-- 
Jim Kiley
Technical Consultant | Summa
[p] 412.258.3346 [m] 412.445.1729
http://www.summa-tech.com

Re: [S2] Passng a parameter with (multiple) Submit buttons

Posted by Greg Lindholm <gl...@yahoo.com>.
Yes Musachy, that is correct.  So is there some struts magic to do this?

The only way I can think of doing this is to add some javascript to each
button that would set the id as a hidden parameter before doing the submit. 
But I would prefer to do this without JS if possible.

I guess what I'm thinking of would be an enhancement to the submit tag to
allow passing an "id" in the same way you can pass the Action and Method. 


Musachy Barroso wrote:
> 
> What you need to do is pass a different parameter on each submit, not
> call a different method.
> 
> musachy
> 
> On Mon, Feb 2, 2009 at 11:06 AM, Greg Lindholm <gl...@yahoo.com>
> wrote:
>>
>> Thanks Miguel, but that doesn't sound workable with an arbitrary number
>> of
>> buttons.
>>
>> Anyone else?
>>
>> I'm looking for a method of dealing with a table with each row having a
>> "remove" button. I need to pass a different rowId based on which button
>> is
>> clicked so I know which row to remove.
>> I need to use a form (not a link) as there are other input fields that
>> need
>> to be submitted with the request.
>>
>> Is there a struts pattern for this?
>>
>>
>>>
>>> On Fri, Jan 30, 2009 at 15:54, Greg Lindholm <gl...@yahoo.com>
>>> wrote:
>>>> I have a CRUD action and jsp page for an entity, this entity has a list
>>>> of attributes. I display these attributes in a table one per row.
>>>> What I would like to do is have a <s:submit action="removeAttr"/>
>>>> button
>>>> on each row of the table so the user can click on the button to remove
>>>> the attribute.
>>>> In order to make this work I would need to pass the id of the attribute
>>>> with the submit button and I can't find a way to do this.
>>>>
>>>> Is there a (struts) way to pass a parameter with a submit button?
>>>>
>>>> I can't use a link because I need all the other form fields to be
>>>> posted
>>>> with the request.
>>>>
>>>> The only way I can think of making this work is to add some javascript
>>>> to
>>>> each button that would set the id in a hidden field before the submit.
>>>> Is
>>>> there a pure struts or better way to do this?
>>>>
>>>
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--Passng-a-parameter-with-%28multiple%29-Submit-buttons-tp21756353p21793012.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] Passng a parameter with (multiple) Submit buttons

Posted by Musachy Barroso <mu...@gmail.com>.
What you need to do is pass a different parameter on each submit, not
call a different method.

musachy

On Mon, Feb 2, 2009 at 11:06 AM, Greg Lindholm <gl...@yahoo.com> wrote:
>
> Thanks Miguel, but that doesn't sound workable with an arbitrary number of
> buttons.
>
> Anyone else?
>
> I'm looking for a method of dealing with a table with each row having a
> "remove" button. I need to pass a different rowId based on which button is
> clicked so I know which row to remove.
> I need to use a form (not a link) as there are other input fields that need
> to be submitted with the request.
>
> Is there a struts pattern for this?
>
>
> Miguel-55 wrote:
>>
>> You can use the method attribute in the s:submit button, combined with
>> a method in your action. You could use the different method invocation
>> as an implicit parameter.
>> You may need to use the action wildcard feature in struts.xml
>>
>> Si quieres ser más positivo, pierde un electrón
>> Miguel Ruiz Velasco S.
>>
>>
>>
>> On Fri, Jan 30, 2009 at 15:54, Greg Lindholm <gl...@yahoo.com> wrote:
>>> I have a CRUD action and jsp page for an entity, this entity has a list
>>> of attributes. I display these attributes in a table one per row.
>>> What I would like to do is have a <s:submit action="removeAttr"/> button
>>> on each row of the table so the user can click on the button to remove
>>> the attribute.
>>> In order to make this work I would need to pass the id of the attribute
>>> with the submit button and I can't find a way to do this.
>>>
>>> Is there a (struts) way to pass a parameter with a submit button?
>>>
>>> I can't use a link because I need all the other form fields to be posted
>>> with the request.
>>>
>>> The only way I can think of making this work is to add some javascript to
>>> each button that would set the id in a hidden field before the submit. Is
>>> there a pure struts or better way to do this?
>>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/-S2--Passng-a-parameter-with-%28multiple%29-Submit-buttons-tp21756353p21792399.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
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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