how to change the label on h:selectOneMenu

I'm passing a List of SelectItems to the f:selectItems tag

I want to use a converter to change the label of the selectItem Object.

but the converter Only changes the value and not the label

I tried to chane the UISelectItem Object Directly from the converter but the display is still the same and only the value is changed and not the label.

how Can I change the label ? anyone can help.

thanx

[431 byte] By [asafza] at [2007-10-2 13:46:00]
# 1
I'm still dont know how to do it.I think that I can change the renderer but Im not sure.help..
asafza at 2007-7-13 11:43:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Maybe it's my lack of imagination, but I can't think of a single practical use for converting a label to anything other than a String. What are you doing? It's the value of the label you should be ultimately interested in, isn't it?

Anyways, there's no easy way. Probably your rendered idea would work.

CowKing

IamCowKinga at 2007-7-13 11:43:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
> Anyways, there's no easy way. Probably your rendered> idea would work.Sorry, I meant your "renderer" idea.
IamCowKinga at 2007-7-13 11:43:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

the String is a code and the actual string that should be displayed should be read from a database resource bundle that is why I want to change the label value with the converter

for now I just set the Label from my Code to be the actual message and not the code but I thougt it would be nicer to do it with the converter

any idea hoe can i do it?

asafza at 2007-7-13 11:43:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

Can you add another field in your DB that has the label? Then set the label from the DB (get it as a String) as your label, and the code as your value.

Otherwise, you are a little stuck with programatically creating labels for every code you retrieve. Converters only work on the value of a select list.

A custom renderer in this case is not a good idea. It's a lot of work, and is not a direct solution to your problem. I mean, what if a new code gets created? Would you want to search hundreds of lines of code and add what is necessary, then redeploy your application, test, and more?

Anyways, personally, I think adding a "label" field to your DB is the best way.

CowKing

IamCowKinga at 2007-7-13 11:43:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...