Friday, September 16, 2011

JSF Trick of the Day: <h:selectOneRadio/> #{true} or "true"

There is a question about which method is more correct assigning the value of a <h:selectOneRadio/> to use #{true} which is an Expression Language (EL) boolean true value, or using "true" to represent to represent the boolean in String form.

Well it turns out either way is correct. JavaServerFaces has implicit conversion between boolean values and its String representation. It is my personal preference to use #{true} which I like better since it better represents the binding method used to connect the page to its backing bean.

I have attached a copy of the NetBeans project: SelectOneRadioBoolean.zip.

 The example below demonstrates using both methods.

index.xhtml



IndexBean.java


0 comments :

Popular Posts