IntelliJ Java IDE
The moose likes JSF and the fly likes using Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "using "h:selectBooleanCheckbox" component" Watch "using "h:selectBooleanCheckbox" component" New topic
Author

using "h:selectBooleanCheckbox" component

Joe Greene
Greenhorn

Joined: May 16, 2007
Posts: 1
Hello -
I'm storing a flag/boolean property of a bean as an int (0 or 1) in my db, and want to render it using the <h:selectBooleanCheckbox component. When I try to load the page, of course, I get an error indicating that a boolean is expected, but I've got the property bound to the bean property of type int. Is there an easy way to provide automatic back-and-forth conversion for this property on both rendering and submitting, or will I need to write a custom converter? Thanks for any help.

- Joe
Daniel Rhoades
Ranch Hand

Joined: Jun 30, 2004
Posts: 186
Personally I'd deal with the property as a boolean in the bean and depending on your persistence mechanism do the conversion from Java boolean to SQL TINYINT when persisting/updating in your DAO/persistence classes.


Drinking more tea is the key...
 
 
subject: using "h:selectBooleanCheckbox" component
 
Threads others viewed
Enabling and disabling components via select checkbox
JSF - SelectManyListBox doesnt populate on valeChangeevent
If in JSF - Conditionaly displaying content
Using boolean value in SelectOneRadio
JSF - passing <f:param> from JSF to Backing Bean
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture