简体   繁体   中英

Pass checkbox value to controller from GSP in Grails

I've a checkbox in my Grails application:

<g:checkBox name="reservationAvailable" value="${cafeeInfo.isReservationAvailable}"/>

It must be uncheked if isReservationAvailable boolean-value is false and checked if it's true. When I click on unchecked checkbox, it become checked, then I send a form, but in logs of controller I get false checkbox value. When I update view page, checkbox become empty again. Using parsing such as:

oldCafeeInfo.isReservationAvailable = Boolean.parseBoolean(params['reservationAvailable'])

doesn't solve my issue.

I noticed, checkbox return "on" string, when it's checked. So available to compare checkbox parameter in response with "on"-constant.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM