Using h:outputFormat to message-format the f:selectItems of a h:selectOneRadio

Posted by msharma on Stack Overflow See other posts from Stack Overflow or by msharma
Published on 2010-05-17T20:59:43Z Indexed on 2010/05/17 22:00 UTC
Read the original article Hit count: 211

Filed under:
|

I am having some trouble with using h:selectOneRadio. I have a list of objects which is being returned which needs to be displayed. I am trying something like this:

<h:selectOneRadio id="selectPlan" layout="pageDirection">
    <f:selectItems value="#{detailsHandler.planList}" />
</h:selectOneRadio>

and planList is a List of Plans. Plan is defined as:

public class Plan {
    protected String id;
    protected String partNumber;
    protected String shortName;
    protected String price;
    protected boolean isService;
    protected boolean isOption;  
    //With all getters/setters
}

The text that must appear for each radio button is actually in a properties file, and I need to insert params in the text to fill out some value in the bean. For example the text in my properties file is:

plan_price=The price of this plan is {0}.

I was hoping to do something like this:

<f:selectItems value="<h:outputFormat value="#{i18n.plan_price}">
    <f:param value="#{planHandler.price}">
</h:outputFormat>" />

Usually if it's not a h:selectOneRadio component, if it's just text I use the h:outputFormat along with f:param tags to display the messages in my .property file called i18n above, and insert a param which is in the backing bean. here this does not work. Does anyone have any ideas how I can deal with this?

I am being returned a list of Plans each with their own prices and the text to be displayed is held in property file. Any help much appreciated.

Thanks!

© Stack Overflow or respective owner

Related posts about jsf

Related posts about formatting