This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | Checkboxes do not reflect underlying data | ||
---|---|---|---|
Product: | obsolete | Reporter: | pncblessed <pncblessed> |
Component: | visualweb | Assignee: | Winston Prakash <wjprakash> |
Status: | RESOLVED FIXED | ||
Severity: | blocker | ||
Priority: | P2 | ||
Version: | 6.x | ||
Hardware: | Sun | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: |
Description
pncblessed
2008-04-15 14:16:49 UTC
Roman's findings: I tried and was able to reproduce. I just created table with one row, add checkbox to the page, DnD table onto checkbox and then choose BIT field in "Bind to Data" dialog. I has value '1' for this field, but checkbox wasn't checked. But I'm not sure that checkbox component should treat BIT values as correct values. Probably this component just treat BIT values as 'false' and that's all. We need to ask developer of this component. It all depends on how the BIT is mapped to a Java type by the JDBC provider. The recommended way is to map to boolean. http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/mapping.html If the type returned by MySQL JDBC is not of type boolean then binding to that column will not help. User need to create a getter/setter and manually. See my blog on this. http://blogs.sun.com/winston/entry/non_boolean_checkbox This does not qualify for a P1 per the bug priority guidelines. There is work around as documented in Winston's blog, so I am down grading this to P2. It doesn't seem like a component issue after all. If so, Winston, can you close this ? Do we need to get feedback from woodstock folks ? thanks Thank you all thats great. Jayashri, as I mentioned, if the JDBC driver does not return a particular column as boolean, then binding it directly to checkbox will not work. Checkbox as such is working correctly. In that case one should use an intermediate property in the Page bean (getter/setter) that would correctly convert the bit value as booelan and set back the boolean as bit value (to persist back in the database) as I mentioned in my blog. I'll close the bug, if I get confirmation from pncblessed that it is working. Okay I did try changing the Data type in the database to BOOLEAN and it still doesn't map. The problem is I have one table (USERS) with loads of boolean fields in them. Also it appears the PASSWORD componant fails to bind properly to a VARCHAR field or anything else. Incidentally if the check box is in a grid it binds without a problem. I think its a bug still not a feature. By the way thank you so much for all you are doing for us Netbeans users it is really really appreciated, I do love Netbeans and what I'm able to build with it and so does my firm! :-) Ok Another update - I also tried using the "Converter" field in properties to specify the database field as being a boolean but still to no avail. Ok here's how to make it work. 1. DO NOT use bind to data from the right click menu, it binds "SelectedValue" to the field which is not used. 2. Instead bind the property "Selected" for the checkbox to the database field. 3. In the Save code insert the following:- cachedRowSetDataProvider1.setValue("locations", new Boolean( checkbox5.getSelected().toString())); Checkbox5 is the checkbox locations is the field in the database I'm not setting it to fixed because really it still is a bug as the checkbox SHOULD bind to the underlying boolean field. Now fixed in the latest release of 6.1 patch upgrades. Set the SELECTED property to the database field Set the SELECTEDVALUE property to true Thanks everyone! |