修复IDE生成的getter的问题;添加登录等按钮

This commit is contained in:
高子兴 2024-07-14 15:24:17 +08:00
parent a26818f107
commit 7e25024e3e
2 changed files with 14 additions and 7 deletions

View File

@ -24,7 +24,7 @@ public class ProjectBean implements Serializable {
private UserInfo userInfo; // User info for the current user
private String username;
private String password;
private boolean isLoggedIn = false;
private Boolean isLoggedIn = false;
public String projectKeywords = ""; // String to hold project keywords
public String newKeyword = "";
public String projectCollaborators = ""; // String to hold project collaborators
@ -126,7 +126,11 @@ public class ProjectBean implements Serializable {
try {
ArrayList<Project> newProject = new ArrayList<>();
newProject.add(project);
projects.set(projectIdx,project);
if (projects.isEmpty()) {
projects.add(project);
} else {
projects.set(projectIdx, project);
}
databaseService.saveProjects(username, newProject);
context.addMessage("saveButton", new FacesMessage(FacesMessage.SEVERITY_INFO, "Submission Succeeded", null));
loadAllKeywords();
@ -252,11 +256,7 @@ public class ProjectBean implements Serializable {
this.newKeyword = newKeyword;
}
public boolean isLoggedIn() {
public Boolean getIsLoggedIn() {
return isLoggedIn;
}
public void setLoggedIn(boolean loggedIn) {
isLoggedIn = loggedIn;
}
}

View File

@ -20,6 +20,13 @@
<li><h:link value="Edit Projects" outcome="edit" rendered="#{not empty projectBean.username}"/></li>
</ul>
</nav>
<div style="position: absolute; top: 10px; right: 10px;">
<h:form>
<h:commandButton value="register" action="register" rendered="#{not projectBean.isLoggedIn}"/>
<h:commandButton value="login" action="login" rendered="#{not projectBean.isLoggedIn}"/>
<h:commandButton value="logout" action="#{projectBean.logout}" rendered="#{projectBean.isLoggedIn}"/>
</h:form>
</div>
</header>
</h:body>
</html>