Friday, August 31, 2012

JSF2 Byte Boolean Checkbox

A few days ago I needed to convert old Icefaces 1.8.2 (JSF1.2) project to Icefaces 3.1 (JSF2) and found a problem when converting Byte to Boolean for the checkboxes. Byte value was generated by Hibernate from database and that is the model that already exists so we really cannot change that. The option with JSF1.2 was to implement Byte to Boolean converter and override rendering kit to call it. JSF2 does not allow this anymore or it is not working (expression library only coerces String to Boolean). After some research, the only option was to automatically generate Boolean getters and setters for existing files. Since there is quite a bit of them spread through different projects, I needed an utility to do this. I ended up writing a small Ruby application for this job. Here is the code:


This is by no means perfect code, but it did the job. If you have a better suggestion, please let me know!

Thanks

No comments:

Post a Comment