List Info

Thread: SelectOneMenu text




SelectOneMenu text
user name
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
user name
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 < danielccss2gmail.com">danielccss2gmail.com> wrote:
Hi all,

How I can get the selected text, not the code, of a <h:selectOneMenu component?

thanks

Re: SelectOneMenu text
user name
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.3gmail.com">simon.lessard.3gmail.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 < danielccss2gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> danielccss2gmail.com> wrote:
Hi all,

How I can get the selected text, not the code, of a <h:selectOneMenu component?

thanks


Re: SelectOneMenu text
user name
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 < danielccss2gmail.com">danielccss2gmail.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.3gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">simon.lessard.3gmail.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 < danielccss2gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> danielccss2gmail.com> wrote:
Hi all,

How I can get the selected text, not the code, of a <h:selectOneMenu component?

thanks



Re: SelectOneMenu text
user name
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.3gmail.com"> simon.lessard.3gmail.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 < danielccss2gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> danielccss2gmail.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.3gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">simon.lessard.3gmail.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 < danielccss2gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> danielccss2gmail.com> wrote:
Hi all,

How I can get the selected text, not the code, of a <h:selectOneMenu component?

thanks




Re: SelectOneMenu text
user name
2007-08-31 11:51:13
LoV = List of Values.

In page.jspx
Either
<h:selectOneChoice binding=&quot;#{myBean.mySelector}" value=&quot;#{whatever}">;
  <f:selectItem itemValue="someValue" itemLabel="someText"/&gt;
</h:selectOneChoice>
or
<h:selectOneChoice value=&quot;#{whatever}">;
  <f:selectItems value=&quot;#{myBean.listOfValues}"/&gt;
</h:selectOneChoice>

In MyBeanClass.java
Either
public class MyBeanClass
{
  private UISelectOne mySelector;

  public UISelectOne getMySelector()
  {
 &nbsp;  return mySelector;
  }

  public void set
MySelector(UISelectOne mySelector)
  {
 &nbsp;  this.
mySelector = mySelector;
  }

  public String getSelectedDescription()
  {
 &nbsp;  Object selectedValue = mySelector.getValue();
 &nbsp;  if (
selectedValue == null)
   ; {
 &nbsp; &nbsp;  return null;
&nbsp; &nbsp; }

 &nbsp;  for (UIComponent child : (
List<UIComponent&gt;) mySelector.getChildren())
 &nbsp;  {
 &nbsp; &nbsp;  if (
selectedValue.equals(child.getItemValue()))
 &nbsp; &nbsp;  {
   ; &nbsp; &nbsp; return child.getItemLabel();
 &nbsp; &nbsp;  }
 &nbsp;  }
 
 &nbsp;  return null; // or throw an exception
  }
}
or
public class MyBeanClass
{
  private List<SelectItem>; listOfValues ;

  public List<SelectItem>; getListOfValues()
  {
 &nbsp;  return listOfValues ;
  }

&nbsp; public String getSelectedDescription()
 ; {
 &nbsp;  Object selectedValue = mySelector.getValue();
 &nbsp;  if (
selectedValue == null)
   ; {
   ; &nbsp; return null;
&nbsp; &nbsp; }

&nbsp; &nbsp; for (
SelectItem item : listOfValues)
   ; {
   ; &nbsp; if (
selectedValue.equals(item.getValue()))
 &nbsp; &nbsp;  {
   ; &nbsp; &nbsp; return item.getLabel();
&nbsp; &nbsp;   }
   ; }
 
 &nbsp;  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 < danielccss2gmail.com">danielccss2gmail.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.3gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> simon.lessard.3gmail.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 < danielccss2gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> danielccss2gmail.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.3gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">simon.lessard.3gmail.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 < danielccss2gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> danielccss2gmail.com> wrote:
Hi all,

How I can get the selected text, not the code, of a <h:selectOneMenu component?

thanks





Re: SelectOneMenu text
user name
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.3gmail.com">simon.lessard.3gmail.com> wrote:
LoV = List of Values.

In page.jspx
Either
<h:selectOneChoice binding=&quot;#{myBean.mySelector}" value=&quot;#{whatever}">;
  <f:selectItem itemValue="someValue" itemLabel="someText"/&gt;
</h:selectOneChoice>
or
<h:selectOneChoice value=&quot;#{whatever}">;
&nbsp; <f:selectItems value=&quot;#{myBean.listOfValues}"/&gt;
</h:selectOneChoice>

In MyBeanClass.java
Either
public class MyBeanClass
{
  private UISelectOne mySelector;

  public UISelectOne getMySelector()
  {
 &nbsp;  return mySelector;
  }

  public void set
MySelector(UISelectOne mySelector)
  {
 &nbsp;  this.
mySelector = mySelector;
  }

  public String getSelectedDescription()
  {
 &nbsp;  Object selectedValue = mySelector.getValue();
 &nbsp;  if (
selectedValue == null)
&nbsp; &nbsp; {
 &nbsp; &nbsp;  return null;
&nbsp; &nbsp; }

 &nbsp;  for (UIComponent child : (
List<UIComponent&gt;) mySelector.getChildren())
 &nbsp;  {
 &nbsp; &nbsp;  if (
selectedValue.equals(child.getItemValue()))
 &nbsp; &nbsp;  {
&nbsp; &nbsp; &nbsp; &nbsp; return child.getItemLabel();
 &nbsp; &nbsp;  }
 &nbsp;  }
 
 &nbsp;  return null; // or throw an exception
  }
}
or
public class MyBeanClass
{
  private List<SelectItem>; listOfValues ;

  public List<SelectItem>; getListOfValues()
  {
 &nbsp;  return listOfValues ;
  }

&nbsp; public String getSelectedDescription()
 ; {
 &nbsp;  Object selectedValue = mySelector.getValue();
 &nbsp;  if (
selectedValue == null)
   ; {
   ; &nbsp; return null;
&nbsp; &nbsp; }

&nbsp; &nbsp; for (
SelectItem item : listOfValues)
   ; {
   ; &nbsp; if (
selectedValue.equals(item.getValue()))
 &nbsp; &nbsp;  {
   ; &nbsp; &nbsp; return item.getLabel();
&nbsp; &nbsp;   }
   ; }
 
 &nbsp;  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 < danielccss2gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">danielccss2gmail.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.3gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> simon.lessard.3gmail.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 < danielccss2gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> danielccss2gmail.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.3gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">simon.lessard.3gmail.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 < danielccss2gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> danielccss2gmail.com> wrote:
Hi all,

How I can get the selected text, not the code, of a <h:selectOneMenu component?

thanks






[1-7]

about | contact  Other archives ( Real Estate discussion Medical topics )