/home/caleb/ASDV-WebDev/Semester 2/Assignments/lab6-f23_CalebFontenot/src/main/java/edu/slcc/asdv/beans/AuthorController.java
/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/JSF/JSFManagedBean.java to edit this template
 */
package edu.slcc.asdv.beans;

import edu.slcc.asdv.pojos.Author;
import jakarta.inject.Named;
import jakarta.enterprise.context.SessionScoped;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author caleb
 */
@Named(value = "authorController")
@SessionScoped
public class AuthorController implements Serializable {

    private String newAuthorFirst;

    public AuthorController() {
        populateAuthorList();
    }

    private String newAuthorLast;

    public String getNewAuthorLast() {
        return newAuthorLast;
    }

    public void setNewAuthorLast(String newAuthorLast) {
        this.newAuthorLast = newAuthorLast;
    }

    private void populateAuthorList() {
        authorList = new ArrayList<>();
        System.out.println("Initializing Authors");
        authorList.add(new Author("Josh", "Juno", "AKA JJ"));
        authorList.add(new Author("Carl", "Dea", "Inventor of the CD"));
    }

    public void addAuthor() {
        System.out.println("Attempting to add author");
        this.getAuthorList().add(
                new Author(this.getNewAuthorFirst(),
                        this.getNewAuthorLast(),
                        this.getBio()));
    }

    public String getNewAuthorFirst() {
        return newAuthorFirst;
    }

    public void setNewAuthorFirst(String newAuthorFirst) {
        this.newAuthorFirst = newAuthorFirst;
    }

    private String string;

    public String getString() {
        return string;
    }

    public void setString(String string) {
        this.string = string;
    }

    private String bio;

    public String getBio() {
        return bio;
    }

    public void setBio(String bio) {
        this.bio = bio;
    }

    private List<Author> authorList;

    public List<Author> getAuthorList() {
        return authorList;
    }

    public void setAuthorList(List<Author> authorList) {
        this.authorList = authorList;
    }

}