[Play 2.0][Java]Getting Checkbox Values from a dropdown

694 views
Skip to first unread message

sameer verasiya

unread,
Sep 11, 2012, 8:23:58 AM9/11/12
to play-fr...@googlegroups.com
Hey Players,,
I have a query, I want to retrieve an array of checkbox values which user selects from a dropdown list .. is there any way in play 2.0
User may select multiple checkoboxes but how come the values could be retrieved?? need halp

Here is what my code looks like..

Html:
<ul class="dropdown-menu">
                    <li class="divider">
                        @for(source <- sourcelist) {
                            <li>&nbsp;&nbsp;&nbsp;<input type="checkbox" name="shopper" value="@source.source_id">&nbsp;&nbsp;nbsp;@source.displayname</li>
                        }
                    <li class="divider"></li>
                </ul>


Mathias Clerc

unread,
Sep 11, 2012, 8:07:12 PM9/11/12
to play-fr...@googlegroups.com
See : http://stackoverflow.com/questions/11532968/play-framework-2-0-multiple-checkboxes-in-java-via-get

2012/9/11 sameer verasiya <sameer...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/IIzwyWxru90J.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.

Sameer Verasiya

unread,
Sep 12, 2012, 1:01:37 AM9/12/12
to play-fr...@googlegroups.com
Thanks for your reply Mathias..

I just want to how it could be retrieved in java.. we usually bind the for and use get() method to retrieve any element.. so i m just facing issue in retrieving all the check values from a dropdown :)

Mathias Clerc

unread,
Sep 12, 2012, 1:03:57 AM9/12/12
to play-fr...@googlegroups.com
In your code you have:
<input type="checkbox" name="shopper"
If you look at the link I gave you, you will see it is not correct.
Once it is fixed, you can do
request().body().asFormUrlEncoded().get("shopper") to get all your
checkboxes

2012/9/12 Sameer Verasiya <sameer...@gmail.com>:

Sameer Verasiya

unread,
Sep 12, 2012, 1:09:28 AM9/12/12
to play-fr...@googlegroups.com
so my element name would be just shopper?

like:


<input type="checkbox" name="shopper" value="@source.source_id">

so after this I may do this to get all the shoppers

request().body().asFormUrlEncoded().get("shopper")    ?????   :)
Reply all
Reply to author
Forward
0 new messages