Nils Playground
This commit is contained in:
commit
7a74507b9d
44 changed files with 1203 additions and 0 deletions
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
.idea/*
|
||||||
|
target/*
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
*.war
|
||||||
|
>>>>>>> 21f7771889fbd331d8067aeaacba276c2ab841e7
|
||||||
|
target/RotanaReg.war
|
||||||
|
com.rotanareg.skolan.iml
|
||||||
27
README.md
Normal file
27
README.md
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
# README
|
||||||
|
|
||||||
|
Project Java EE Kurs
|
||||||
|
|
||||||
|
## Hemsida för kursverksamhet
|
||||||
|
|
||||||
|
Bygga en hemsida där man kan lägga upp kurser registrera lärare och elever. Föra närvaro per lektionstillfälle. Varje användare kommer ha en login med rättigheter enligt nedan
|
||||||
|
|
||||||
|
Elev ska kunna:
|
||||||
|
|
||||||
|
- Registrera sig till en eller flera kurser
|
||||||
|
- Avregistrera sig till en kurs
|
||||||
|
- Se sin närvaro statistik
|
||||||
|
|
||||||
|
Lärare ska kunna:
|
||||||
|
|
||||||
|
- Se de kurser de håller inklusive elever
|
||||||
|
- Kunna föra närvaro för de kurser de håller
|
||||||
|
- Se närvaro statisk för de kurser de håller
|
||||||
|
|
||||||
|
Administrator ska kunna
|
||||||
|
|
||||||
|
- Registrera lärare och elever
|
||||||
|
- Lägga till kurser och ansluta lärare och elever
|
||||||
|
- Se närvaro statistik per kurs/elev ..
|
||||||
|
- Få daglig statistik på närvaro för alla kurser
|
||||||
|
- Ska kunna med JMS ”standalone” på närvaro
|
||||||
BIN
docs/20170818_mötet_fredag.jpg
Normal file
BIN
docs/20170818_mötet_fredag.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.3 MiB |
BIN
docs/Rotana-prototyp.pdf
Normal file
BIN
docs/Rotana-prototyp.pdf
Normal file
Binary file not shown.
BIN
docs/gitsetup.pdf
Normal file
BIN
docs/gitsetup.pdf
Normal file
Binary file not shown.
BIN
docs/gitworkflow.pdf
Normal file
BIN
docs/gitworkflow.pdf
Normal file
Binary file not shown.
58
pom.xml
Normal file
58
pom.xml
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>javaEE.x</groupId>
|
||||||
|
<artifactId>com.rotanareg.skolan</artifactId>
|
||||||
|
<packaging>war</packaging>
|
||||||
|
<name>RotanaReg</name>
|
||||||
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
<build>
|
||||||
|
<finalName>RotanaReg</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- https://mvnrepository.com/artifact/javax/javaee-api -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax</groupId>
|
||||||
|
<artifactId>javaee-api</artifactId>
|
||||||
|
<version>7.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.primefaces</groupId>
|
||||||
|
<artifactId>primefaces</artifactId>
|
||||||
|
<version>6.1</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.eclipse.persistence/org.eclipse.persistence.jpa -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.persistence</groupId>
|
||||||
|
<artifactId>org.eclipse.persistence.jpa</artifactId>
|
||||||
|
<version>2.6.4</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
22
src/main/java/com/rotanareg/skolan/Role.java
Normal file
22
src/main/java/com/rotanareg/skolan/Role.java
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.rotanareg.skolan;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Marko K. Seppänen.
|
||||||
|
*/
|
||||||
|
public enum Role {
|
||||||
|
STUDENT, TEACHER, ADMIN;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
switch (this) {
|
||||||
|
case STUDENT:
|
||||||
|
return "Student";
|
||||||
|
case TEACHER:
|
||||||
|
return "Teacher";
|
||||||
|
case ADMIN:
|
||||||
|
return "Admin";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "--not defined--"; // should never happen
|
||||||
|
}
|
||||||
|
}
|
||||||
28
src/main/java/com/rotanareg/skolan/course/Course.java
Normal file
28
src/main/java/com/rotanareg/skolan/course/Course.java
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.rotanareg.skolan.course;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public final class Course implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final long id;
|
||||||
|
private final String name;
|
||||||
|
private final String description;
|
||||||
|
|
||||||
|
public Course (long id, String name, String description){
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
}
|
||||||
35
src/main/java/com/rotanareg/skolan/course/CourseDetails.java
Normal file
35
src/main/java/com/rotanareg/skolan/course/CourseDetails.java
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.rotanareg.skolan.course;
|
||||||
|
|
||||||
|
import javax.faces.view.ViewScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Named
|
||||||
|
@ViewScoped
|
||||||
|
public class CourseDetails implements Serializable{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private CourseService courseService;
|
||||||
|
|
||||||
|
private long courseId;
|
||||||
|
|
||||||
|
private Course course;
|
||||||
|
|
||||||
|
public long getCourseId() {
|
||||||
|
return courseId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCourseId(long courseId) {
|
||||||
|
this.courseId = courseId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onload() {
|
||||||
|
course = courseService.getCourse(courseId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//public course getCourse() {
|
||||||
|
// return course;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.rotanareg.skolan.course;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface CourseService {
|
||||||
|
List<Course> getMostStudiedCourses ();
|
||||||
|
Course getCourse (long id);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.rotanareg.skolan.course;
|
||||||
|
|
||||||
|
import javax.enterprise.context.ApplicationScoped;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ApplicationScoped
|
||||||
|
public class CourseServiceImpl implements CourseService {
|
||||||
|
|
||||||
|
private final Map<Long, Course> courses;
|
||||||
|
|
||||||
|
private final List<Course> mostStudiedCourses;
|
||||||
|
|
||||||
|
public CourseServiceImpl (){
|
||||||
|
Map<Long, Course> map = new HashMap<>();
|
||||||
|
map.put(1L, new Course(1L,"Design och konstruktion av grafiska gränssnitt","Kursen innehåller en genomgång av standardklasserna i ett välutvecklat grafiskt bibliotek, en översikt över vilka riktlinjer som krävs för att skapa lättanvända gränssnitt samt metoder för att iterativt utveckla och förbättra ett gränssnitt. Kursen ger praktisk erfarenhet i implementering samt användbarhet genom ett grupprojekt som ger en fördjupning av delmomentet kring grafiska komponenter från kursen Objektorienterad programvaruutveckling. Projektets mål är att utveckla en applikation för en specifik användargrupp och att genom att låta dessa testa programmet iterativt förbättra det."));
|
||||||
|
map.put(2L, new Course(2L," Objektorienterad programmering","Grundläggande begrepp i objektorienterad programutveckling. Vad som skiljer det objektorienterade synsättet från andra synsätt.I kursen används programspråket Java. Momenten så som objekt och klass, datainkapsling,konstruktorer, metoder, instansvariabler, klassvariabler behandals men även modularisering av program, användning av dokumentation för standardbibliotek, användning av standardklasser för datasamlingar samt kodningsstandard, namnsättning och kommentering. Testning av program också ingår i kursen och det behandlas även arv, dynamisk bindning och polymorfism, abstrakta klasser och gränssnitt, grafiska användargränssnitt, händelser och lyssnare."));
|
||||||
|
map.put(3L, new Course(3L,"Datastrukturer","Abstrakta datatyper. Enkel komplexitetsanalys. Vanliga datastrukturer som fält, listor, träd och hashtabeller samt hur dessa kan användas för att implementera abstrakta datatyper som köer, prioritetsköer, lexika och grafer. Standardalgoritmer för dessa datastrukturer och deras resurskrav. Iteratorer. Sorteringsalgoritmer. Standardbibliotek för datastrukturer och algoritmer."));
|
||||||
|
|
||||||
|
courses =Collections.unmodifiableMap(map);
|
||||||
|
mostStudiedCourses = Collections.unmodifiableList(new ArrayList<>(courses.values()));
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public List<Course> getMostStudiedCourses() {
|
||||||
|
return mostStudiedCourses;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public Course getCourse (long id) {
|
||||||
|
return courses.get(id);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.rotanareg.skolan.course;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Named
|
||||||
|
@RequestScoped
|
||||||
|
public class MostStudiedCourses {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private com.rotanareg.skolan.course.CourseService courseService;
|
||||||
|
|
||||||
|
private List<Course> courses;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void initialize() {
|
||||||
|
courses = courseService.getMostStudiedCourses ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Course> getCourses() {
|
||||||
|
return courses;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.rotanareg.skolan.user;
|
||||||
|
|
||||||
|
import javax.validation.ConstraintValidator;
|
||||||
|
import javax.validation.ConstraintValidatorContext;
|
||||||
|
|
||||||
|
public class EmailAddressValidator implements ConstraintValidator<ValidEmailAddress, String> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(ValidEmailAddress constraintAnnotation) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid(String value, ConstraintValidatorContext context) {
|
||||||
|
return value == null || value.equals("") || value.contains("@");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
28
src/main/java/com/rotanareg/skolan/user/PhoneNumber.java
Normal file
28
src/main/java/com/rotanareg/skolan/user/PhoneNumber.java
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.rotanareg.skolan.user;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class PhoneNumber implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String countryCode;
|
||||||
|
private String subscriberNumber;
|
||||||
|
|
||||||
|
public String getCountryCode() {
|
||||||
|
return countryCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCountryCode(String countryCode) {
|
||||||
|
this.countryCode = countryCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getSubscriberNumber() {
|
||||||
|
return subscriberNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubscriberNumber(String subscriberNumber) {
|
||||||
|
this.subscriberNumber = subscriberNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.rotanareg.skolan.user;
|
||||||
|
|
||||||
|
import javax.faces.application.FacesMessage;
|
||||||
|
import javax.faces.component.UIComponent;
|
||||||
|
import javax.faces.context.FacesContext;
|
||||||
|
import javax.faces.convert.Converter;
|
||||||
|
import javax.faces.convert.ConverterException;
|
||||||
|
import javax.faces.convert.FacesConverter;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@FacesConverter(forClass = PhoneNumber.class)
|
||||||
|
public class PhoneNumberConverter implements Converter {
|
||||||
|
|
||||||
|
private static final Pattern PHONE_NUMBER_PATTERN = Pattern.compile("[0-8]{2}-[0-8]{3}-[0-8]{3}");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getAsObject(FacesContext context, UIComponent component, String value) {
|
||||||
|
if (value == null || value.equals("")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!PHONE_NUMBER_PATTERN.matcher(value).matches()) {
|
||||||
|
throw new ConverterException(
|
||||||
|
new FacesMessage("Fyll i det rätta formen på telefonummer: 00-000-000."));
|
||||||
|
}
|
||||||
|
|
||||||
|
PhoneNumber phoneNumber = new PhoneNumber();
|
||||||
|
phoneNumber.setCountryCode(value.substring(0, 2));
|
||||||
|
phoneNumber.setSubscriberNumber(value.substring(3));
|
||||||
|
|
||||||
|
return phoneNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAsString(FacesContext context, UIComponent component, Object value) {
|
||||||
|
if (value == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
PhoneNumber phoneNumber = (PhoneNumber) value;
|
||||||
|
|
||||||
|
return phoneNumber.getCountryCode() + "-" + phoneNumber.getSubscriberNumber();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.rotanareg.skolan.user;
|
||||||
|
|
||||||
|
import javax.faces.application.FacesMessage;
|
||||||
|
import javax.faces.component.UIComponent;
|
||||||
|
import javax.faces.context.FacesContext;
|
||||||
|
import javax.faces.validator.FacesValidator;
|
||||||
|
import javax.faces.validator.Validator;
|
||||||
|
import javax.faces.validator.ValidatorException;
|
||||||
|
|
||||||
|
|
||||||
|
@FacesValidator("com.rotanareg.skolan.user.PhoneNumber")
|
||||||
|
public class PhoneNumberValidator implements Validator {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
|
||||||
|
PhoneNumber phoneNumber = (PhoneNumber) value;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (phoneNumber != null) {
|
||||||
|
checkCountryCode(phoneNumber.getCountryCode());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkCountryCode(String countryCode) {
|
||||||
|
int firstDigit = Character.digit(countryCode.charAt(0), 10);
|
||||||
|
if (firstDigit == 0 || firstDigit == 1) {
|
||||||
|
throw new ValidatorException(
|
||||||
|
new FacesMessage("Första siffran i ditt tfn får inte vara 0 or 1."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
42
src/main/java/com/rotanareg/skolan/user/SignIn.java
Normal file
42
src/main/java/com/rotanareg/skolan/user/SignIn.java
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.rotanareg.skolan.user;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.validation.constraints.Pattern;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
|
@Named
|
||||||
|
@RequestScoped
|
||||||
|
public class SignIn {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private UserManager userManager;
|
||||||
|
|
||||||
|
@Pattern(regexp = "[A-Za-z0-9]{2,20}", message = "Användarnamnet skall innehålla bara bokstäver och siffror samt vara långt mellan 2 och 20 tecken.")
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@Size(min = 8, message = "Ditt password måste innehålla minst 8 tecken.")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String submit() {
|
||||||
|
return userManager.signIn(username, password);
|
||||||
|
}
|
||||||
|
}
|
||||||
102
src/main/java/com/rotanareg/skolan/user/User.java
Normal file
102
src/main/java/com/rotanareg/skolan/user/User.java
Normal file
|
|
@ -0,0 +1,102 @@
|
||||||
|
package com.rotanareg.skolan.user;
|
||||||
|
|
||||||
|
import com.rotanareg.skolan.Role;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class User implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
private String firstName;
|
||||||
|
private String lastName;
|
||||||
|
private String emailAddress;
|
||||||
|
private String phoneNumber;
|
||||||
|
private Date birthDate;
|
||||||
|
private Role role;
|
||||||
|
private List<Role> rolesList;
|
||||||
|
|
||||||
|
public User(){
|
||||||
|
rolesList = new ArrayList();
|
||||||
|
rolesList.add(Role.STUDENT);
|
||||||
|
rolesList.add(Role.TEACHER);
|
||||||
|
rolesList.add(Role.ADMIN);
|
||||||
|
role = Role.STUDENT; // set the first role as default
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFirstName() {
|
||||||
|
return firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirstName(String firstName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastName() {
|
||||||
|
return lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastName(String lastName) {
|
||||||
|
this.lastName = lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmailAddress() {
|
||||||
|
return emailAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmailAddress(String emailAddress) {
|
||||||
|
this.emailAddress = emailAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPhoneNumber() {
|
||||||
|
return phoneNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhoneNumber(String phoneNumber) {
|
||||||
|
this.phoneNumber = phoneNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getBirthDate() {
|
||||||
|
return birthDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBirthDate(Date birthDate) {
|
||||||
|
this.birthDate = birthDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Role getRole() {
|
||||||
|
return role;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRole(Role role) {
|
||||||
|
this.role = role;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Role> getRolesList() {
|
||||||
|
return rolesList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
30
src/main/java/com/rotanareg/skolan/user/UserDetail.java
Normal file
30
src/main/java/com/rotanareg/skolan/user/UserDetail.java
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.rotanareg.skolan.user;
|
||||||
|
|
||||||
|
|
||||||
|
import javax.faces.view.ViewScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import java.io.Serializable;
|
||||||
|
@Named
|
||||||
|
@ViewScoped
|
||||||
|
public class UserDetail implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private UserManager userManager;
|
||||||
|
|
||||||
|
private User user;
|
||||||
|
|
||||||
|
public User getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onload() {
|
||||||
|
user = userManager.isSignedIn() ? userManager.getCurrentUser() : new User();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String submit() {
|
||||||
|
return userManager.save(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
54
src/main/java/com/rotanareg/skolan/user/UserManager.java
Normal file
54
src/main/java/com/rotanareg/skolan/user/UserManager.java
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
package com.rotanareg.skolan.user;
|
||||||
|
|
||||||
|
import javax.enterprise.context.SessionScoped;
|
||||||
|
import javax.faces.application.FacesMessage;
|
||||||
|
import javax.faces.context.FacesContext;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Named
|
||||||
|
@SessionScoped // Marko jobbar på
|
||||||
|
public class UserManager implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
|
private User currentUser;
|
||||||
|
|
||||||
|
public boolean isSignedIn() {
|
||||||
|
return currentUser != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User getCurrentUser() {
|
||||||
|
return currentUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String signIn(String username, String password) {
|
||||||
|
User user = userService.getUser(username);
|
||||||
|
if (user == null || !password.equals(user.getPassword())) {
|
||||||
|
FacesContext.getCurrentInstance().addMessage(null,
|
||||||
|
new FacesMessage("Skriv in ditt användarnamn och password"));
|
||||||
|
return "failure";
|
||||||
|
}
|
||||||
|
|
||||||
|
currentUser = user;
|
||||||
|
return "success";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void signOut() {
|
||||||
|
|
||||||
|
FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
|
||||||
|
//return "index?faces-redirect =true";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String save(User user) {
|
||||||
|
userService.saveUser(user);
|
||||||
|
currentUser = user;
|
||||||
|
return "index";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
9
src/main/java/com/rotanareg/skolan/user/UserService.java
Normal file
9
src/main/java/com/rotanareg/skolan/user/UserService.java
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.rotanareg.skolan.user;
|
||||||
|
|
||||||
|
public interface UserService {
|
||||||
|
// get information om användare
|
||||||
|
User getUser(String username);
|
||||||
|
|
||||||
|
// spara information om användare
|
||||||
|
void saveUser(User user);
|
||||||
|
}
|
||||||
23
src/main/java/com/rotanareg/skolan/user/UserServiceImpl.java
Normal file
23
src/main/java/com/rotanareg/skolan/user/UserServiceImpl.java
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.rotanareg.skolan.user;
|
||||||
|
|
||||||
|
import javax.enterprise.context.ApplicationScoped;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
@ApplicationScoped // skall stored i databas
|
||||||
|
public class UserServiceImpl implements UserService {
|
||||||
|
|
||||||
|
|
||||||
|
private final Map<String, User> users = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public User getUser(String username) {
|
||||||
|
return users.get(username);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveUser(User user) {
|
||||||
|
users.put(user.getUsername(), user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.rotanareg.skolan.user;
|
||||||
|
|
||||||
|
import javax.validation.Constraint;
|
||||||
|
import javax.validation.Payload;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Constraint(validatedBy = EmailAddressValidator.class)
|
||||||
|
@Target(ElementType.FIELD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface ValidEmailAddress {
|
||||||
|
|
||||||
|
String message() default "Skriv din rätta e-mail adressen.";
|
||||||
|
|
||||||
|
Class<?>[] groups() default {};
|
||||||
|
|
||||||
|
Class<? extends Payload>[] payload() default {};
|
||||||
|
}
|
||||||
19
src/main/resources/META-INF/persistence.xml
Normal file
19
src/main/resources/META-INF/persistence.xml
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
|
||||||
|
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
|
||||||
|
|
||||||
|
<persistence-unit name="nameDB" transaction-type="JTA"> <!--same name as in emf definition-->
|
||||||
|
|
||||||
|
<jta-data-source>jdbc/person</jta-data-source> <!--This resource has to be added to GlassFish-->
|
||||||
|
<exclude-unlisted-classes>false</exclude-unlisted-classes>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<!-- <property name="javax.persistence.schema-generation.database.action" value="create"/> -->
|
||||||
|
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</persistence-unit>
|
||||||
|
</persistence>
|
||||||
7
src/main/webapp/WEB-INF/faces-config.xml
Normal file
7
src/main/webapp/WEB-INF/faces-config.xml
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<faces-config version="2.2" 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_2.xsd">
|
||||||
|
|
||||||
|
</faces-config>
|
||||||
29
src/main/webapp/WEB-INF/web.xml
Normal file
29
src/main/webapp/WEB-INF/web.xml
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="http://java.sun.com/xml/ns/javaee"
|
||||||
|
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
|
||||||
|
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||||
|
version="2.5">
|
||||||
|
|
||||||
|
<description>MyProject web.xml</description>
|
||||||
|
|
||||||
|
<!-- Faces Servlet -->
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>Faces Servlet</servlet-name>
|
||||||
|
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
|
||||||
|
<load-on-startup>1</load-on-startup>
|
||||||
|
</servlet>
|
||||||
|
|
||||||
|
<!-- Faces Servlet Mapping -->
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>Faces Servlet</servlet-name>
|
||||||
|
<url-pattern>*.xhtml</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<!-- Welcome files -->
|
||||||
|
<welcome-file-list>
|
||||||
|
<welcome-file>index.xhtml</welcome-file>
|
||||||
|
</welcome-file-list>
|
||||||
|
|
||||||
|
</web-app>
|
||||||
32
src/main/webapp/admin.xhtml
Normal file
32
src/main/webapp/admin.xhtml
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||||
|
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||||
|
|
||||||
|
<ui:composition template="templates/template_page.xhtml">
|
||||||
|
<ui:param name="pageTitle" value="Admin sidan"/>
|
||||||
|
|
||||||
|
|
||||||
|
<ui:define name="panel-top">
|
||||||
|
<section>
|
||||||
|
<h:outputLink value="user_detail.xhtml">Registrera nya användare</h:outputLink>
|
||||||
|
<p> </p>
|
||||||
|
<h:outputLink value="create_course.xhtml">Registrera nya kurser</h:outputLink>
|
||||||
|
</section>
|
||||||
|
</ui:define>
|
||||||
|
|
||||||
|
|
||||||
|
<ui:define name="panel-main">
|
||||||
|
<section>
|
||||||
|
<h1>här kommer mer</h1>
|
||||||
|
|
||||||
|
|
||||||
|
</section>
|
||||||
|
</ui:define>
|
||||||
|
</ui:composition>
|
||||||
|
|
||||||
|
|
||||||
|
</html>
|
||||||
58
src/main/webapp/contracts/device/style.css
Normal file
58
src/main/webapp/contracts/device/style.css
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
html {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
font-family: Tahoma, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
margin: 0 0 8px 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 8px 0 0 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
input, button,select {
|
||||||
|
font-family: Tahoma, sans-serif;
|
||||||
|
font-size: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body > header {
|
||||||
|
padding: 16px;
|
||||||
|
clear: both;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 200%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body > header > h1 {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body > section , body > form > section{
|
||||||
|
margin: 8px 20%;
|
||||||
|
padding: 18px;
|
||||||
|
overflow: hidden;
|
||||||
|
.bild
|
||||||
|
background-image: url("testBild2.jpg");
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: cover;
|
||||||
|
background-position: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body > footer {
|
||||||
|
padding: 8px;
|
||||||
|
clear: both;
|
||||||
|
font-size: 13px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
body > footer > p {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
45
src/main/webapp/contracts/theme/blueheven.css
Normal file
45
src/main/webapp/contracts/theme/blueheven.css
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
body {
|
||||||
|
background-color: rgba(118, 203, 224, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
a:link, a:visited {
|
||||||
|
color: #8d52a0;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover, a:active {
|
||||||
|
color: #76cbe0;
|
||||||
|
}
|
||||||
|
|
||||||
|
input, select {
|
||||||
|
background-color: #ffffff;
|
||||||
|
color: #000000;
|
||||||
|
border: 1px solid #396280;
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
option {
|
||||||
|
background-color: white;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
input[readonly] {
|
||||||
|
color: #808080;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="submit"], input[type="button"] {
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 4px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body > header {
|
||||||
|
background-color: #2badca;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
body > section, body > form > section {
|
||||||
|
background-color: rgba(114, 207, 179, 0.38);
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
body > footer {
|
||||||
|
background-color: #2badca;
|
||||||
|
color: #e5e5e5;
|
||||||
|
}
|
||||||
11
src/main/webapp/course.xhtml
Normal file
11
src/main/webapp/course.xhtml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||||
|
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||||
|
<f:view>
|
||||||
|
<h:outputLabel value="Hello, world"/>
|
||||||
|
</f:view>
|
||||||
|
</html>
|
||||||
25
src/main/webapp/course_details.xhtml
Normal file
25
src/main/webapp/course_details.xhtml
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||||
|
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||||
|
|
||||||
|
<ui:composition template="templates/template_page.xhtml">
|
||||||
|
<f:metadata>
|
||||||
|
<f:viewParam name ="courseId" value="#{courseDetails.courseId}"/>
|
||||||
|
<f:viewAction action="#{courseDetails.onload}"/>
|
||||||
|
</f:metadata>
|
||||||
|
|
||||||
|
<ui:param name="pageTitle" value="Course Details"/>
|
||||||
|
<ui:define name="panel-main">
|
||||||
|
<section class="course_details">
|
||||||
|
<h:form>
|
||||||
|
<h1>#{courseDetails.course.name}</h1>
|
||||||
|
<p>#{courseDetails.course.description}</p>
|
||||||
|
</h:form>
|
||||||
|
</section>
|
||||||
|
</ui:define>
|
||||||
|
</ui:composition>
|
||||||
|
</html>
|
||||||
11
src/main/webapp/create_course.xhtml
Normal file
11
src/main/webapp/create_course.xhtml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||||
|
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||||
|
<f:view>
|
||||||
|
<h:outputLabel value="Hello, world"/>
|
||||||
|
</f:view>
|
||||||
|
</html>
|
||||||
19
src/main/webapp/index.xhtml
Normal file
19
src/main/webapp/index.xhtml
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||||
|
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||||
|
|
||||||
|
<ui:composition template="/templates/template_page.xhtml">
|
||||||
|
<ui:param name="pageTitle" value="Index sidan"/>
|
||||||
|
|
||||||
|
<ui:define name="panel-main">
|
||||||
|
<section class = "bild">
|
||||||
|
<h:graphicImage library="skola" name="/images/testBild2.jpg"/>
|
||||||
|
</section>
|
||||||
|
</ui:define>
|
||||||
|
|
||||||
|
</ui:composition>
|
||||||
|
</html>
|
||||||
BIN
src/main/webapp/resources/skola/images/testBild2.jpg
Normal file
BIN
src/main/webapp/resources/skola/images/testBild2.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 91 KiB |
53
src/main/webapp/signIn.xhtml
Normal file
53
src/main/webapp/signIn.xhtml
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||||
|
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||||
|
|
||||||
|
<ui:composition template="/templates/template_page.xhtml">
|
||||||
|
<ui:param name="pageTitle" value="Sign In"/>
|
||||||
|
|
||||||
|
<ui:define name="panel-top">
|
||||||
|
<section>
|
||||||
|
<ui:fragment rendered="#{not userManager.signedIn}">
|
||||||
|
<h1>Logga in</h1>
|
||||||
|
<p>Skriv ditt användarnamn</p>
|
||||||
|
</ui:fragment>
|
||||||
|
|
||||||
|
<ui:fragment rendered="#{userManager.signedIn}">
|
||||||
|
<h:form>
|
||||||
|
<h1>Välkommen, #{userManager.currentUser.firstName}!</h1>
|
||||||
|
<p>Du är redan inloggad.
|
||||||
|
Vill du<h:commandLink action="#{userManager.signOut}">logga ut</h:commandLink>?</p>
|
||||||
|
</h:form>
|
||||||
|
</ui:fragment>
|
||||||
|
</section>
|
||||||
|
</ui:define>
|
||||||
|
|
||||||
|
|
||||||
|
<ui:define name="panel-main">
|
||||||
|
<ui:fragment rendered="#{not userManager.signedIn}">
|
||||||
|
<section>
|
||||||
|
<h:messages styleClass="validation-messages"/>
|
||||||
|
<h:form>
|
||||||
|
<h:panelGrid columns="2" styleClass="form-grid" columnClasses="form-column-label,form-column-input">
|
||||||
|
<h:outputLabel for="username">Användarnamn</h:outputLabel>
|
||||||
|
<h:inputText id="username" value="#{signIn.username}" size="20"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h:outputLabel for="password">Password</h:outputLabel>
|
||||||
|
<h:inputSecret id="password" value="#{signIn.password}" size="20"/>
|
||||||
|
|
||||||
|
<h:outputText value=""/>
|
||||||
|
<h:commandButton value="Submit" action="#{signIn.submit}"/> <!--anroppar usermanager-->
|
||||||
|
</h:panelGrid>
|
||||||
|
</h:form>
|
||||||
|
</section>
|
||||||
|
</ui:fragment>
|
||||||
|
</ui:define>
|
||||||
|
|
||||||
|
</ui:composition>
|
||||||
|
</html>
|
||||||
34
src/main/webapp/student.xhtml
Normal file
34
src/main/webapp/student.xhtml
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||||
|
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||||
|
|
||||||
|
<ui:composition template="templates/template_page.xhtml">
|
||||||
|
<ui:param name="pageTitle" value="Student sidan"/>
|
||||||
|
|
||||||
|
<ui:define name="panel-top">
|
||||||
|
<section>
|
||||||
|
<!-- <h:outputLink value="index.xhtml">Logga ut</h:outputLink> måste redict på rätt sätt-->
|
||||||
|
</section>
|
||||||
|
</ui:define>
|
||||||
|
|
||||||
|
<ui:define name="panel-main">
|
||||||
|
<section>
|
||||||
|
<h1>Mest lästa kurser</h1>
|
||||||
|
<h:form>
|
||||||
|
<ui:repeat value="#{mostStudiedCourses.courses}" var="course">
|
||||||
|
<ui:param name="course" value="#{course}"/>
|
||||||
|
<ui:define name="course-description">
|
||||||
|
|
||||||
|
</ui:define>
|
||||||
|
</ui:repeat>
|
||||||
|
</h:form>
|
||||||
|
</section>
|
||||||
|
</ui:define>
|
||||||
|
</ui:composition>
|
||||||
|
|
||||||
|
</html>
|
||||||
|
|
||||||
21
src/main/webapp/teacher.xhtml
Normal file
21
src/main/webapp/teacher.xhtml
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||||
|
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||||
|
|
||||||
|
<ui:composition template="templates/template_page.xhtml">
|
||||||
|
<ui:param name="pageTitle" value="Lärare sidan"/>
|
||||||
|
<ui:define name="panel-top">
|
||||||
|
<section>
|
||||||
|
|
||||||
|
|
||||||
|
</section>
|
||||||
|
</ui:define>
|
||||||
|
</ui:composition>
|
||||||
|
|
||||||
|
|
||||||
|
</html>
|
||||||
|
|
||||||
26
src/main/webapp/templates/panel_top.xhtml
Normal file
26
src/main/webapp/templates/panel_top.xhtml
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||||
|
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||||
|
|
||||||
|
|
||||||
|
<ui:composition>
|
||||||
|
<section>
|
||||||
|
<ui:fragment rendered="#{not userManager.signedIn}">
|
||||||
|
<p> <h:outputLink value="signIn.xhtml">Logga in</h:outputLink></p>
|
||||||
|
</ui:fragment>
|
||||||
|
|
||||||
|
<ui:fragment rendered="#{userManager.signedIn}">
|
||||||
|
<h:form>
|
||||||
|
<h1>Välkommen #{userManager.currentUser.firstName}!</h1>
|
||||||
|
|
||||||
|
<p> <h:commandLink action="#{userManager.signOut}">Logga ut</h:commandLink></p>
|
||||||
|
</h:form>
|
||||||
|
</ui:fragment>
|
||||||
|
</section>
|
||||||
|
</ui:composition>
|
||||||
|
|
||||||
|
</html>
|
||||||
19
src/main/webapp/templates/panel_top_admin.xhtml
Normal file
19
src/main/webapp/templates/panel_top_admin.xhtml
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||||
|
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||||
|
<ui:composition>
|
||||||
|
<section>
|
||||||
|
<ui:fragment rendered="#{userManager.signedIn}">
|
||||||
|
<h:form>
|
||||||
|
<h1>Välkommen #{userManager.currentUser.firstName}!</h1>
|
||||||
|
|
||||||
|
<p> <h:commandLink action="#{userManager.signOut}">Logga ut</h:commandLink></p>
|
||||||
|
</h:form>
|
||||||
|
</ui:fragment>
|
||||||
|
</section>
|
||||||
|
</ui:composition>
|
||||||
|
</html>
|
||||||
17
src/main/webapp/templates/template_footer.xhtml
Normal file
17
src/main/webapp/templates/template_footer.xhtml
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||||
|
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||||
|
|
||||||
|
<ui:composition>
|
||||||
|
<footer>
|
||||||
|
<h:form>
|
||||||
|
<h:outputText value="Skolan 2017"/>
|
||||||
|
</h:form>
|
||||||
|
</footer>
|
||||||
|
</ui:composition>
|
||||||
|
</html>
|
||||||
|
|
||||||
15
src/main/webapp/templates/template_header.xhtml
Normal file
15
src/main/webapp/templates/template_header.xhtml
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||||
|
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||||
|
<ui:composition>
|
||||||
|
<header>
|
||||||
|
<h:form>
|
||||||
|
<h:outputText value="Rotana Reg Skolan"/>
|
||||||
|
</h:form>
|
||||||
|
</header>
|
||||||
|
</ui:composition>
|
||||||
|
</html>
|
||||||
47
src/main/webapp/templates/template_page.xhtml
Normal file
47
src/main/webapp/templates/template_page.xhtml
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||||
|
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||||
|
|
||||||
|
<f:view contentType="text/html">
|
||||||
|
|
||||||
|
<h:head>
|
||||||
|
<meta charset="UTF-8"/>
|
||||||
|
<title>RotanaReg Skolan - #{pageTitle}</title>
|
||||||
|
<h:outputStylesheet name="blueheven.css"/>
|
||||||
|
<h:outputStylesheet name="style.css"/>
|
||||||
|
</h:head>
|
||||||
|
|
||||||
|
<h:body>
|
||||||
|
<ui:include src="/templates/template_header.xhtml"/>
|
||||||
|
|
||||||
|
<nav>
|
||||||
|
<h:link styleClass="menuItem" value="Home" outcome="index"/>
|
||||||
|
<span class="text_grey"> | </span>
|
||||||
|
<h:link styleClass="menuItem" value="Admin" outcome="admin"/>
|
||||||
|
<span class="text_grey"> | </span>
|
||||||
|
<h:link styleClass="menuItem" value="Student" outcome="student"/>
|
||||||
|
<span class="text_grey"> | </span>
|
||||||
|
<h:link styleClass="menuItem" value="Teacher" outcome="teacher"/>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<ui:insert name = "panel-top">
|
||||||
|
<section>
|
||||||
|
<ui:include src="panel_top.xhtml"/>
|
||||||
|
</section>
|
||||||
|
</ui:insert>
|
||||||
|
|
||||||
|
<ui:insert name="panel-main">
|
||||||
|
<section>
|
||||||
|
<h1>Main Panel</h1>
|
||||||
|
<p>Placeholder text.</p>
|
||||||
|
</section>
|
||||||
|
</ui:insert>
|
||||||
|
|
||||||
|
<ui:include src="/templates/template_footer.xhtml"/>
|
||||||
|
</h:body>
|
||||||
|
</f:view>
|
||||||
|
</html>
|
||||||
62
src/main/webapp/user_detail.xhtml
Normal file
62
src/main/webapp/user_detail.xhtml
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||||
|
xmlns:p="http://xmlns.jcp.org/jsf/passthrough"
|
||||||
|
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||||
|
<ui:composition template="templates/template_page.xhtml">
|
||||||
|
<f:metadata>
|
||||||
|
<f:viewAction action="#{userDetail.onload}"/>
|
||||||
|
</f:metadata>
|
||||||
|
<ui:param name="pageTitle" value="Användar detaljer"/>
|
||||||
|
|
||||||
|
<ui:define name="panel-top">
|
||||||
|
<section>
|
||||||
|
<h:outputLink value="admin.xhtml">Tillbaka</h:outputLink>
|
||||||
|
</section>
|
||||||
|
</ui:define>
|
||||||
|
<ui:define name="panel-main">
|
||||||
|
<section>
|
||||||
|
<h:form>
|
||||||
|
<h:panelGrid columns="2" styleClass="form-grid" columnClasses="form-column-label,form-column-input">
|
||||||
|
<h:outputLabel for="username">Användarnamn</h:outputLabel>
|
||||||
|
<h:inputText id="username" value="#{userDetail.user.username}" size="20"
|
||||||
|
readonly="#{userManager.signedIn}"/>
|
||||||
|
|
||||||
|
<h:outputLabel for="password">Password</h:outputLabel>
|
||||||
|
<h:inputSecret id="password" value="#{userDetail.user.password}" size="20"/>
|
||||||
|
|
||||||
|
<h:outputLabel for="firstName">Förnamn</h:outputLabel>
|
||||||
|
<h:inputText id="firstName" value="#{userDetail.user.firstName}" size="30"/>
|
||||||
|
|
||||||
|
<h:outputLabel for="lastName">Efternamn</h:outputLabel>
|
||||||
|
<h:inputText id="lastName" value="#{userDetail.user.lastName}" size="30"/>
|
||||||
|
|
||||||
|
<h:outputLabel for="emailAddress">E-mail address</h:outputLabel>
|
||||||
|
<h:inputText id="emailAddress" value="#{userDetail.user.emailAddress}" size="20"/>
|
||||||
|
|
||||||
|
<h:outputLabel for="phoneNumber">Telefon nummer</h:outputLabel>
|
||||||
|
<h:inputText id="phoneNumber" value="#{userDetail.user.phoneNumber}" size="20"/>
|
||||||
|
|
||||||
|
<h:outputLabel for="birthDate">Födelsedatum</h:outputLabel>
|
||||||
|
<h:inputText id="birthDate" p:type="date" value="#{userDetail.user.birthDate}">
|
||||||
|
<f:convertDateTime pattern="yyyy-MM-dd"/>
|
||||||
|
</h:inputText>
|
||||||
|
|
||||||
|
<h:outputLabel for="role" value="Roll:"/>
|
||||||
|
<h:selectOneRadio rendered="true" id="role" value="#{userDetail.user.role}" label="role"
|
||||||
|
filter="true" panelStyle="width:250px">
|
||||||
|
<f:selectItems value="#{userDetail.user.rolesList}"/>
|
||||||
|
</h:selectOneRadio>
|
||||||
|
|
||||||
|
<h:outputText value=""/>
|
||||||
|
<h:commandButton value="Submit" action="#{userDetail.submit}"/>
|
||||||
|
</h:panelGrid>
|
||||||
|
|
||||||
|
</h:form>
|
||||||
|
</section>
|
||||||
|
</ui:define>
|
||||||
|
</ui:composition>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Reference in a new issue