Seam selectItems ignores label tag
hubaer Jan 15, 2007 12:26 PMHello,
I tried to figure out how the selectItems component from seam works, but I wasn't very successful yet.
I tried out the examples but I can't figure out how I can transfer this to my application.
Here my scenario:
I have a List of Languages, that I want to display my web gui in a h:selectOneMenu.
I have extend my jsf, wrote a Converter, make a backing bean. The value of the option is set correct through the Converter, but for the description I get always the result of the toString() method. It seems that the label tag is ignored. I can write what ever I want and get always the toString()-result.
Maybe I have configured wrong.
Here some code fragements:
The jsp:
<h:selectOneMenu value="#{user.language}" converter="myLanguageConverter"> <si:selectItems value="#{languages}" var="language" label="#{language.isocode}"/> </h:selectOneMenu>
The backing bean:
public class EditUserInformationActionBean implements EditUserInformationAction, Serializable { @SelectItems private List<Language> languages; @Factory("languages") public void initLanguages() { languages = ItemHelper.initLanguage(); } ... }
The Converter:
public class LanguageConverter extends SelectItemsConverter { public LanguageConverter() { } public Object getAsObject(FacesContext context, UIComponent component, String value) throws ConverterException { throw new ConverterException("Method not supported"); } public String getAsString(FacesContext context, UIComponent component, Object value) throws ConverterException { if (null == value) { return ""; } if (value instanceof Language) { Language l = (Language) value; return formatLanguageString(l); } return ""; }
The language class:
public class Language implements Serializable { @Id @Column(name = "isocode", nullable = false) private String isocode; /** Creates a new instance of Language */ protected Language() { } // getter/setter, toString, equals etc.
The examples works fine. But I think there is an litte error, too. The discount drop-down-field has the descriptions "tenPercent", ""twentyPercent" and "twentyFivePercent", but I would expected the values from the message.properties (10%, 20% and 25%)
I hope someone could give me a hint what's wrong.
My System:
- WinXP Pro
- JBoss 4.0.5.GA
- Seam 1.1.0.GA
Tried:
- selectitems-1.1.1beta4
- selectitems-1.1.0rc2
Regards
Marco