2023-09-27 13:31:02 -05:00

120 lines
6.7 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>AuthorController.java</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
table {color: #888888; background-color: #313335; font-family: monospace}
.ST2 {color: #9876aa}
.ST3 {color: #ffc66d}
.string {color: #6a8759}
.comment {color: #808080}
.whitespace {color: #505050}
.ST4 {color: #9876aa; font-family: monospace; font-style: italic}
.ST1 {color: #808080; font-family: monospace; font-weight: bold}
.ST0 {color: #287bde}
.literal {color: #cc7832}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">/home/caleb/ASDV-WebDev/Semester 2/Assignments/lab6-f23_CalebFontenot/src/main/java/edu/slcc/asdv/beans/AuthorController.java</td></tr></table>
<pre>
<span class="comment">/*</span>
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt</span><span class="comment"> to change this license</span>
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/JSF/JSFManagedBean.java</span><span class="comment"> to edit this template</span>
<span class="comment"> */</span>
<span class="literal">package</span> edu.slcc.asdv.beans;
<span class="literal">import</span> edu.slcc.asdv.pojos.Author;
<span class="literal">import</span> jakarta.inject.Named;
<span class="literal">import</span> jakarta.enterprise.context.SessionScoped;
<span class="literal">import</span> java.io.Serializable;
<span class="literal">import</span> java.util.ArrayList;
<span class="literal">import</span> java.util.List;
<span class="comment">/**</span>
<span class="comment"> *</span>
<span class="comment"> * </span><span class="ST1">@author</span> <span class="comment">caleb</span>
<span class="comment">*/</span>
@Named(value = <span class="string">&quot;</span><span class="string">authorController</span><span class="string">&quot;</span>)
@SessionScoped
<span class="literal">public</span> <span class="literal">class</span> AuthorController <span class="literal">implements</span> Serializable {
<span class="literal">private</span> String <span class="ST2">newAuthorFirst</span>;
<span class="literal">public</span> AuthorController() {
populateAuthorList();
}
<span class="literal">private</span> String <span class="ST2">newAuthorLast</span>;
<span class="literal">public</span> String <span class="ST3">getNewAuthorLast</span>() {
<span class="literal">return</span> <span class="ST2">newAuthorLast</span>;
}
<span class="literal">public</span> <span class="literal">void</span> <span class="ST3">setNewAuthorLast</span>(String newAuthorLast) {
<span class="literal">this</span>.<span class="ST2">newAuthorLast</span> = newAuthorLast;
}
<span class="literal">private</span> <span class="literal">void</span> <span class="ST3">populateAuthorList</span>() {
<span class="ST2">authorList</span> = <span class="literal">new</span> ArrayList&lt;&gt;();
System.<span class="ST4">out</span>.println(<span class="string">&quot;</span><span class="string">Initializing Authors</span><span class="string">&quot;</span>);
<span class="ST2">authorList</span>.add(<span class="literal">new</span> Author(<span class="string">&quot;</span><span class="string">Josh</span><span class="string">&quot;</span>, <span class="string">&quot;</span><span class="string">Juno</span><span class="string">&quot;</span>, <span class="string">&quot;</span><span class="string">AKA JJ</span><span class="string">&quot;</span>));
<span class="ST2">authorList</span>.add(<span class="literal">new</span> Author(<span class="string">&quot;</span><span class="string">Carl</span><span class="string">&quot;</span>, <span class="string">&quot;</span><span class="string">Dea</span><span class="string">&quot;</span>, <span class="string">&quot;</span><span class="string">Inventor of the CD</span><span class="string">&quot;</span>));
}
<span class="literal">public</span> <span class="literal">void</span> <span class="ST3">addAuthor</span>() {
System.<span class="ST4">out</span>.println(<span class="string">&quot;</span><span class="string">Attempting to add author</span><span class="string">&quot;</span>);
<span class="literal">this</span>.getAuthorList().add(
<span class="literal">new</span> Author(<span class="literal">t</span><span class="literal">his</span>.getNewAuthorFirst(),
<span class="literal">t</span><span class="literal">his</span>.getNewAuthorLast(),
<span class="literal">t</span><span class="literal">his</span>.getBio()));
}
<span class="literal">public</span> String <span class="ST3">getNewAuthorFirst</span>() {
<span class="literal">return</span> <span class="ST2">newAuthorFirst</span>;
}
<span class="literal">public</span> <span class="literal">void</span> <span class="ST3">setNewAuthorFirst</span>(String newAuthorFirst) {
<span class="literal">this</span>.<span class="ST2">newAuthorFirst</span> = newAuthorFirst;
}
<span class="literal">private</span> String <span class="ST2">string</span>;
<span class="literal">public</span> String <span class="ST3">getString</span>() {
<span class="literal">return</span> <span class="ST2">string</span>;
}
<span class="literal">public</span> <span class="literal">void</span> <span class="ST3">setString</span>(String string) {
<span class="literal">this</span>.<span class="ST2">string</span> = string;
}
<span class="literal">private</span> String <span class="ST2">bio</span>;
<span class="literal">public</span> String <span class="ST3">getBio</span>() {
<span class="literal">return</span> <span class="ST2">bio</span>;
}
<span class="literal">public</span> <span class="literal">void</span> <span class="ST3">setBio</span>(String bio) {
<span class="literal">this</span>.<span class="ST2">bio</span> = bio;
}
<span class="literal">private</span> List&lt;Author&gt; <span class="ST2">authorList</span>;
<span class="literal">public</span> List&lt;Author&gt; <span class="ST3">getAuthorList</span>() {
<span class="literal">return</span> <span class="ST2">authorList</span>;
}
<span class="literal">public</span> <span class="literal">void</span> <span class="ST3">setAuthorList</span>(List&lt;Author&gt; authorList) {
<span class="literal">this</span>.<span class="ST2">authorList</span> = authorList;
}
}
</pre></body>
</html>