You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Carlos Ortiz <co...@coral-technologies.com> on 2007/05/10 19:56:41 UTC

Problem with Datalist.

datalist is not render absoult nothing. any other jsf tag is working but 
this one [datalist] just dont render,I'm using the jars form the example 
download ,
any ideas. ¡?

   
> <f:view>
>
>                 <t:dataList var="car" value="#{carBean.lst}" 
> layout="grid" id="none" >
>                                 
>                         <t:outputText value="#{car.Id}"></t:outputText>
>                     
>                         <t:outputText value="#{car.Brand}"></t:outputText>
>                         
>                         <t:outputText value="#{car.Model}"></t:outputText>
>                         
>                         <t:outputText value="#{car.Name}"></t:outputText>
>                         
>                     
>                 
>                 </t:dataList>
>           
> </f:view>
the Car
public class SimpleCar {
    private int Id;
    private String Brand;
    private String Model;
    private String Name;
   
    public String getBrand() {
        return Brand;
    }
    public void setBrand(String brand) {
        Brand = brand;
    }
    public int getId() {
        return Id;
    }
    public void setId(int id) {
        Id = id;
    }
    public String getModel() {
        return Model;
    }
    public void setModel(String model) {
        Model = model;
    }
    public String getName() {
        return Name;
    }
    public void setName(String name) {
        Name = name;
    }
  
the car bean

import java.util.ArrayList;
import java.util.List;


public class CarBean {

 private List<SimpleCar> lst;

    public CarBean() {
        lst=new ArrayList<SimpleCar>();
        int i=0,current;
        for(;i<15;i++){
            SimpleCar tmp=new SimpleCar();
            tmp.setBrand("BMW");
            tmp.setId(i);
            tmp.setModel("X5");
            tmp.setName(String.valueOf(i)+tmp.getModel());
        }
        current=i;
        current+=15;
       
        for(;i<current;i++){
            SimpleCar tmp=new SimpleCar();
            tmp.setBrand("BMW");
            tmp.setId(i);
            tmp.setModel("Z32");
            tmp.setName(String.valueOf(i)+tmp.getModel());
        }
        current=i;
        current+=15;
        for(;i<current;i++){
            SimpleCar tmp=new SimpleCar();
            tmp.setBrand("Hyunday");
            tmp.setId(i);
            tmp.setModel("Elentra");
            tmp.setName(String.valueOf(i)+tmp.getModel());
        }
        current=i;
        current+=15;
        for(;i<current;i++){
            SimpleCar tmp=new SimpleCar();
            tmp.setBrand("Hyunday");
            tmp.setId(i);
            tmp.setModel("Getz");
            tmp.setName(String.valueOf(i)+tmp.getModel());
        }
        current=i;
        current+=15;
        for(;i<current;i++){
            SimpleCar tmp=new SimpleCar();
            tmp.setBrand("VolksWagen");
            tmp.setId(i);
            tmp.setModel("Polo");
            tmp.setName(String.valueOf(i)+tmp.getModel());
        }
        current=i;
        current+=15;
        for(;i<current;i++){
            SimpleCar tmp=new SimpleCar();
            tmp.setBrand("VolksWagen");
            tmp.setId(i);
            tmp.setModel("Jetta");
            tmp.setName(String.valueOf(i)+tmp.getModel());
        }
        current=i;
        current+=15;
        for(;i<current;i++){
            SimpleCar tmp=new SimpleCar();
            tmp.setBrand("Toyota");
            tmp.setId(i);
            tmp.setModel("Rav4");
            tmp.setName(String.valueOf(i)+tmp.getModel());
        }
       
        current=i;
        current+=15;
        for(;i<current;i++){
            SimpleCar tmp=new SimpleCar();
            tmp.setBrand("Toyota");
            tmp.setId(i);
            tmp.setModel("Corolla");
            tmp.setName(String.valueOf(i)+tmp.getModel());
        }
       
    }

    public List<SimpleCar> getLst() {
        return lst;
    }

    public void setLst(List<SimpleCar> lst) {
        this.lst = lst;
    }
 
   
 
 
 
}




Re: Problem with Datalist.

Posted by Carlos Ortiz <co...@coral-technologies.com>.
Solve , the properties of the beans must start in lowercase.
   private int Id;
   private String Brand;
   private String Model;
   private String Name;
must be
   private int id;
   private String brand;
   private String model;
   private String name;

   <t:outputText value="#{car.id}"></t:outputText>
   <t:outputText value="#{car.brand}"></t:outputText>
   <t:outputText value="#{car.model}"></t:outputText>
   <t:outputText value="#{car.name}"></t:outputText>

                                                                           
Carlos Ortiz escribió:
> datalist is not render absoult nothing. any other jsf tag is working 
> but this one [datalist] just dont render,I'm using the jars form the 
> example download ,
> any ideas. ¡?
>
>  
>> <f:view>
>>
>>                 <t:dataList var="car" value="#{carBean.lst}" 
>> layout="grid" id="none" >
>>                                                         <t:outputText 
>> value="#{car.Id}"></t:outputText>
>>                                             <t:outputText 
>> value="#{car.Brand}"></t:outputText>
>>                                                 <t:outputText 
>> value="#{car.Model}"></t:outputText>
>>                                                 <t:outputText 
>> value="#{car.Name}"></t:outputText>
>>                                                             
>>                 </t:dataList>
>>           </f:view>
> the Car
> public class SimpleCar {
>
>      public String getBrand() {
>        return Brand;
>    }
>    public void setBrand(String brand) {
>        Brand = brand;
>    }
>    public int getId() {
>        return Id;
>    }
>    public void setId(int id) {
>        Id = id;
>    }
>    public String getModel() {
>        return Model;
>    }
>    public void setModel(String model) {
>        Model = model;
>    }
>    public String getName() {
>        return Name;
>    }
>    public void setName(String name) {
>        Name = name;
>    }
>  
> the car bean
>
> import java.util.ArrayList;
> import java.util.List;
>
>
> public class CarBean {
>
> private List<SimpleCar> lst;
>
>    public CarBean() {
>        lst=new ArrayList<SimpleCar>();
>        int i=0,current;
>        for(;i<15;i++){
>            SimpleCar tmp=new SimpleCar();
>            tmp.setBrand("BMW");
>            tmp.setId(i);
>            tmp.setModel("X5");
>            tmp.setName(String.valueOf(i)+tmp.getModel());
>        }
>        current=i;
>        current+=15;
>              for(;i<current;i++){
>            SimpleCar tmp=new SimpleCar();
>            tmp.setBrand("BMW");
>            tmp.setId(i);
>            tmp.setModel("Z32");
>            tmp.setName(String.valueOf(i)+tmp.getModel());
>        }
>        current=i;
>        current+=15;
>        for(;i<current;i++){
>            SimpleCar tmp=new SimpleCar();
>            tmp.setBrand("Hyunday");
>            tmp.setId(i);
>            tmp.setModel("Elentra");
>            tmp.setName(String.valueOf(i)+tmp.getModel());
>        }
>        current=i;
>        current+=15;
>        for(;i<current;i++){
>            SimpleCar tmp=new SimpleCar();
>            tmp.setBrand("Hyunday");
>            tmp.setId(i);
>            tmp.setModel("Getz");
>            tmp.setName(String.valueOf(i)+tmp.getModel());
>        }
>        current=i;
>        current+=15;
>        for(;i<current;i++){
>            SimpleCar tmp=new SimpleCar();
>            tmp.setBrand("VolksWagen");
>            tmp.setId(i);
>            tmp.setModel("Polo");
>            tmp.setName(String.valueOf(i)+tmp.getModel());
>        }
>        current=i;
>        current+=15;
>        for(;i<current;i++){
>            SimpleCar tmp=new SimpleCar();
>            tmp.setBrand("VolksWagen");
>            tmp.setId(i);
>            tmp.setModel("Jetta");
>            tmp.setName(String.valueOf(i)+tmp.getModel());
>        }
>        current=i;
>        current+=15;
>        for(;i<current;i++){
>            SimpleCar tmp=new SimpleCar();
>            tmp.setBrand("Toyota");
>            tmp.setId(i);
>            tmp.setModel("Rav4");
>            tmp.setName(String.valueOf(i)+tmp.getModel());
>        }
>              current=i;
>        current+=15;
>        for(;i<current;i++){
>            SimpleCar tmp=new SimpleCar();
>            tmp.setBrand("Toyota");
>            tmp.setId(i);
>            tmp.setModel("Corolla");
>            tmp.setName(String.valueOf(i)+tmp.getModel());
>        }
>          }
>
>    public List<SimpleCar> getLst() {
>        return lst;
>    }
>
>    public void setLst(List<SimpleCar> lst) {
>        this.lst = lst;
>    }
>
>  
>
>
> }
>
>
>

Re: Problem with Datalist.

Posted by Carlos Ortiz <co...@coral-technologies.com>.
THX

David Delbecq escribió:
> Carlos Ortiz a écrit :
>   
>> datalist is not render absoult nothing. any other jsf tag is working
>> but this one [datalist] just dont render,I'm using the jars form the
>> example download ,
>> any ideas. ¡?
>>     
> basic thought: because list empty?
>   
>>  
>>     
>>> <f:view>
>>>
>>>                 <t:dataList var="car" value="#{carBean.lst}"
>>> layout="grid" id="none" >
>>>                                                         <t:outputText
>>> value="#{car.Id}"></t:outputText>
>>>       
> I think general convention uses #{car.id} not #{car.Id}. It shouldn't
> change behavious because EL parser uppercase itself first letter and
> adds get or set in front to have method name. However, id fits more java
> conventions for naming fields than Id. Same remark for Brand, Model and
> Name.
>   
>>>                                             <t:outputText
>>> value="#{car.Brand}"></t:outputText>
>>>                                                 <t:outputText
>>> value="#{car.Model}"></t:outputText>
>>>                                                 <t:outputText
>>> value="#{car.Name}"></t:outputText>
>>>                                                            
>>>                 </t:dataList>
>>>           </f:view>
>>>       
>> the Car
>> public class SimpleCar {
>>    private int Id;
>>    private String Brand; 
>>    private String Model;
>>    private String Name;
>>      public String getBrand() {
>>        return Brand;
>>    }
>>    public void setBrand(String brand) {
>>        Brand = brand;
>>    }
>>     
> Same remark here, java conventions is to use lowerCamelCase for fields,
> variables and method names and UpperCamelCase for class names.This way
> when you do something.x() and Something.y() you know you call method x
> on instance something and call static methid y() on class Something with
> looking up at declaration code :)
>   
>>    public int getId() {
>>        return Id;
>>    }
>>    public void setId(int id) {
>>        Id = id;
>>    }
>>    public String getModel() {
>>        return Model;
>>    }
>>    public void setModel(String model) {
>>        Model = model;
>>    }
>>    public String getName() {
>>        return Name;
>>    }
>>    public void setName(String name) {
>>        Name = name;
>>    }
>>  
>> the car bean
>>
>> import java.util.ArrayList;
>> import java.util.List;
>>
>>
>> public class CarBean {
>>
>> private List<SimpleCar> lst;
>>
>>    public CarBean() {
>>        lst=new ArrayList<SimpleCar>();
>>        int i=0,current;
>>        for(;i<15;i++){
>>            SimpleCar tmp=new SimpleCar();
>>            tmp.setBrand("BMW");
>>            tmp.setId(i);
>>            tmp.setModel("X5");
>>            tmp.setName(String.valueOf(i)+tmp.getModel());
>>        }
>>        current=i;
>>        current+=15;
>>              for(;i<current;i++){
>>            SimpleCar tmp=new SimpleCar();
>>            tmp.setBrand("BMW");
>>            tmp.setId(i);
>>            tmp.setModel("Z32");
>>            tmp.setName(String.valueOf(i)+tmp.getModel());
>>        }
>>        current=i;
>>        current+=15;
>>        for(;i<current;i++){
>>            SimpleCar tmp=new SimpleCar();
>>            tmp.setBrand("Hyunday");
>>            tmp.setId(i);
>>            tmp.setModel("Elentra");
>>            tmp.setName(String.valueOf(i)+tmp.getModel());
>>        }
>>        current=i;
>>        current+=15;
>>        for(;i<current;i++){
>>            SimpleCar tmp=new SimpleCar();
>>            tmp.setBrand("Hyunday");
>>            tmp.setId(i);
>>            tmp.setModel("Getz");
>>            tmp.setName(String.valueOf(i)+tmp.getModel());
>>        }
>>        current=i;
>>        current+=15;
>>        for(;i<current;i++){
>>            SimpleCar tmp=new SimpleCar();
>>            tmp.setBrand("VolksWagen");
>>            tmp.setId(i);
>>            tmp.setModel("Polo");
>>            tmp.setName(String.valueOf(i)+tmp.getModel());
>>        }
>>        current=i;
>>        current+=15;
>>        for(;i<current;i++){
>>            SimpleCar tmp=new SimpleCar();
>>            tmp.setBrand("VolksWagen");
>>            tmp.setId(i);
>>            tmp.setModel("Jetta");
>>            tmp.setName(String.valueOf(i)+tmp.getModel());
>>        }
>>        current=i;
>>        current+=15;
>>        for(;i<current;i++){
>>            SimpleCar tmp=new SimpleCar();
>>            tmp.setBrand("Toyota");
>>            tmp.setId(i);
>>            tmp.setModel("Rav4");
>>            tmp.setName(String.valueOf(i)+tmp.getModel());
>>        }
>>              current=i;
>>        current+=15;
>>        for(;i<current;i++){
>>            SimpleCar tmp=new SimpleCar();
>>            tmp.setBrand("Toyota");
>>            tmp.setId(i);
>>            tmp.setModel("Corolla");
>>            tmp.setName(String.valueOf(i)+tmp.getModel());
>>        }
>>          }
>>     
> Nice, lots of tmp SimpleCar but... Where do you store them? ;)
>   
>>    public List<SimpleCar> getLst() {
>>        return lst;
>>     
> Returns a brand new never use empty list ;)
>   
>>    }
>>
>>    public void setLst(List<SimpleCar> lst) {
>>        this.lst = lst;
>>    }
>>
>>  
>>
>>
>> }
>>
>>
>>
>>     
>
>   

Re: Problem with Datalist.

Posted by David Delbecq <de...@oma.be>.
Carlos Ortiz a écrit :
> datalist is not render absoult nothing. any other jsf tag is working
> but this one [datalist] just dont render,I'm using the jars form the
> example download ,
> any ideas. ¡?
basic thought: because list empty?
>
>  
>> <f:view>
>>
>>                 <t:dataList var="car" value="#{carBean.lst}"
>> layout="grid" id="none" >
>>                                                         <t:outputText
>> value="#{car.Id}"></t:outputText>
I think general convention uses #{car.id} not #{car.Id}. It shouldn't
change behavious because EL parser uppercase itself first letter and
adds get or set in front to have method name. However, id fits more java
conventions for naming fields than Id. Same remark for Brand, Model and
Name.
>>                                             <t:outputText
>> value="#{car.Brand}"></t:outputText>
>>                                                 <t:outputText
>> value="#{car.Model}"></t:outputText>
>>                                                 <t:outputText
>> value="#{car.Name}"></t:outputText>
>>                                                            
>>                 </t:dataList>
>>           </f:view>
> the Car
> public class SimpleCar {
>    private int Id;
>    private String Brand; 
>    private String Model;
>    private String Name;
>      public String getBrand() {
>        return Brand;
>    }
>    public void setBrand(String brand) {
>        Brand = brand;
>    }
Same remark here, java conventions is to use lowerCamelCase for fields,
variables and method names and UpperCamelCase for class names.This way
when you do something.x() and Something.y() you know you call method x
on instance something and call static methid y() on class Something with
looking up at declaration code :)
>    public int getId() {
>        return Id;
>    }
>    public void setId(int id) {
>        Id = id;
>    }
>    public String getModel() {
>        return Model;
>    }
>    public void setModel(String model) {
>        Model = model;
>    }
>    public String getName() {
>        return Name;
>    }
>    public void setName(String name) {
>        Name = name;
>    }
>  
> the car bean
>
> import java.util.ArrayList;
> import java.util.List;
>
>
> public class CarBean {
>
> private List<SimpleCar> lst;
>
>    public CarBean() {
>        lst=new ArrayList<SimpleCar>();
>        int i=0,current;
>        for(;i<15;i++){
>            SimpleCar tmp=new SimpleCar();
>            tmp.setBrand("BMW");
>            tmp.setId(i);
>            tmp.setModel("X5");
>            tmp.setName(String.valueOf(i)+tmp.getModel());
>        }
>        current=i;
>        current+=15;
>              for(;i<current;i++){
>            SimpleCar tmp=new SimpleCar();
>            tmp.setBrand("BMW");
>            tmp.setId(i);
>            tmp.setModel("Z32");
>            tmp.setName(String.valueOf(i)+tmp.getModel());
>        }
>        current=i;
>        current+=15;
>        for(;i<current;i++){
>            SimpleCar tmp=new SimpleCar();
>            tmp.setBrand("Hyunday");
>            tmp.setId(i);
>            tmp.setModel("Elentra");
>            tmp.setName(String.valueOf(i)+tmp.getModel());
>        }
>        current=i;
>        current+=15;
>        for(;i<current;i++){
>            SimpleCar tmp=new SimpleCar();
>            tmp.setBrand("Hyunday");
>            tmp.setId(i);
>            tmp.setModel("Getz");
>            tmp.setName(String.valueOf(i)+tmp.getModel());
>        }
>        current=i;
>        current+=15;
>        for(;i<current;i++){
>            SimpleCar tmp=new SimpleCar();
>            tmp.setBrand("VolksWagen");
>            tmp.setId(i);
>            tmp.setModel("Polo");
>            tmp.setName(String.valueOf(i)+tmp.getModel());
>        }
>        current=i;
>        current+=15;
>        for(;i<current;i++){
>            SimpleCar tmp=new SimpleCar();
>            tmp.setBrand("VolksWagen");
>            tmp.setId(i);
>            tmp.setModel("Jetta");
>            tmp.setName(String.valueOf(i)+tmp.getModel());
>        }
>        current=i;
>        current+=15;
>        for(;i<current;i++){
>            SimpleCar tmp=new SimpleCar();
>            tmp.setBrand("Toyota");
>            tmp.setId(i);
>            tmp.setModel("Rav4");
>            tmp.setName(String.valueOf(i)+tmp.getModel());
>        }
>              current=i;
>        current+=15;
>        for(;i<current;i++){
>            SimpleCar tmp=new SimpleCar();
>            tmp.setBrand("Toyota");
>            tmp.setId(i);
>            tmp.setModel("Corolla");
>            tmp.setName(String.valueOf(i)+tmp.getModel());
>        }
>          }
Nice, lots of tmp SimpleCar but... Where do you store them? ;)
>
>    public List<SimpleCar> getLst() {
>        return lst;
Returns a brand new never use empty list ;)
>    }
>
>    public void setLst(List<SimpleCar> lst) {
>        this.lst = lst;
>    }
>
>  
>
>
> }
>
>
>