switching to cdi completely
This commit is contained in:
10
build.gradle
10
build.gradle
@ -22,7 +22,7 @@ apply plugin: 'eclipse'
|
||||
apply plugin: 'nu.studer.jooq'
|
||||
|
||||
group = 'jottyfan'
|
||||
version = '1.0.1'
|
||||
version = '1.0.2'
|
||||
|
||||
description = """timetrack"""
|
||||
|
||||
@ -41,8 +41,10 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'org.apache.myfaces.core:myfaces-api:2.2.12'
|
||||
compile 'org.apache.myfaces.core:myfaces-impl:2.2.12'
|
||||
compile 'org.jboss.weld.servlet:weld-servlet:2.4.8.Final'
|
||||
|
||||
compile 'org.apache.myfaces.core:myfaces-api:2.3.3'
|
||||
compile 'org.apache.myfaces.core:myfaces-impl:2.3.3'
|
||||
compile 'net.bootsfaces:bootsfaces:1.4.1'
|
||||
compile 'de.jooqFaces:jooqFaces:0.1.3-SNAPSHOT'
|
||||
compile 'org.postgresql:postgresql:42.2.5'
|
||||
@ -50,7 +52,7 @@ dependencies {
|
||||
compile 'org.jooq:jooq-codegen:3.11.9'
|
||||
compile 'com.google.code.gson:gson:2.8.5'
|
||||
compile 'org.jasypt:jasypt:1.9.2'
|
||||
compile 'javax.servlet:javax.servlet-api:3.1.0'
|
||||
compile 'javax.servlet:javax.servlet-api:4.0.1'
|
||||
compile 'org.apache.logging.log4j:log4j-core:2.11.1'
|
||||
compile 'org.apache.logging.log4j:log4j-api:2.11.1'
|
||||
|
||||
|
@ -1,18 +1,23 @@
|
||||
package de.jottyfan.timetrack.help;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.bean.*;
|
||||
import javax.enterprise.context.SessionScoped;
|
||||
import javax.inject.Named;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author henkej
|
||||
*
|
||||
*/
|
||||
@ManagedBean
|
||||
@Named
|
||||
@SessionScoped
|
||||
public class ThemeBean
|
||||
public class ThemeBean implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String currentTheme;
|
||||
|
||||
public List<String> getValidThemes(){
|
||||
|
@ -14,11 +14,4 @@ public interface ControlInterface
|
||||
* @throws DBException
|
||||
*/
|
||||
public String toList();
|
||||
|
||||
/**
|
||||
* return model of bean container
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Model getModel();
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ package de.jottyfan.timetrack.modules;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.enterprise.context.SessionScoped;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jasypt.util.password.StrongPasswordEncryptor;
|
||||
|
||||
@ -12,7 +12,7 @@ import org.jasypt.util.password.StrongPasswordEncryptor;
|
||||
* @author henkej
|
||||
*
|
||||
*/
|
||||
@ManagedBean
|
||||
@Named
|
||||
@SessionScoped
|
||||
public class SessionBean implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -1,56 +1,36 @@
|
||||
package de.jottyfan.timetrack.modules;
|
||||
|
||||
import javax.faces.bean.RequestScoped;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import de.jottyfan.timetrack.help.Pages;
|
||||
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.ManagedProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author henkej
|
||||
*
|
||||
*/
|
||||
@ManagedBean
|
||||
@Named
|
||||
@RequestScoped
|
||||
public class SessionControl {
|
||||
|
||||
@ManagedProperty(value = "#{facesContext}")
|
||||
private FacesContext facesContext;
|
||||
|
||||
@ManagedProperty(value = "#{sessionBean}")
|
||||
private SessionBean bean;
|
||||
@Inject
|
||||
private SessionBean sessionBean;
|
||||
|
||||
public String doLogin() {
|
||||
SessionModel model = new SessionModel();
|
||||
model.doLogin(facesContext, bean);
|
||||
model.doLogin(FacesContext.getCurrentInstance(), sessionBean);
|
||||
return Pages.START.get();
|
||||
}
|
||||
|
||||
public String doLogout() {
|
||||
bean.setLogin(null);
|
||||
bean.setSecret(null);
|
||||
bean.setForename(null);
|
||||
bean.setSurname(null);
|
||||
bean.setUsername(null);
|
||||
sessionBean.setLogin(null);
|
||||
sessionBean.setSecret(null);
|
||||
sessionBean.setForename(null);
|
||||
sessionBean.setSurname(null);
|
||||
sessionBean.setUsername(null);
|
||||
return Pages.START.get();
|
||||
}
|
||||
|
||||
public FacesContext getFacesContext() {
|
||||
return facesContext;
|
||||
}
|
||||
|
||||
public void setFacesContext(FacesContext facesContext) {
|
||||
this.facesContext = facesContext;
|
||||
}
|
||||
|
||||
public SessionBean getBean() {
|
||||
return bean;
|
||||
}
|
||||
|
||||
public void setBean(SessionBean bean) {
|
||||
this.bean = bean;
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,11 @@ package de.jottyfan.timetrack.modules.contact;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.ManagedProperty;
|
||||
import javax.faces.bean.RequestScoped;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import de.jooqFaces.JooqFacesContext;
|
||||
import de.jottyfan.timetrack.help.Navigation;
|
||||
import de.jottyfan.timetrack.help.Pages;
|
||||
import de.jottyfan.timetrack.modules.ControlInterface;
|
||||
@ -16,23 +16,21 @@ import de.jottyfan.timetrack.modules.ControlInterface;
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
@ManagedBean
|
||||
@Named
|
||||
@RequestScoped
|
||||
public class ContactControl extends Navigation implements ControlInterface, Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ManagedProperty(value = "#{contactModel}")
|
||||
@Inject
|
||||
@Named("contactModel")
|
||||
private ContactModel model;
|
||||
|
||||
@ManagedProperty(value = "#{facesContext}")
|
||||
private JooqFacesContext facesContext;
|
||||
|
||||
public String toStart() {
|
||||
return navigateTo(Pages.START);
|
||||
}
|
||||
|
||||
public String toList() {
|
||||
boolean ready = model.init(facesContext);
|
||||
boolean ready = model.init(FacesContext.getCurrentInstance());
|
||||
return ready ? navigateTo(Pages.CONTACT_LIST) : toStart();
|
||||
}
|
||||
|
||||
@ -47,33 +45,21 @@ public class ContactControl extends Navigation implements ControlInterface, Seri
|
||||
}
|
||||
|
||||
public String doAdd() {
|
||||
boolean ready = model.add(facesContext);
|
||||
boolean ready = model.add(FacesContext.getCurrentInstance());
|
||||
return ready ? toList() : navigateTo(Pages.CONTACT_ITEM);
|
||||
}
|
||||
|
||||
public String doUpdate() {
|
||||
boolean ready = model.update(facesContext);
|
||||
boolean ready = model.update(FacesContext.getCurrentInstance());
|
||||
return ready ? toList() : navigateTo(Pages.CONTACT_ITEM);
|
||||
}
|
||||
|
||||
public String doDelete() {
|
||||
boolean ready = model.delete(facesContext);
|
||||
boolean ready = model.delete(FacesContext.getCurrentInstance());
|
||||
return ready ? toList() : navigateTo(Pages.CONTACT_ITEM);
|
||||
}
|
||||
|
||||
public Integer getAmount() {
|
||||
return model.getAmount(facesContext);
|
||||
}
|
||||
|
||||
public ContactModel getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(ContactModel model) {
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public void setFacesContext(JooqFacesContext facesContext) {
|
||||
this.facesContext = facesContext;
|
||||
return model.getAmount(FacesContext.getCurrentInstance());
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,13 @@ import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.enterprise.context.SessionScoped;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jooq.exception.DataAccessException;
|
||||
|
||||
import de.jooqFaces.JooqFacesContext;
|
||||
import de.jottyfan.timetrack.db.contact.enums.EnumContacttype;
|
||||
import de.jottyfan.timetrack.modules.Model;
|
||||
|
||||
@ -19,7 +19,7 @@ import de.jottyfan.timetrack.modules.Model;
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
@ManagedBean
|
||||
@Named
|
||||
@SessionScoped
|
||||
public class ContactModel implements Model, Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -28,7 +28,7 @@ public class ContactModel implements Model, Serializable {
|
||||
private List<ContactBean> list;
|
||||
private List<EnumContacttype> types;
|
||||
|
||||
public boolean init(JooqFacesContext facesContext) {
|
||||
public boolean init(FacesContext facesContext) {
|
||||
bean = new ContactBean(null);
|
||||
try {
|
||||
ContactGateway gw = new ContactGateway(facesContext);
|
||||
@ -44,7 +44,7 @@ public class ContactModel implements Model, Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean delete(JooqFacesContext facesContext) {
|
||||
public boolean delete(FacesContext facesContext) {
|
||||
try {
|
||||
Integer affected = new ContactGateway(facesContext).delete(bean.getPk());
|
||||
return affected.equals(1);
|
||||
@ -55,7 +55,7 @@ public class ContactModel implements Model, Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean add(JooqFacesContext facesContext) {
|
||||
public boolean add(FacesContext facesContext) {
|
||||
try {
|
||||
Integer affected = new ContactGateway(facesContext).add(bean);
|
||||
return affected.equals(1);
|
||||
@ -66,7 +66,7 @@ public class ContactModel implements Model, Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean update(JooqFacesContext facesContext) {
|
||||
public boolean update(FacesContext facesContext) {
|
||||
try {
|
||||
Integer affected = new ContactGateway(facesContext).update(bean);
|
||||
return affected.equals(1);
|
||||
@ -77,7 +77,7 @@ public class ContactModel implements Model, Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getAmount(JooqFacesContext facesContext) {
|
||||
public Integer getAmount(FacesContext facesContext) {
|
||||
try {
|
||||
return new ContactGateway(facesContext).getAmount();
|
||||
} catch (DataAccessException e) {
|
||||
|
@ -5,10 +5,10 @@ import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.ManagedProperty;
|
||||
import javax.faces.bean.RequestScoped;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import de.jottyfan.timetrack.help.Navigation;
|
||||
import de.jottyfan.timetrack.help.Pages;
|
||||
@ -19,23 +19,21 @@ import de.jottyfan.timetrack.modules.ControlInterface;
|
||||
* @author henkej
|
||||
*
|
||||
*/
|
||||
@ManagedBean
|
||||
@Named
|
||||
@RequestScoped
|
||||
public class DoneControl extends Navigation implements ControlInterface, Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ManagedProperty(value = "#{doneModel}")
|
||||
@Inject
|
||||
@Named("doneModel")
|
||||
private DoneModel model;
|
||||
|
||||
@ManagedProperty(value = "#{facesContext}")
|
||||
private FacesContext facesContext;
|
||||
|
||||
public String toStart() {
|
||||
return navigateTo(Pages.START);
|
||||
}
|
||||
|
||||
public String toList() {
|
||||
boolean ready = model.init(facesContext);
|
||||
boolean ready = model.init(FacesContext.getCurrentInstance());
|
||||
return ready ? navigateTo(Pages.DONE_INIT) : toStart();
|
||||
}
|
||||
|
||||
@ -43,13 +41,13 @@ public class DoneControl extends Navigation implements ControlInterface, Seriali
|
||||
DoneBean bean = new DoneBean();
|
||||
bean.setTimeFrom(getCurrentDate());
|
||||
model.setBean(bean);
|
||||
boolean ready = model.loadDefaults(facesContext);
|
||||
boolean ready = model.loadDefaults(FacesContext.getCurrentInstance());
|
||||
return ready ? navigateTo(Pages.DONE_ADD) : toList();
|
||||
}
|
||||
|
||||
public String toEdit(DoneBean bean) {
|
||||
model.setBean(bean);
|
||||
boolean ready = model.loadDefaults(facesContext);
|
||||
boolean ready = model.loadDefaults(FacesContext.getCurrentInstance());
|
||||
return ready ? navigateTo(Pages.DONE_EDIT) : toList();
|
||||
}
|
||||
|
||||
@ -59,17 +57,17 @@ public class DoneControl extends Navigation implements ControlInterface, Seriali
|
||||
}
|
||||
|
||||
public String doUpdate() {
|
||||
boolean ready = model.update(facesContext);
|
||||
boolean ready = model.update(FacesContext.getCurrentInstance());
|
||||
return ready ? toList() : toEdit(model.getBean());
|
||||
}
|
||||
|
||||
public String doDelete() {
|
||||
boolean ready = model.delete(facesContext);
|
||||
boolean ready = model.delete(FacesContext.getCurrentInstance());
|
||||
return ready ? toList() : toDelete(model.getBean());
|
||||
}
|
||||
|
||||
public String doAdd() {
|
||||
boolean ready = model.insert(facesContext);
|
||||
boolean ready = model.insert(FacesContext.getCurrentInstance());
|
||||
return ready ? toList() : toAdd();
|
||||
}
|
||||
|
||||
@ -80,16 +78,4 @@ public class DoneControl extends Navigation implements ControlInterface, Seriali
|
||||
public Timestamp getCurrentDate() {
|
||||
return Timestamp.valueOf(LocalDateTime.now());
|
||||
}
|
||||
|
||||
public DoneModel getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(DoneModel model) {
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public void setFacesContext(FacesContext facesContext) {
|
||||
this.facesContext = facesContext;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import static de.jottyfan.timetrack.db.done.Tables.V_TOTALOFDAY;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@ -252,15 +251,6 @@ public class DoneGateway extends JooqGateway {
|
||||
return new WholeDaySummaryBean("", "", "", "");
|
||||
}
|
||||
|
||||
private String toStringFromDuration(Duration i) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
if (i != null) {
|
||||
buf.append(i.toHours()).append(":");
|
||||
buf.append(i.toMinutes() % 60);
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* get all jobs of day
|
||||
*
|
||||
|
@ -11,10 +11,10 @@ import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import javax.enterprise.context.SessionScoped;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jooq.exception.DataAccessException;
|
||||
|
||||
@ -28,7 +28,7 @@ import de.jottyfan.timetrack.modules.Model;
|
||||
* @author henkej
|
||||
*
|
||||
*/
|
||||
@ManagedBean
|
||||
@Named
|
||||
@SessionScoped
|
||||
public class DoneModel implements Model, Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -2,33 +2,30 @@ package de.jottyfan.timetrack.modules.note;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.ManagedProperty;
|
||||
import javax.faces.bean.RequestScoped;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import de.jottyfan.timetrack.help.Navigation;
|
||||
import de.jottyfan.timetrack.help.Pages;
|
||||
import de.jottyfan.timetrack.modules.ControlInterface;
|
||||
import de.jottyfan.timetrack.modules.Model;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author henkej
|
||||
*
|
||||
*/
|
||||
@ManagedBean
|
||||
@Named
|
||||
@RequestScoped
|
||||
public class NoteControl extends Navigation implements ControlInterface, Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ManagedProperty(value = "#{noteModel}")
|
||||
@Inject
|
||||
@Named("noteModel")
|
||||
private NoteModel model;
|
||||
|
||||
@ManagedProperty(value = "#{facesContext}")
|
||||
private FacesContext facesContext;
|
||||
|
||||
public String toStart()
|
||||
{
|
||||
return navigateTo(Pages.START);
|
||||
@ -36,7 +33,7 @@ public class NoteControl extends Navigation implements ControlInterface, Seriali
|
||||
|
||||
public String toList()
|
||||
{
|
||||
boolean ready = model.init(facesContext);
|
||||
boolean ready = model.init(FacesContext.getCurrentInstance());
|
||||
return ready ? navigateTo(Pages.NOTE_LIST) : "";
|
||||
}
|
||||
|
||||
@ -53,19 +50,19 @@ public class NoteControl extends Navigation implements ControlInterface, Seriali
|
||||
|
||||
public String doAdd()
|
||||
{
|
||||
boolean ready = model.add(facesContext);
|
||||
boolean ready = model.add(FacesContext.getCurrentInstance());
|
||||
return ready ? toList() : toItem(model.getBean());
|
||||
}
|
||||
|
||||
public String doUpdate()
|
||||
{
|
||||
boolean ready = model.update(facesContext);
|
||||
boolean ready = model.update(FacesContext.getCurrentInstance());
|
||||
return ready ? toList() : toItem(model.getBean());
|
||||
}
|
||||
|
||||
public String doDelete()
|
||||
{
|
||||
boolean ready = model.delete(facesContext);
|
||||
boolean ready = model.delete(FacesContext.getCurrentInstance());
|
||||
return ready ? toList() : toItem(model.getBean());
|
||||
}
|
||||
|
||||
@ -101,22 +98,6 @@ public class NoteControl extends Navigation implements ControlInterface, Seriali
|
||||
}
|
||||
|
||||
public Long getAmount() {
|
||||
return model.getAmount(facesContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Model getModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(NoteModel model)
|
||||
{
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public void setFacesContext(FacesContext facesContext)
|
||||
{
|
||||
this.facesContext = facesContext;
|
||||
return model.getAmount(FacesContext.getCurrentInstance());
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,10 @@ package de.jottyfan.timetrack.modules.note;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import javax.enterprise.context.SessionScoped;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jooq.exception.DataAccessException;
|
||||
|
||||
@ -18,7 +18,7 @@ import de.jottyfan.timetrack.modules.Model;
|
||||
* @author henkej
|
||||
*
|
||||
*/
|
||||
@ManagedBean
|
||||
@Named
|
||||
@SessionScoped
|
||||
public class NoteModel implements Model, Serializable
|
||||
{
|
||||
|
6
src/main/webapp/META-INF/context.xml
Normal file
6
src/main/webapp/META-INF/context.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<Context>
|
||||
<Resource name="BeanManager" auth="Container"
|
||||
type="javax.enterprise.inject.api.BeanManager"
|
||||
factory="org.jboss.weld.resources.ManagerObjectFactory" />
|
||||
</Context>
|
0
src/main/webapp/WEB-INF/beans.xml
Normal file
0
src/main/webapp/WEB-INF/beans.xml
Normal file
Reference in New Issue
Block a user