Hello I want to show the add form page. when i click on button it throw that error. I am also using the @Named annotations because @ManagedBean annotations is deprecated. So Help me to solve out this error.
ProfessorController.java:
package databank.jsf;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import databank.dao.ListDataDao;
import databank.dao.ProfessorDao;
import databank.model.ProfessorPojo;
@Named("professorController")
@RequestScoped
public class ProfessorController implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
private Map<String, Object> sessionMap;
@Inject
private ProfessorDao professorDao;
@Inject
private ListDataDao listDataDao;
private List<ProfessorPojo> professors;
public void loadProfessors() {
setProfessors(professorDao.readAllProfessors());
}
public List<ProfessorPojo> getProfessors() {
return professors;
}
public void setProfessors(List<ProfessorPojo> professors) {
this.professors = professors;
}
public List<String> getDegrees() {
return listDataDao.readAllDegrees();
}
public List<String> getMajors() {
return listDataDao.readAllMajors();
}
public String navigateToAddForm() {
sessionMap.put("newProfessor", new ProfessorPojo());
return "add-professor.xhtml?faces-redirect=true";
}
public String submitProfessor(ProfessorPojo professor) {
professor.setCreated(LocalDateTime.now());
professorDao.createProfessor(professor);
return "list-professors.xhtml?faces-redirect=true";
}
public String navigateToUpdateForm(int professorId) {
ProfessorPojo professor = professorDao.readProfessorById(professorId);
sessionMap.put("editProfessor", professor);
return "edit-professor.xhtml?faces-redirect=true";
}
public String submitUpdatedProfessor(ProfessorPojo professor) {
professorDao.updateProfessor(professor);
return "list-professors.xhtml?faces-redirect=true";
}
public String deleteProfessor(int professorId) {
professorDao.deleteProfessorById(professorId);
return "list-professors.xhtml?faces-redirect=true";
}
public String editProfessor(int professorId) {
ProfessorPojo professor = professorDao.readProfessorById(professorId);
sessionMap.put("professorToEdit", professor);
return "edit-professors.xhtml?faces-redirect=true";
}
}
face-config.xml:
`<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd"
version="2.3">
<application>
<resource-bundle>
<base-name>Bundle</base-name>
<var>uiconsts</var>
</resource-bundle>
</application>
</faces-config>`
list-professors.xhtml:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html>
<html
lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:jsf="http://xmlns.jcp.org/jsf"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
>
<!-- Professor CRUD View -->
<h:head>
<!-- Title of tab/window in browser -->
<title>#{uiconsts['viewTitle']}</title>
<!-- Modern front-end artifacts such as CSS, JavaScript, etc. -->
<!-- Misc. table styles -->
<style>
table {
border: solid 1px #DDEEEE;
border-collapse: collapse;
border-spacing: 0;
table-layout: auto;
width: 95%;
}
table td {
border: solid 1px #DDEEEE;
}
table th {
border: solid 1px black;
background-color: #d8d8d8;
}
table tr:nth-child(even) {
background: #f2f2f2;
}
.table-hover tbody tr:hover td, .table-hover tbody tr:hover th {
background-color: #f0f0e0;
}
caption {
white-space: nowrap;
caption-side: bottom;
}
</style>
</h:head>
<h:body>
<h2>#{uiconsts['viewTitle']}</h2>
<br />
<h:form>
<!-- JavaScript onclick-handler cannot use 'map-style' uiconsts['something'], use 'properties-style' -->
<h:commandButton value="#{uiconsts['addButtonLabel']}" action="#{professorController.navigateToAddForm()}" />
<p/>
<h:dataTable value="#{professorController.professors}" action="#{professorController.loadProfessors()}" var="prof"
styleClass="table table-hover">
<h:column>
<f:facet name="header">#{uiconsts['columnLabel_Id']}</f:facet>
<h:outputText value="#{prof.id}"/>
</h:column>
<h:column>
<f:facet name="header">#{uiconsts['columnLabel_LastName']}</f:facet>
<h:outputText value="#{prof.lastName}"/>
</h:column>
<h:column>
<f:facet name="header">#{uiconsts['columnLabel_FirstName']}</f:facet>
<h:outputText value="#{prof.firstName}"/>
</h:column>
<h:column>
<f:facet name="header">#{uiconsts['columnLabel_Email']}</f:facet>
<h:outputText value="#{prof.email}"/>
</h:column>
<h:column>
<f:facet name="header">#{uiconsts['columnLabel_PhoneNumber']}</f:facet>
<h:outputText value="#{prof.phoneNumber}"/>
</h:column>
<h:column>
<f:facet name="header">#{uiconsts['columnLabel_Degree']}</f:facet>
<h:outputText value="#{prof.degree}"/>
</h:column>
<h:column>
<f:facet name="header">#{uiconsts['columnLabel_Major']}</f:facet>
<h:outputText value="#{prof.major}"/>
</h:column>
<h:column>
<f:facet name="header">#{uiconsts['columnLabel_Created']}</f:facet>
<h:outputText value="#{prof.created}"/>
</h:column>
<!--
Action column
you can add an action instead of onclick to edit button
-->
<h:column>
<f:facet name="header">#{uiconsts['columnLabel_Action']}</f:facet>
<h:commandButton value="#{uiconsts['editButtonLabel']}"
onclick ="if (!confirm('#{uiconsts.rus}')) return false"
action="#{professorController.navigateToUpdateForm(prof.id)}" />
 
<h:commandButton value="#{uiconsts['deleteButtonLabel']}"
onclick="if (!confirm('#{uiconsts.rus}')) return false"
action="#{professorController.deleteProfessor(prof.id)}" />
</h:column>
<f:facet name="caption">#{uiconsts['listCaption']} - Created by: #{uiconsts['footer.studentname']} #{uiconsts['footer.studentnumber']} #{uiconsts['footer.labsection']}</f:facet>
</h:dataTable>
</h:form>
</h:body>
</html>
I am also using the beans.xml file.
I am try to find the solution but not get a suitable solution. I am using Payara6 server for running this website.