|
List Info
Thread: SelectOneMenu text
|
|
| SelectOneMenu text |

|
2007-08-31 09:19:57 |
|
Hi all,
How I can get the selected text, not the code, of a <h:selectOneMenu component?
thanks
|
| Re: SelectOneMenu text |

|
2007-08-31 09:23:12 |
|
Hello Daniel,
I don't really understand your question. Can you be a bit more specific? If I understand well though, you could either change the value property of your SelectItem object, or loop through the SelectItem list until you find the one with the selected value to extract the description.
Regards,
~ Simon
On 8/31/07, daniel ccss < danielccss2 gmail.com">danielccss2 gmail.com> wrote:
Hi all,
How I can get the selected text, not the code, of a <h:selectOneMenu component?
thanks
|
| Re: SelectOneMenu text |

|
2007-08-31 09:25:27 |
|
Hi, sorry, yes the correct question is how to:
loop through the SelectItem list until find the one with the selected value to extract the description
Thanks
On 8/31/07,
Simon Lessard < simon.lessard.3 gmail.com">simon.lessard.3 gmail.com> wrote:
Hello Daniel,
I don't really understand your question. Can you be a bit more specific? If I understand well though, you could either change the value property of your SelectItem object, or loop through the SelectItem list until you find the one with the selected value to extract the description.
Regards,
~ Simon
On 8/31/07, daniel ccss < danielccss2 gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
danielccss2 gmail.com> wrote:
Hi all,
How I can get the selected text, not the code, of a <h:selectOneMenu component?
thanks
|
| Re: SelectOneMenu text |

|
2007-08-31 09:38:39 |
|
Ah ok,
It depends on the type of LoV you're using. If you're using a static lov (<f:selectItem/>), then you have to use a binding for your selectOneChoice component to your managed bean. Then, in your method, you simply have to loops through the selectOneMenu's children until you find the right UISelectItem. IF you use a dynamic LoV, it's simpler, as you simply have to call the methods returning the list of values and loops through all returned SelectItem objects.
Regards,
~ Simon
On 8/31/07, daniel ccss < danielccss2 gmail.com">danielccss2 gmail.com> wrote:
Hi, sorry, yes the correct question is how to:
loop through the SelectItem list until find the one with the selected value to extract the description
Thanks
On 8/31/07,
Simon Lessard < simon.lessard.3 gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">simon.lessard.3 gmail.com> wrote:
Hello Daniel,
I don't really understand your question. Can you be a bit more specific? If I understand well though, you could either change the value property of your SelectItem object, or loop through the SelectItem list until you find the one with the selected value to extract the description.
Regards,
~ Simon
On 8/31/07, daniel ccss < danielccss2 gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
danielccss2 gmail.com> wrote:
Hi all,
How I can get the selected text, not the code, of a <h:selectOneMenu component?
thanks
|
| Re: SelectOneMenu text |

|
2007-08-31 10:52:08 |
|
Sorry but what do you mean with LoV, can you give me some example code of the static and dynamic
On 8/31/07, Simon Lessard < simon.lessard.3 gmail.com">
simon.lessard.3 gmail.com> wrote:Ah ok,
It depends on the type of LoV you're using. If you're using a static lov (<f:selectItem/>), then you have to use a binding for your selectOneChoice component to your managed bean. Then, in your method, you simply have to loops through the selectOneMenu's children until you find the right UISelectItem. IF you use a dynamic LoV, it's simpler, as you simply have to call the methods returning the list of values and loops through all returned SelectItem objects.
Regards,
~ Simon
On 8/31/07, daniel ccss < danielccss2 gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
danielccss2 gmail.com> wrote:
Hi, sorry, yes the correct question is how to:
loop through the SelectItem list until find the one with the selected value to extract the description
Thanks
On 8/31/07,
Simon Lessard < simon.lessard.3 gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">simon.lessard.3 gmail.com> wrote:
Hello Daniel,
I don't really understand your question. Can you be a bit more specific? If I understand well though, you could either change the value property of your SelectItem object, or loop through the SelectItem list until you find the one with the selected value to extract the description.
Regards,
~ Simon
On 8/31/07, daniel ccss < danielccss2 gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
danielccss2 gmail.com> wrote:
Hi all,
How I can get the selected text, not the code, of a <h:selectOneMenu component?
thanks
|
| Re: SelectOneMenu text |

|
2007-08-31 11:51:13 |
|
LoV = List of Values.
In page.jspx Either <h:selectOneChoice binding="#{myBean.mySelector}" value="#{whatever}">
<f:selectItem itemValue="someValue" itemLabel="someText"/>
</h:selectOneChoice> or <h:selectOneChoice value="#{whatever}">
<f:selectItems value="#{myBean.listOfValues}"/>
</h:selectOneChoice>
In MyBeanClass.java Either public class MyBeanClass
{ private UISelectOne mySelector;
public UISelectOne getMySelector()
{ return mySelector;
}
public void setMySelector(UISelectOne
mySelector) { this.mySelector =
mySelector; }
public String getSelectedDescription() { Object selectedValue =
mySelector.getValue(); if (selectedValue == null)
{ return null; }
for (UIComponent child : (List<UIComponent>)
mySelector.getChildren()) { if (
selectedValue.equals(child.getItemValue())) {
return child.getItemLabel(); } } return null; // or throw an exception }
} or public class MyBeanClass
{
private List<SelectItem> listOfValues
;
public List<SelectItem> getListOfValues()
{
return listOfValues
;
}
public String getSelectedDescription()
{
Object selectedValue = mySelector.getValue();
if (selectedValue == null)
{
return null;
}
for (SelectItem item :
listOfValues)
{
if (selectedValue.equals(item.getValue()))
{
return item.getLabel();
}
}
return null; // or throw an exception
}
}
That being said, I'm very curious about the use case requiring that.
Regards,
~ Simon
On 8/31/07, daniel ccss < danielccss2 gmail.com">danielccss2 gmail.com> wrote:
Sorry but what do you mean with LoV, can you give me some example code of the static and dynamic
On 8/31/07,
Simon Lessard < simon.lessard.3 gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
simon.lessard.3 gmail.com> wrote:Ah ok,
It depends on the type of LoV you're using. If you're using a static lov (<f:selectItem/>), then you have to use a binding for your selectOneChoice component to your managed bean. Then, in your method, you simply have to loops through the selectOneMenu's children until you find the right UISelectItem. IF you use a dynamic LoV, it's simpler, as you simply have to call the methods returning the list of values and loops through all returned SelectItem objects.
Regards,
~ Simon
On 8/31/07, daniel ccss < danielccss2 gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
danielccss2 gmail.com> wrote:
Hi, sorry, yes the correct question is how to:
loop through the SelectItem list until find the one with the selected value to extract the description
Thanks
On 8/31/07,
Simon Lessard < simon.lessard.3 gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">simon.lessard.3 gmail.com> wrote:
Hello Daniel,
I don't really understand your question. Can you be a bit more specific? If I understand well though, you could either change the value property of your SelectItem object, or loop through the SelectItem list until you find the one with the selected value to extract the description.
Regards,
~ Simon
On 8/31/07, daniel ccss < danielccss2 gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
danielccss2 gmail.com> wrote:
Hi all,
How I can get the selected text, not the code, of a <h:selectOneMenu component?
thanks
|
| Re: SelectOneMenu text |

|
2007-08-31 14:23:33 |
|
Thanks!!!!! Yes I was using the <f:selectItems (second case), Thanks
On 8/31/07, Simon Lessard
< simon.lessard.3 gmail.com">simon.lessard.3 gmail.com> wrote:
LoV = List of Values.
In page.jspx Either <h:selectOneChoice binding="#{myBean.mySelector}" value="#{whatever}">
<f:selectItem itemValue="someValue" itemLabel="someText"/>
</h:selectOneChoice> or <h:selectOneChoice value="#{whatever}">
<f:selectItems value="#{myBean.listOfValues}"/>
</h:selectOneChoice>
In MyBeanClass.java Either public class MyBeanClass
{ private UISelectOne mySelector;
public UISelectOne getMySelector()
{ return mySelector;
}
public void setMySelector(UISelectOne
mySelector) { this.mySelector =
mySelector; }
public String getSelectedDescription() { Object selectedValue =
mySelector.getValue(); if (selectedValue == null)
{ return null; }
for (UIComponent child : (List<UIComponent>)
mySelector.getChildren()) { if (
selectedValue.equals(child.getItemValue())) {
return child.getItemLabel(); } } return null; // or throw an exception }
} or public class MyBeanClass
{
private List<SelectItem> listOfValues
;
public List<SelectItem> getListOfValues()
{
return listOfValues
;
}
public String getSelectedDescription()
{
Object selectedValue = mySelector.getValue();
if (selectedValue == null)
{
return null;
}
for (SelectItem item :
listOfValues)
{
if (selectedValue.equals(item.getValue()))
{
return item.getLabel();
}
}
return null; // or throw an exception
}
}
That being said, I'm very curious about the use case requiring that.
Regards,
~ Simon
On 8/31/07, daniel ccss < danielccss2 gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">danielccss2 gmail.com> wrote:
Sorry but what do you mean with LoV, can you give me some example code of the static and dynamic
On 8/31/07,
Simon Lessard < simon.lessard.3 gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
simon.lessard.3 gmail.com> wrote:Ah ok,
It depends on the type of LoV you're using. If you're using a static lov (<f:selectItem/>), then you have to use a binding for your selectOneChoice component to your managed bean. Then, in your method, you simply have to loops through the selectOneMenu's children until you find the right UISelectItem. IF you use a dynamic LoV, it's simpler, as you simply have to call the methods returning the list of values and loops through all returned SelectItem objects.
Regards,
~ Simon
On 8/31/07, daniel ccss < danielccss2 gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
danielccss2 gmail.com> wrote:
Hi, sorry, yes the correct question is how to:
loop through the SelectItem list until find the one with the selected value to extract the description
Thanks
On 8/31/07,
Simon Lessard < simon.lessard.3 gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">simon.lessard.3 gmail.com> wrote:
Hello Daniel,
I don't really understand your question. Can you be a bit more specific? If I understand well though, you could either change the value property of your SelectItem object, or loop through the SelectItem list until you find the one with the selected value to extract the description.
Regards,
~ Simon
On 8/31/07, daniel ccss < danielccss2 gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
danielccss2 gmail.com> wrote:
Hi all,
How I can get the selected text, not the code, of a <h:selectOneMenu component?
thanks
|
[1-7]
|
|