Facelet repeat Tag

This tag is used to iterate over the list of items. The name of list of items is specified by the EL expression in the value attribute of this tag. This tag contains two attributes "value" "name". The literal name specified in the name attribute is used to iterate over the items. In this example, we have used a bean named "TableBean" and info name is given to be used further. For ex., info.id, info.name used in value attribute of inputText JSF tag where id and name are attributes specified in bean. so here all id and names will be displayed.

Code Description :

repeat.xhtml :



xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html">

RoseIndia Facelet Tags Tutorial


Welcome to the Facelet world..........
















  • repeattemplate.xhtml :



    xmlns:ui="http://java.sun.com/jsf/facelets">

    facelet example





    TableBean.java :(Java Bean used for collection of items)

    package roseindia;

    public class TableBean {

    private perInfo[] perInfoAll = new perInfo[]{
    new perInfo(101, "CHANDAN", "9891444444", "aaa", 11111),
    new perInfo(102, "RAVI", "9911666666", "bbb" ,22222),
    new perInfo(103, "JOHN", "9313888888", "ccc", 33333),
    new perInfo(104, "ANDREW", "9911222222", "ddd" , 44444),
    new perInfo(105, "SYMONDS", "9313999999", "eee", 55555)
    };

    public perInfo[] getperInfoAll() {
    return perInfoAll;
    }

    public class perInfo {
    int id;
    String name;
    String phone;
    String city;
    int pin;

    public perInfo(int id, String name, String phone, String city, int pin) {
    this.id = id;
    this.name = name;
    this.phone = phone;
    this.city = city;
    this.pin= pin;
    }
    public int getid() {
    return id;
    }
    public String getname() {
    return name;
    }
    public String getphone() {
    return phone;
    }
    public String getcity() {
    return city;
    }
    public int getpin() {
    return pin;
    }
    }
    }

    Rendered Output :

    Html Source Code :





    RoseIndia Facelet Tags Tutorial


    Welcome to the Facelet world..........



    TR/xhtml1/DTD/xhtml1-transitional.dtd" >



    facelet example



    This is the list of ID and Names.

























  • This tag contains two attributes :

    value : This attribute specifies the list of items whose items are to be iterated. This is the EL expression.
    var : This attribute is used to give a name using that the iteration is done.

    0 comments:

    Post a Comment