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<len;i++) {
      car.add(newCar[i]);
    }
  }
  public ArrayList getCarList() {
      return this.carList;
  }

  public void setCarList(ArrayList _carList) {
     this.carList = _carList;
  }
}


Regards,

        Kurt


on 12/8/2005 12:38 PM Simon Kitching stated:
[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:

<h:selectOneMenu id="selectCar"
 value="#{carBean.currentCar}">
  <f:selectItems
   value="#{carBean.carList}" />
</h:selectOneMenu>

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

Reply via email to