[jboss-user] [JBoss Seam] - Seam selectItems ignores label tag
hubaer
do-not-reply at jboss.com
Mon Jan 15 12:26:13 EST 2007
Hello,
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
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4001851#4001851
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4001851
More information about the jboss-user
mailing list