[
https://issues.apache.org/jira/browse/SLING-649?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12712980#action_12712980
]
Renaud Richardet commented on SLING-649:
----------------------------------------
hi Michael,
i started to work on a patch, but ended up using jquery:
// whenever a checkbox changes
$(':checkbox').bind('change', function(){
// if it was just checked
if ($(this).attr('checked') == true) {
// set helper field value to true
$(this).next().attr('value', 'true');
} else {
// set helper field value to false
$(this).next().attr('value', 'false');
}
});
the checkbox element itself is not bound to Sling's post servlet, and you set a
hidden input element next to it that is bound to Sling:
<input id="helper-foo" name="helper-foo" type="checkbox" checked />
<input id="foo" name="./foo" type="hidden" value="true"/>
<input name="./f...@typehint" type="hidden" value="Boolean"/>
maybe this is an option for you...
> checkboxes not handled by SlingPostServlet
> ------------------------------------------
>
> Key: SLING-649
> URL: https://issues.apache.org/jira/browse/SLING-649
> Project: Sling
> Issue Type: Improvement
> Components: Servlets Post
> Environment: Ubuntu AMD64 FF3
> Reporter: Renaud Richardet
> Priority: Minor
>
> I am trying to use checkboxes with the SlingPostServlet, as described in
> http://incubator.apache.org/sling/site/manipulating-content-the-slingpostservlet.html
> <form method="POST" action="/content/page/first">
> <input type="text" name="width" />
> <input type="hidden" name="wi...@typehint" value="Long" />
> <input type="checkbox" name="checked" />
> <input type="hidden" name="chec...@typehint" value="Boolean" />
> ...
> <input type="Submit" />
> </form>
> All elements work fine, excepte the checkbox: the "checked" node property is
> always set to false in JCR after a POST. Can anyone confirm?
> I guess it's because the POST request parameters are:
> width 1234
> wi...@typehint Long
> checked on
> chec...@typehint Boolean
> So, the passed checkbox parameter is "on" instead of "true"
> I guess I would have to modify SlingPropertyValueHandler.setPropertyAsIs() to
> handle "on" values as "true" if @TypeHint is Boolean. Similar to how dates
> values are handled if @TypeHint = date.
> If it's the right way to go, I will create a patch.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.