Re: H:selectOneMenu question

2006-01-13 Thread Mikael Andersson
Hi,
you could use the style attribute.
style="width:150px;"

MickeOn 12/01/06, Yixing Ma <[EMAIL PROTECTED]> wrote:













Quick question,

 

 

How to change the width of a drop down list ?

 

H:selectOneMenu

 

 

I want to set
a fixed width to the drop down list. It trims off the empty spaces
automatically.

 

Thanks










Re: h:selectOneMenu question

2005-12-08 Thread Kurt Edegger

Hi Simon,

the exadel example jar actually runs without any problems and I don't 
see any custom converter configured.
I don't know why this is the case, this was the reason for starting this 
thread anyway ;)
I modified my classes to handle Strings in the getter and setters and 
now it works.
I still would like to know why the exadel example handles 
javax.faces.model.SelectItem directly.


Regards,

Kurt

on 12/8/2005 2:36 PM Simon Kitching stated:

Simon Kitching wrote:


Kurt Edegger wrote:



Let me post the carBean class to show that 'carBean.currentCar' 
accesses the SelectItem directly [1]:




Hmm..interesting. Thanks for posting that.


However I can't see any Converter class in MyFaces that is capable of 
doing String->SelectItem conversion. The Converter methods do get 
passed the associated UIComponent, so potentially such a converter 
could access its parent component in order to iterate over its child 
SelectItem objects.


It must be possible, as the example jar clearly does it. However I 
can't figure out *how* the UISelectOneMenu can use a value-binding 
dealing in SelectItem instances. I'd be very happy if someone could 
explain!


Of course, specifying the "value" binding as a primitive property 
(String/int/etc) works fine.



Looking at the official Sun javadoc for the SelectItem class, the 
getValue() method is defined as follows:



Return the value of this item, to be delivered to the model if this item 
is selected by the user.




This sure implies that the "value" attribute of the enclosing 
 should point to a property that takes objects of the 
same type as is returned by SelectItem.getValue(), rather than taking a 
complete SelectItem instance.


The MyFaces examples dir has "selectbox.jsp", whose backing bean is 
class CarConfigurator.java. This example always maps the select 
component's "value" attribute to primitive properties, eg

 public String getCar();
 public int getDoors();

Does the exadel example jar actually run?

Cheers,

Simon




Re: h:selectOneMenu question

2005-12-08 Thread Simon Kitching

Simon Kitching wrote:

Kurt Edegger wrote:


Let me post the carBean class to show that 'carBean.currentCar' 
accesses the SelectItem directly [1]:




Hmm..interesting. Thanks for posting that.


However I can't see any Converter class in MyFaces that is capable of 
doing String->SelectItem conversion. The Converter methods do get passed 
the associated UIComponent, so potentially such a converter could access 
its parent component in order to iterate over its child SelectItem objects.


It must be possible, as the example jar clearly does it. However I can't 
figure out *how* the UISelectOneMenu can use a value-binding dealing in 
SelectItem instances. I'd be very happy if someone could explain!


Of course, specifying the "value" binding as a primitive property 
(String/int/etc) works fine.


Looking at the official Sun javadoc for the SelectItem class, the 
getValue() method is defined as follows:



Return the value of this item, to be delivered to the model if this item 
is selected by the user.




This sure implies that the "value" attribute of the enclosing 
 should point to a property that takes objects of the 
same type as is returned by SelectItem.getValue(), rather than taking a 
complete SelectItem instance.


The MyFaces examples dir has "selectbox.jsp", whose backing bean is 
class CarConfigurator.java. This example always maps the select 
component's "value" attribute to primitive properties, eg

 public String getCar();
 public int getDoors();

Does the exadel example jar actually run?

Cheers,

Simon


Re: h:selectOneMenu question

2005-12-08 Thread Simon Kitching

Kurt Edegger wrote:

Simon,

unfortunately they don't have the sources published directly on this 
site but provide the jar file 
(http://www.exadel.com/tutorial/jsf/misc/jsftags-guide.jar)

to download.
Let me post the carBean class to show that 'carBean.currentCar' accesses 
the SelectItem directly [1]:


public class CarBean {


  //[1] carBean.currentCar accesses SelectItem
  public SelectItem getCurrentCar () {
 return new SelectItem("nissan-z","Nissan Z350","Nissan Z350 - 
sports");

  }


Hmm..interesting. Thanks for posting that.

The main classes involved here are
  HtmlSelectOneMenu : extends UISelectOne
  HtmlMenuRendererBase

What is contained in the request parameters on postback is definitely 
the "value" string associated with the selected  tag. The

 HtmlMenuRendererBase.decode
method calls
  HtmlRendererUtils.decodeUISelectOne
which just stores this string as the component's submittedValue. During 
the validation phase, method

  _SharedRendererUtils.findUIOutputConverter
is called to create a "converter" that maps the string into the 
appropriate type. This class inspects the type of the method specified 
by the "value" binding to determine the desired final type, then asks 
the Application object for an appropriate Converter.


However I can't see any Converter class in MyFaces that is capable of 
doing String->SelectItem conversion. The Converter methods do get passed 
the associated UIComponent, so potentially such a converter could access 
its parent component in order to iterate over its child SelectItem objects.


It must be possible, as the example jar clearly does it. However I can't 
figure out *how* the UISelectOneMenu can use a value-binding dealing in 
SelectItem instances. I'd be very happy if someone could explain!


Of course, specifying the "value" binding as a primitive property 
(String/int/etc) works fine.


Cheers,

Simon



Re: h:selectOneMenu question

2005-12-08 Thread Kurt Edegger

Simon,

unfortunately they don't have the sources published directly on this 
site but provide the jar file 
(http://www.exadel.com/tutorial/jsf/misc/jsftags-guide.jar)

to download.
Let me post the carBean class to show that 'carBean.currentCar' accesses 
the SelectItem directly [1]:


public class CarBean {

  ArrayList car = new ArrayList();
  ArrayList carList = new ArrayList();

  SelectItem currentCar;

  public CarBean()  {

carList.add(new SelectItem("accord","Honda Accord","Honda Accord - 
sedan"));
carList.add(new SelectItem("4runner","Toyota 4Runner","Toyota 
4Runner - suv"));
carList.add(new SelectItem("nissan-z","Nissan Z350","Nissan Z350 - 
sports"));

  }

  //[1] carBean.currentCar accesses SelectItem
  public SelectItem getCurrentCar () {
 return new SelectItem("nissan-z","Nissan Z350","Nissan Z350 - 
sports");

  }

  public void setCurrenteCar (SelectItem item) {
 currentCar = item;
  }

  public Object[] getCar() {
  return car.toArray();
  }

  public void setCar(Object[] newCar) {

int len=0;
if (null == newCar || ( len = newCar.length)==0 ) {
  return;
}
car.clear();
car = new ArrayList(len);
for ( int i=0;i
[EMAIL PROTECTED] wrote:


Simon,

thank you for your answer, I modified the getter/setter to handle
SelectItem.getValue().toString() instead of the selectItem itself.
But had you ever the chance to take a look at the jsftags-guide examples
(http://www.exadel.com/tutorial/jsf/jsftags-guide.html)?
They are using the SelectItems directly. Where's the difference?




The page shows this example:


  


But where does it say what datatype method getCurrentCar is returning?
I would think it returns String, eg "accord".

And likewise, I would expect setCurrentCar to take a String parameter, 
which will be one of "accord", "4runner", "nissan-z" depending on what 
the user chooses.



Regards,

Simon




Re: h:selectOneMenu question

2005-12-08 Thread Simon Kitching

[EMAIL PROTECTED] wrote:

Simon,

thank you for your answer, I modified the getter/setter to handle
SelectItem.getValue().toString() instead of the selectItem itself.
But had you ever the chance to take a look at the jsftags-guide examples
(http://www.exadel.com/tutorial/jsf/jsftags-guide.html)? 

They are using the SelectItems directly. 
Where's the difference?



The page shows this example:


  


But where does it say what datatype method getCurrentCar is returning?
I would think it returns String, eg "accord".

And likewise, I would expect setCurrentCar to take a String parameter, 
which will be one of "accord", "4runner", "nissan-z" depending on what 
the user chooses.



Regards,

Simon


Re: h:selectOneMenu question

2005-12-07 Thread mail
Simon,

thank you for your answer, I modified the getter/setter to handle
SelectItem.getValue().toString() instead of the selectItem itself.
But had you ever the chance to take a look at the jsftags-guide examples
(http://www.exadel.com/tutorial/jsf/jsftags-guide.html)? 

They are using the SelectItems directly. 
Where's the difference?

Kurt

Quoting Simon Kitching <[EMAIL PROTECTED]>:

> Kurt Edegger wrote:
> > Hi everybody,
> > 
> > I'd like to use a dropdown menu in my jsp page, therefor I added 
> > 
> > 
> >   
> >  
> > 
> > to my page. The bean provides getter and setters for both properties,
> whereby
> > currentItem is of type SelectItem and itemList is an ArrayList containing
> > SelectItems. 
> 
> I believe #{bean.currentItem} has to return a string that matches 
> SelectItem.getValue() of one of the SelectItems in the list.
> 
> And when an item in the list is selected, that property will be updated 
> to contain the getValue() value of the chosen SelectItem, not a 
> reference to the complete SelectItem object.
> 
> Regards,
> 
> Simon
> 






Re: h:selectOneMenu question

2005-12-07 Thread Simon Kitching

Kurt Edegger wrote:

Hi everybody,

I'd like to use a dropdown menu in my jsp page, therefor I added 



  
 


to my page. The bean provides getter and setters for both properties, whereby
currentItem is of type SelectItem and itemList is an ArrayList containing
SelectItems. 


I believe #{bean.currentItem} has to return a string that matches 
SelectItem.getValue() of one of the SelectItems in the list.


And when an item in the list is selected, that property will be updated 
to contain the getValue() value of the chosen SelectItem, not a 
reference to the complete SelectItem object.


Regards,

Simon