struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ylva Degerfeldt" <ylva.degerfe...@gmail.com>
Subject Re: [S2] Problem with list of submit buttons
Date Fri, 29 Aug 2008 16:10:31 GMT
Thanks all of you for your replies but I'm afraid they're not helping
in this case.

James, It's not about getting different buttons to do different
actions. Like I said, I'm using e.g. method = "Edit" or method =
"Save" for that.

I just need some way to return the index of the object in the list
that a certain row belongs to when one of the row's buttons has been
pushed (Like I said.)

To Jim: I actually started doing this application by having each row
in a separate form but I had to change that because of Theme issues
and because I didn't know how to make the automatic handling of errors
and values work in that case. Please don't ask me to change that again
'cause then I have to change the theme as well and I really don't have
the time to do that! There must be another way.

Dave, you seem to know a whole lot about Struts 2. Is there no way to
take the value of "#state.index" of the s:iterator when a certain
iteration is being processed, connect that to a button and send the
value to an Action property when the button has been pushed?

/Ylva

On Fri, Aug 29, 2008 at 5:37 PM, Jim Kiley <jhkiley@summa-tech.com> wrote:
> If each of the buttons is a Submit button, and you have each row of the
> table wrapped in a separate form, you can put a <s:hidden> within each form,
> and store/provide the ID of the row within it.
>
> jk
>
> On Fri, Aug 29, 2008 at 11:22 AM, Ylva Degerfeldt <ylva.degerfeldt@gmail.com
>> wrote:
>
>> Hi everyone,
>>
>> I have a List of POJOs that I've created, and for every POJO in the
>> list I'm displaying some UI components corresponding to the properties
>> of the POJO (textfields and select fields et.c.). I also have some
>> submit buttons that belong to each row (and indirectly to each POJO),
>> like "Edit", "Save" and "Remove" buttons. My corresponding Action has
>> a property for the List and it receives its values the way it should.
>>
>> My problem is that I need some way to tell the Action which of the
>> buttons that had been pushed (which one of the "Edit" buttons for
>> instance), and I don't know how to do that. To be more exact, I'd like
>> some way to return the #state.index of that iteration/row when a
>> specific button has been pushed.
>>
>> I'm also using the "method" tag for calling different methods on the
>> Action depending on which of the three buttons that was pushed, so
>> that's not a problem.
>>
>> I've tried to find more information about the s:submit but I didn't
>> find anything in "Struts 2 in Action" and the Struts 2 API docs aren't
>> explaining much either.
>>
>> I've tried using the "name" and "value" attributes like for other UI
>> components, like:
>>
>> <s:submit name = "Edit" value = "%{#state.index}" key =
>> "caption.editbutton" method = "Edit"/>
>>
>> but that only caused the index value to be the caption of the button.
>> So it looks like "value" means something else for submit components
>> than for other UI components. (It turns into the caption, If a "value"
>> is specified..)
>>
>> I've also checked the parameter names I receive from the action, but
>> apart from the different properties of the List I only receive
>> "method: Edit" (when an "Edit" button has been pressed). Though I
>> recall that when not using Struts you could receive the name of the
>> button as a request parameter, so how do I do that with Struts 2 - and
>> connect a value to it?
>>
>> Maybe I could use the "onclick" attribute of s:submit but I don't know
>> the syntax for sending a value to the Action there. (Isn't that
>> javascript?)
>>
>> Can somebody please help me with this?
>>
>> Thanks in advance!
>>
>> /Ylva
>>
>> ---------------------------------------------------------------------
>> 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
>

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


Mime
View raw message