/*_x000D_
 * To change this template, choose Tools | Templates_x000D_
 * and open the template in the editor._x000D_
 */_x000D_
// https://netbeans.org/kb/docs/web/hibernate-webapp.html_x000D_
package Hibernate;_x000D_
_x000D_
import java.util.List;_x000D_
import javax.faces.bean.ManagedBean;_x000D_
import javax.faces.bean.SessionScoped;_x000D_
import javax.faces.model.DataModel;_x000D_
import javax.faces.model.ListDataModel;_x000D_
_x000D_
/**_x000D_
 *_x000D_
 * @author Eusebius_x000D_
 */_x000D_
@ManagedBean_x000D_
@SessionScoped_x000D_
public class festivalManagedBean {_x000D_
_x000D_
    /**_x000D_
     * Creates a new instance of festivalManagedBean_x000D_
     */_x000D_
    _x000D_
    int startId;_x000D_
    int endId;_x000D_
    DataModel festivalNames;_x000D_
    festivalHelper helper;_x000D_
    private int recordCount = 2;_x000D_
    private int pageSize = 10;_x000D_
_x000D_
    private Festivals current;_x000D_
    private int selectedItemIndex;_x000D_
    _x000D_
    public festivalManagedBean() {_x000D_
        helper = new festivalHelper();_x000D_
        startId = 1;_x000D_
        endId = 10;_x000D_
    }_x000D_
_x000D_
    public festivalManagedBean(int startId, int endId) {_x000D_
        helper = new festivalHelper();_x000D_
        this.startId = startId;_x000D_
        this.endId = endId;_x000D_
    }_x000D_
_x000D_
    public Festivals getSelected() {_x000D_
        if (current == null) {_x000D_
            current = new Festivals();_x000D_
            selectedItemIndex = -1;_x000D_
        }_x000D_
        return current;_x000D_
    }_x000D_
_x000D_
_x000D_
    public DataModel getFestivalNames() {_x000D_
        if (festivalNames == null) {_x000D_
            festivalNames = new ListDataModel(helper.getFestivalNames(startId, endId));_x000D_
        }_x000D_
        return festivalNames;_x000D_
    }_x000D_
_x000D_
    void recreateModel() {_x000D_
        festivalNames = null;_x000D_
    }_x000D_
    _x000D_
     public boolean isHasNextPage() {_x000D_
        if (endId + pageSize <= recordCount) {_x000D_
            return true;_x000D_
        }_x000D_
        return false;_x000D_
    }_x000D_
_x000D_
    public boolean isHasPreviousPage() {_x000D_
        if (startId-pageSize > 0) {_x000D_
            return true;_x000D_
        }_x000D_
        return false;_x000D_
    }_x000D_
_x000D_
    public String next() {_x000D_
        startId = endId+1;_x000D_
        endId = endId + pageSize;_x000D_
        recreateModel();_x000D_
        return "index";_x000D_
    }_x000D_
_x000D_
    public String previous() {_x000D_
        startId = startId - pageSize;_x000D_
        endId = endId - pageSize;_x000D_
        recreateModel();_x000D_
        return "index";_x000D_
    }_x000D_
_x000D_
    public int getPageSize() {_x000D_
        return pageSize;_x000D_
    }_x000D_
_x000D_
    public String prepareView(){_x000D_
        current = (Festivals) getFestivalNames().getRowData();_x000D_
        return "browse";_x000D_
    }_x000D_
    public String prepareList(){_x000D_
        recreateModel();_x000D_
        return "index";_x000D_
    }_x000D_
    // alle bands van een bepaald festival ophalen en achter elkaar zetten_x000D_
     public String getBands() {_x000D_
        List bands = helper.getBandsByID(current.getFestId());_x000D_
        StringBuilder totalLineUp = new StringBuilder();_x000D_
        for (int i = 0; i < bands.size(); i++) {_x000D_
            Bands band = (Bands) bands.get(i);_x000D_
            totalLineUp.append(band.getBandNaam());_x000D_
            totalLineUp.append(" : ");_x000D_
            totalLineUp.append(band.getBandSoortMuziek());_x000D_
            totalLineUp.append("; ");_x000D_
        }_x000D_
        return totalLineUp.toString();_x000D_
    }_x000D_
    // alle tickets en hun prijs van een bepaald festival ophalen en achter elkaar zetten_x000D_
    public String getTicketypes() {_x000D_
        List tickets = helper.getTicketsByID(current.getFestId());_x000D_
        StringBuilder totalTickets = new StringBuilder();_x000D_
        for (int i = 0; i < tickets.size(); i++) {_x000D_
            Tickettypes ticket = (Tickettypes) tickets.get(i);_x000D_
            totalTickets.append(ticket.getTypOmschr());_x000D_
            totalTickets.append(" : €");_x000D_
            totalTickets.append(ticket.getTypPrijs().toString());_x000D_
            totalTickets.append("; ");_x000D_
        }_x000D_
        return totalTickets.toString();_x000D_
    }_x000D_
}_x000D_

// alle tickets en hun prijs van een bepaald festival ophalen en achter elkaar zetten_x000D_
/*_x000D_
 * To change this template, choose Tools | Templates_x000D_
 * and open the template in the editor._x000D_
 */_x000D_
// https://netbeans.org/kb/docs/web/hibernate-webapp.html_x000D_
package Hibernate;_x000D_
_x000D_
import java.util.List;_x000D_
import javax.faces.bean.ManagedBean;_x000D_
import javax.faces.bean.SessionScoped;_x000D_
import javax.faces.model.DataModel;_x000D_
import javax.faces.model.ListDataModel;_x000D_
_x000D_
/**_x000D_
 *_x000D_
 * @author Eusebius_x000D_
 */_x000D_
@ManagedBean_x000D_
@SessionScoped_x000D_
public class festivalManagedBean {_x000D_
_x000D_
    /**_x000D_
     * Creates a new instance of festivalManagedBean_x000D_
     */_x000D_
    _x000D_
    int startId;_x000D_
    int endId;_x000D_
    DataModel festivalNames;_x000D_
    festivalHelper helper;_x000D_
    private int recordCount = 2;_x000D_
    private int pageSize = 10;_x000D_
_x000D_
    private Festivals current;_x000D_
    private int selectedItemIndex;_x000D_
    _x000D_
    public festivalManagedBean() {_x000D_
        helper = new festivalHelper();_x000D_
        startId = 1;_x000D_
        endId = 10;_x000D_
    }_x000D_
_x000D_
    public festivalManagedBean(int startId, int endId) {_x000D_
        helper = new festivalHelper();_x000D_
        this.startId = startId;_x000D_
        this.endId = endId;_x000D_
    }_x000D_
_x000D_
    public Festivals getSelected() {_x000D_
        if (current == null) {_x000D_
            current = new Festivals();_x000D_
            selectedItemIndex = -1;_x000D_
        }_x000D_
        return current;_x000D_
    }_x000D_
_x000D_
_x000D_
    public DataModel getFestivalNames() {_x000D_
        if (festivalNames == null) {_x000D_
            festivalNames = new ListDataModel(helper.getFestivalNames(startId, endId));_x000D_
        }_x000D_
        return festivalNames;_x000D_
    }_x000D_
_x000D_
    void recreateModel() {_x000D_
        festivalNames = null;_x000D_
    }_x000D_
    _x000D_
     public boolean isHasNextPage() {_x000D_
        if (endId + pageSize <= recordCount) {_x000D_
            return true;_x000D_
        }_x000D_
        return false;_x000D_
    }_x000D_
_x000D_
    public boolean isHasPreviousPage() {_x000D_
        if (startId-pageSize > 0) {_x000D_
            return true;_x000D_
        }_x000D_
        return false;_x000D_
    }_x000D_
_x000D_
    public String next() {_x000D_
        startId = endId+1;_x000D_
        endId = endId + pageSize;_x000D_
        recreateModel();_x000D_
        return "index";_x000D_
    }_x000D_
_x000D_
    public String previous() {_x000D_
        startId = startId - pageSize;_x000D_
        endId = endId - pageSize;_x000D_
        recreateModel();_x000D_
        return "index";_x000D_
    }_x000D_
_x000D_
    public int getPageSize() {_x000D_
        return pageSize;_x000D_
    }_x000D_
_x000D_
    public String prepareView(){_x000D_
        current = (Festivals) getFestivalNames().getRowData();_x000D_
        return "browse";_x000D_
    }_x000D_
    public String prepareList(){_x000D_
        recreateModel();_x000D_
        return "index";_x000D_
    }_x000D_
    // alle bands van een bepaald festival ophalen en achter elkaar zetten_x000D_
     public String getBands() {_x000D_
        List bands = helper.getBandsByID(current.getFestId());_x000D_
        StringBuilder totalLineUp = new StringBuilder();_x000D_
        for (int i = 0; i < bands.size(); i++) {_x000D_
            Bands band = (Bands) bands.get(i);_x000D_
            totalLineUp.append(band.getBandNaam());_x000D_
            totalLineUp.append(" : ");_x000D_
            totalLineUp.append(band.getBandSoortMuziek());_x000D_
            totalLineUp.append("; ");_x000D_
        }_x000D_
        return totalLineUp.toString();_x000D_
    }_x000D_
    // alle tickets<SUF>
    public String getTicketypes() {_x000D_
        List tickets = helper.getTicketsByID(current.getFestId());_x000D_
        StringBuilder totalTickets = new StringBuilder();_x000D_
        for (int i = 0; i < tickets.size(); i++) {_x000D_
            Tickettypes ticket = (Tickettypes) tickets.get(i);_x000D_
            totalTickets.append(ticket.getTypOmschr());_x000D_
            totalTickets.append(" : €");_x000D_
            totalTickets.append(ticket.getTypPrijs().toString());_x000D_
            totalTickets.append("; ");_x000D_
        }_x000D_
        return totalTickets.toString();_x000D_
    }_x000D_
}_x000D_
