Saturday 18 July 2015

Radio button as a cell editor for a column in Table UI element - Part 2

 We have seen creation of radio button in a table column. In case you have missed the part 1 of this tutorial here it is Part 1.

This post is all about how to save that radio buttons data in database table so that next time when one comes back to the application, previously selected radio buttons come selected for the user. Much in tune with the checkboxes thing. Though in general, we use radio button to select one option out of available ones, so in that case there is no need to save that data in database table, but still there are many scenarios where one would like to save the data for further use in some other component.

The idea would be to fill the value of the attribute, which is bind to the selectedKey poperty, in a way that it always holds one single value for the row whose radio button is selected. This coding we will do in the method which we have given for onSelect property of radio button.

So we will take base of the component which we have created in part 1 and we will add one button. On click of that, data will be saved in a database table. Next time when we will open the application, we will get the earlier saved data.

So in main view add one button and assign one method for onAction event.


Create one database table with below fields.

Add below logic in method for onAction event.

Paste below code in WDDOINIT method of the view.



Now go into the properties of radio button and for event onSelect create one mthod TOGGLE_RADIO_BTN. In that method add below lines of code.



Now test the application and also check the content of the database table. You will get the fair idea of the working of the radio buttons.








Happy Learning :)



No comments:

Post a Comment