You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by xushaoxun <xu...@gmail.com> on 2007/03/14 13:48:57 UTC
How to submit multiple selection?
For example, i want to get the ids of the selected messages in the forum and
delete the selected messages.
(Suppose i am the admin).
how to achieve this? seems won't work.
--
View this message in context: http://www.nabble.com/How-to-submit-multiple-selection--tf3401936.html#a9473724
Sent from the Struts - User mailing list archive at Nabble.com.
Re: How to submit multiple selection?
Posted by tobinibot <to...@gmail.com>.
Allow me to answer my own question, before somebody tells me how stupid I am.
I think the problem was my action wasn't set up correctly. The following
snippets of jsp and java give me an array (xxx) containing the values that
were checked on the page. In production, these fieldValues attributes would
obviously have user ids in them, rather than the hard-coded numbers like in
this example.
<s:form action="tobin">
<s:checkbox name="xxx" label="1" fieldValue="1"/>
<s:checkbox name="xxx" label="2" fieldValue="2"/>
<s:checkbox name="xxx" label="3" fieldValue="3"/>
<s:checkbox name="xxx" label="4" fieldValue="4"/>
<s:checkbox name="xxx" label="5" fieldValue="5"/>
<s:submit/>
</s:form>
-----------------------------
private int[] xxx;
@Override
public String execute() throws Exception {
return SUCCESS;
}
public int[] getXxx() {
return xxx;
}
public void setXxx(int[] xxx) {
this.xxx = xxx;
}
tobinibot wrote:
>
> If I may tag on a question here....
>
> In your action then, how do you capture all 7 (for example) user id's that
> the admin wants to delete? I have a very similar design, I have a list of
> users, and each user has a checkbox. The admin can select multiple users
> to either activate or deactivate.
>
> In my action then, ideally, all I want back from the page is an array (or
> some sort of collection) of each of the user id's. I haven't been able to
> get any form of this working yet. Any tips?
>
> (this is using Struts 2)
>
> Tobin
>
--
View this message in context: http://www.nabble.com/How-to-submit-multiple-selection--tf3401936.html#a9924729
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: How to submit multiple selection?
Posted by tobinibot <to...@gmail.com>.
If I may tag on a question here....
In your action then, how do you capture all 7 (for example) user id's that
the admin wants to delete? I have a very similar design, I have a list of
users, and each user has a checkbox. The admin can select multiple users to
either activate or deactivate.
In my action then, ideally, all I want back from the page is an array (or
some sort of collection) of each of the user id's. I haven't been able to
get any form of this working yet. Any tips?
(this is using Struts 2)
Tobin
Dave Newton-4 wrote:
>
> --- xushaoxun <xu...@gmail.com> wrote:
>> I am using struts2, and I've been thinking for this
>> questing for days. [s:checkbox] seems won't work.
>> Because it only renders boolean value.
>
> Try using the fieldValue attribute of <s:checkbox.../>
>
> For example, if I use:
>
> <s:checkbox name="user.id"
> fieldValue="%{user.id}"/>
>
> it renders as:
>
> <input type="checkbox"
> name="user.id"
> value="42"
> checked="checked"
> id="confirmTest_user_id"/>
> <input type="hidden"
> name="__checkbox_user.id"
> value="42"/>
>
> d.
>
>
>
>
> ____________________________________________________________________________________
> Expecting? Get great news right away with email Auto-Check.
> Try the Yahoo! Mail Beta.
> http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html
>
> ---------------------------------------------------------------------
> 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/How-to-submit-multiple-selection--tf3401936.html#a9922117
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: How to submit multiple selection?
Posted by Dave Newton <ne...@yahoo.com>.
--- xushaoxun <xu...@gmail.com> wrote:
> I am using struts2, and I've been thinking for this
> questing for days. [s:checkbox] seems won't work.
> Because it only renders boolean value.
Try using the fieldValue attribute of <s:checkbox.../>
For example, if I use:
<s:checkbox name="user.id"
fieldValue="%{user.id}"/>
it renders as:
<input type="checkbox"
name="user.id"
value="42"
checked="checked"
id="confirmTest_user_id"/>
<input type="hidden"
name="__checkbox_user.id"
value="42"/>
d.
____________________________________________________________________________________
Expecting? Get great news right away with email Auto-Check.
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: How to submit multiple selection?
Posted by xushaoxun <xu...@gmail.com>.
I am using struts2, and I've been thinking for this questing for days.
[s:checkbox] seems won't work. Because it only renders boolean value.
Can anyone help?
Alex Wibowo wrote:
>
> are you using struts 1 ? if so, have a look at html:multibox.
> basically you will need a collection in your action form (something like
> List<String> selectedIds = new ArrayList<String>()).
>
> for struts 2, i havent had time to check it yet.. just migrated to Struts
> 2
> a couple days ago :P
>
> On 3/14/07, xushaoxun <xu...@gmail.com> wrote:
>>
>>
>> For example, i want to get the ids of the selected messages in the forum
>> and
>> delete the selected messages.
>> (Suppose i am the admin).
>> how to achieve this? seems won't work.
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-submit-multiple-selection--tf3401936.html#a9473724
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>
>
>
> --
> Best regards,
>
>
> WiB
> -------------------
>
>
--
View this message in context: http://www.nabble.com/How-to-submit-multiple-selection--tf3401936.html#a9492402
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: How to submit multiple selection?
Posted by Alex Wibowo <al...@gmail.com>.
are you using struts 1 ? if so, have a look at html:multibox.
basically you will need a collection in your action form (something like
List<String> selectedIds = new ArrayList<String>()).
for struts 2, i havent had time to check it yet.. just migrated to Struts 2
a couple days ago :P
On 3/14/07, xushaoxun <xu...@gmail.com> wrote:
>
>
> For example, i want to get the ids of the selected messages in the forum
> and
> delete the selected messages.
> (Suppose i am the admin).
> how to achieve this? seems won't work.
> --
> View this message in context:
> http://www.nabble.com/How-to-submit-multiple-selection--tf3401936.html#a9473724
> Sent from the Struts - User mailing list archive at Nabble.com.
>
--
Best regards,
WiB
-------------------