+ payment pages
+ selection pages
This commit is contained in:
parent
d205e62419
commit
f09762c100
@ -66,7 +66,11 @@ public class AddressDB {
|
||||
|
||||
try {
|
||||
ResultSet rs = entry.getKey();
|
||||
Address address = new Address(user, id, rs.getString("name"), rs.getString("street"), rs.getString("number"), rs.getInt("zipCode"), rs.getString("city"));
|
||||
rs.beforeFirst();
|
||||
Address address = null;
|
||||
while(rs.next()) {
|
||||
address = new Address(user, id, rs.getString("name"), rs.getString("street"), rs.getString("number"), rs.getInt("zipCode"), rs.getString("city"));
|
||||
}
|
||||
entry.getValue().close();
|
||||
|
||||
return address;
|
||||
|
@ -32,8 +32,8 @@ public class PaymentDB {
|
||||
|
||||
try {
|
||||
ResultSet rs = entry.getKey();
|
||||
rs.beforeFirst();
|
||||
PaymentType type = null;
|
||||
rs.beforeFirst();
|
||||
while(rs.next()) {
|
||||
type = new PaymentType(id, rs.getString("name"));
|
||||
}
|
||||
@ -92,8 +92,8 @@ public class PaymentDB {
|
||||
|
||||
try {
|
||||
ResultSet rs = entry.getKey();
|
||||
rs.beforeFirst();
|
||||
PayPalPayment payment = null;
|
||||
rs.beforeFirst();
|
||||
while(rs.next()) {
|
||||
payment = new PayPalPayment(id, user, rs.getString("mail"), rs.getString("auth"));
|
||||
}
|
||||
@ -114,8 +114,8 @@ public class PaymentDB {
|
||||
|
||||
try {
|
||||
ResultSet rs = entry.getKey();
|
||||
rs.beforeFirst();
|
||||
CreditCardPayment payment = null;
|
||||
rs.beforeFirst();
|
||||
while(rs.next()) {
|
||||
payment = new CreditCardPayment(id, user, rs.getInt("number"), rs.getString("owner"), rs.getDate("expiration"), rs.getInt("checksum"));
|
||||
}
|
||||
@ -137,8 +137,8 @@ public class PaymentDB {
|
||||
|
||||
try {
|
||||
ResultSet rs = entry.getKey();
|
||||
rs.beforeFirst();
|
||||
DebitCardPayment payment = null;
|
||||
rs.beforeFirst();
|
||||
while(rs.next()) {
|
||||
payment = new DebitCardPayment(id, user, rs.getString("iban"), rs.getString("bic"), rs.getString("owner"));
|
||||
}
|
||||
@ -266,6 +266,7 @@ public class PaymentDB {
|
||||
return insertCount;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private long insertType(@NotNull Payment payment) {
|
||||
Connection connection = database.getConnection();
|
||||
assert connection != null;
|
||||
@ -277,7 +278,12 @@ public class PaymentDB {
|
||||
|
||||
statement.executeUpdate();
|
||||
|
||||
long id = statement.getGeneratedKeys().getLong("id");
|
||||
ResultSet rs = statement.getGeneratedKeys();
|
||||
Long id = null;
|
||||
|
||||
while(rs.next()) {
|
||||
id = rs.getLong("id");
|
||||
}
|
||||
|
||||
connection.close();
|
||||
|
||||
|
@ -23,6 +23,14 @@ public class CreditCardPayment extends Payment{
|
||||
@NonNull private Date expiration;
|
||||
@NonNull private int checksum;
|
||||
|
||||
public CreditCardPayment(User user, int number, String owner, Date expiration, int checksum) {
|
||||
super(0, new PaymentType(1, "CreditCard"), user);
|
||||
this.number = number;
|
||||
this.owner = owner;
|
||||
this.expiration = expiration;
|
||||
this.checksum = checksum;
|
||||
}
|
||||
|
||||
public CreditCardPayment(long id, User user, int number, String owner, Date expiration, int checksum) {
|
||||
super(id, new PaymentType(1, "CreditCard"), user);
|
||||
this.number = number;
|
||||
|
@ -19,6 +19,12 @@ public class PayPalPayment extends Payment{
|
||||
@NonNull private String email;
|
||||
@NonNull private String authCode;
|
||||
|
||||
public PayPalPayment(User user, String email, String authCode) {
|
||||
super(0, new PaymentType(4, "PayPal"), user);
|
||||
this.email = email;
|
||||
this.authCode = authCode;
|
||||
}
|
||||
|
||||
public PayPalPayment(long id, User user, String email, String authCode) {
|
||||
super(id, new PaymentType(4, "PayPal"), user);
|
||||
this.email = email;
|
||||
|
@ -41,7 +41,7 @@ public class AddressBean implements Serializable {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private int zipCode = -1;
|
||||
private Integer zipCode;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ -50,6 +50,14 @@ public class AddressBean implements Serializable {
|
||||
@Getter
|
||||
private boolean valid = true;
|
||||
|
||||
@Getter
|
||||
private Address selected;
|
||||
|
||||
public String select(Address address) {
|
||||
selected = address;
|
||||
return "paymentSelection.jsf";
|
||||
}
|
||||
|
||||
|
||||
public List<Address> getAddressList() {
|
||||
List<Address> list = Database.getInstance().address().getAll(getUser());
|
||||
@ -58,11 +66,11 @@ public class AddressBean implements Serializable {
|
||||
}
|
||||
|
||||
public String add() {
|
||||
if(getUser() != null && name != null && street != null && number != null && zipCode != -1 && city != null) {
|
||||
if(getUser() != null && name != null && street != null && number != null && zipCode != null && city != null) {
|
||||
Database.getInstance().address().insert(new Address(getUser(), name, street, number, zipCode, city));
|
||||
name = null;
|
||||
number = null;
|
||||
zipCode = -1;
|
||||
zipCode = null;
|
||||
city = null;
|
||||
valid = true;
|
||||
return "address.xhtml";
|
||||
|
55
src/main/java/de/hsel/itech/jsf/CreditCardBean.java
Normal file
55
src/main/java/de/hsel/itech/jsf/CreditCardBean.java
Normal file
@ -0,0 +1,55 @@
|
||||
package de.hsel.itech.jsf;
|
||||
|
||||
|
||||
import de.hsel.itech.db.Database;
|
||||
import de.hsel.itech.db.pojo.CreditCardPayment;
|
||||
import de.hsel.itech.db.pojo.User;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.RequestScoped;
|
||||
import javax.faces.context.FacesContext;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Johannes Theiner
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
@ManagedBean
|
||||
@RequestScoped
|
||||
public class CreditCardBean implements Serializable {
|
||||
|
||||
public User getUser() {
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
return (User) context.getApplication().evaluateExpressionGet(context,"#{userBean.user}", User.class);
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String owner;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private int number;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private Date expiration;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private int checksum;
|
||||
|
||||
public String add() {
|
||||
java.sql.Date date = new java.sql.Date(expiration.getTime());
|
||||
CreditCardPayment payment = new CreditCardPayment(getUser(), number, owner, date, checksum);
|
||||
|
||||
Database.getInstance().payment().insert(payment);
|
||||
|
||||
return "payments.jsf";
|
||||
}
|
||||
}
|
43
src/main/java/de/hsel/itech/jsf/PayPalBean.java
Normal file
43
src/main/java/de/hsel/itech/jsf/PayPalBean.java
Normal file
@ -0,0 +1,43 @@
|
||||
package de.hsel.itech.jsf;
|
||||
|
||||
import de.hsel.itech.db.Database;
|
||||
import de.hsel.itech.db.pojo.PayPalPayment;
|
||||
import de.hsel.itech.db.pojo.User;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.RequestScoped;
|
||||
import javax.faces.context.FacesContext;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Johannes Theiner
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
@ManagedBean
|
||||
@RequestScoped
|
||||
public class PayPalBean implements Serializable {
|
||||
|
||||
public User getUser() {
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
return (User) context.getApplication().evaluateExpressionGet(context,"#{userBean.user}", User.class);
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String mail;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String auth;
|
||||
|
||||
|
||||
public String add() {
|
||||
PayPalPayment payment = new PayPalPayment(getUser(), mail, auth);
|
||||
Database.getInstance().payment().insert(payment);
|
||||
|
||||
return "payments.jsf";
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package de.hsel.itech.jsf;
|
||||
|
||||
import de.hsel.itech.db.Database;
|
||||
import de.hsel.itech.db.pojo.*;
|
||||
import lombok.Getter;
|
||||
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
@ -18,6 +19,15 @@ public class PaymentBean {
|
||||
return (User) context.getApplication().evaluateExpressionGet(context,"#{userBean.user}", User.class);
|
||||
}
|
||||
|
||||
@Getter
|
||||
private Payment selected;
|
||||
|
||||
public String select(Payment payment) {
|
||||
selected = payment;
|
||||
|
||||
return "confirmation.jsf";
|
||||
}
|
||||
|
||||
public List<CreditCardPayment> getCreditCard() {
|
||||
List<CreditCardPayment> list = new ArrayList<>();
|
||||
for(Payment payment : Database.getInstance().payment().get(getUser())) {
|
||||
|
@ -12,15 +12,20 @@
|
||||
<div class="m-row">
|
||||
<div class="m-col-s-4 m-push-s-4">
|
||||
<h:form>
|
||||
<h:inputText id="name" value="#{addressBean.name}">Name</h:inputText>
|
||||
<h:inputText id="name" value="#{addressBean.name}" required="true">Name</h:inputText>
|
||||
<h:message for="name"/>
|
||||
<br/>
|
||||
<h:inputText id="street" value="#{addressBean.street}">Straße</h:inputText>
|
||||
<h:inputText id="street" value="#{addressBean.street}" required="true">Straße</h:inputText>
|
||||
<h:message for="street"/>
|
||||
<br/>
|
||||
<h:inputText id="number" value="#{addressBean.number}">Hausnummer</h:inputText>
|
||||
<h:inputText id="number" value="#{addressBean.number}" required="true">Hausnummer</h:inputText>
|
||||
<h:message for="number"/>
|
||||
<br/>
|
||||
<h:inputText id="zipCode" value="#{addressBean.zipCode}">Postleitzahl</h:inputText>
|
||||
<h:inputText id="zipCode" value="#{addressBean.zipCode}" required="true">Postleitzahl</h:inputText>
|
||||
<h:message for="zipCode"/>
|
||||
<br/>
|
||||
<h:inputText id="city" value="#{addressBean.city}">Ort</h:inputText>
|
||||
<h:inputText id="city" value="#{addressBean.city}" required="true">Ort</h:inputText>
|
||||
<h:message for="city"/>
|
||||
<br/>
|
||||
<h:commandButton action="#{addressBean.add}" value="hinzufügen"/>
|
||||
</h:form>
|
||||
|
34
src/main/webapp/addressSelection.xhtml
Normal file
34
src/main/webapp/addressSelection.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">
|
||||
<f:view>
|
||||
<ui:composition template="template.xhtml">
|
||||
|
||||
<ui:define name="content">
|
||||
|
||||
<h1 class="m-text-center">Adresse auswählen</h1>
|
||||
|
||||
<h:panelGroup layout="block" styleClass="m-row" rendered="#{userBean.loggedIn}">
|
||||
<ui:repeat value="#{addressBean.addressList}" var="address">
|
||||
|
||||
<h:panelGroup layout="block" styleClass="m-col-t-3">
|
||||
<h:commandLink action="#{addressBean.select(address)}">
|
||||
<div class="m-block m-primary">
|
||||
#{address.name}<br/>
|
||||
#{address.street} #{address.number}<br/>
|
||||
#{address.zipCode} #{address.city}
|
||||
</div>
|
||||
</h:commandLink>
|
||||
</h:panelGroup>
|
||||
</ui:repeat>
|
||||
</h:panelGroup>
|
||||
|
||||
</ui:define>
|
||||
|
||||
</ui:composition>
|
||||
</f:view>
|
||||
</html>
|
42
src/main/webapp/payment-add-credit.xhtml
Normal file
42
src/main/webapp/payment-add-credit.xhtml
Normal file
@ -0,0 +1,42 @@
|
||||
<?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>
|
||||
<ui:composition template="template.xhtml">
|
||||
|
||||
<ui:define name="content">
|
||||
|
||||
<div class="m-row">
|
||||
<div class="m-col-s-4 m-push-s-4">
|
||||
<h:form>
|
||||
<h:inputText id="owner" value="#{creditCardBean.owner}">Besitzer</h:inputText>
|
||||
<h:message for="owner"/>
|
||||
<br/>
|
||||
<h:inputText id="number" value="#{creditCardBean.number}">Kartennummer</h:inputText>
|
||||
<h:message for="number"/>
|
||||
<br/>
|
||||
<h:inputText id="expiration" value="#{creditCardBean.expiration}">Ablaufdaten
|
||||
<f:convertDateTime pattern="dd.MM.yyyy"/>
|
||||
</h:inputText>
|
||||
<h:message for="expiration"/>
|
||||
<br/>
|
||||
<h:inputText id="checksum" value="#{creditCardBean.checksum}">Prüfsumme</h:inputText>
|
||||
<h:message for="checksum"/>
|
||||
|
||||
|
||||
<br/>
|
||||
<h:commandButton action="#{creditCardBean.add}" value="hinzufügen"/>
|
||||
</h:form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</ui:define>
|
||||
|
||||
</ui:composition>
|
||||
</f:view>
|
||||
</html>
|
34
src/main/webapp/payment-add-paypal.xhtml
Normal file
34
src/main/webapp/payment-add-paypal.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">
|
||||
<f:view>
|
||||
|
||||
<ui:composition template="template.xhtml">
|
||||
|
||||
<ui:define name="content">
|
||||
|
||||
<div class="m-row">
|
||||
<div class="m-col-s-4 m-push-s-4">
|
||||
<h:form>
|
||||
<h:inputText id="mail" value="#{payPalBean.mail}">Mail</h:inputText>
|
||||
<h:message for="mail"/>
|
||||
<br/>
|
||||
<h:inputText id="number" value="#{creditCardBean.number}">Kartennummer</h:inputText>
|
||||
<h:message for="number"/>
|
||||
<br/>
|
||||
<h:commandButton action="#{payPalBean.add}" value="hinzufügen"/>
|
||||
</h:form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</ui:define>
|
||||
|
||||
</ui:composition>
|
||||
|
||||
</f:view>
|
||||
</html>
|
57
src/main/webapp/paymentSelection.xhtml
Normal file
57
src/main/webapp/paymentSelection.xhtml
Normal file
@ -0,0 +1,57 @@
|
||||
<?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>
|
||||
<ui:composition template="template.xhtml">
|
||||
<ui:define name="content">
|
||||
|
||||
<h1 class="m-text-center">Zahlungsmöglichkeit auswählen</h1>
|
||||
|
||||
<h:panelGroup layout="block" rendered="#{userBean.loggedIn}">
|
||||
|
||||
|
||||
<h3 class="m-text-center m-text m-small">Kreditkarte</h3>
|
||||
<h:panelGroup layout="block" styleClass="m-row">
|
||||
<ui:repeat value="#{paymentBean.creditCard}" var="payment">
|
||||
<h:commandLink action="#{paymentBean.select(payment)}">
|
||||
<div class="m-col-t-3">
|
||||
<div class="m-block m-primary">
|
||||
#{payment.owner}<br/>
|
||||
#{payment.number} /
|
||||
#{payment.checksum}<br/>
|
||||
Ablaufdatum:<h:outputText value="#{payment.expiration}">
|
||||
<f:convertDateTime pattern="dd.MM.yyyy"/>
|
||||
</h:outputText>
|
||||
</div>
|
||||
</div>
|
||||
</h:commandLink>
|
||||
</ui:repeat>
|
||||
|
||||
</h:panelGroup>
|
||||
|
||||
|
||||
<h3 class="m-text-center m-text m-small">PayPal</h3>
|
||||
<h:panelGroup layout="block" styleClass="m-row">
|
||||
<ui:repeat value="#{paymentBean.payPal}" var="payment">
|
||||
<h:commandLink action="#{paymentBean.select(payment)}">
|
||||
<div class="m-col-t-3">
|
||||
<div class="m-block m-primary">
|
||||
#{payment.email}
|
||||
</div>
|
||||
</div>
|
||||
</h:commandLink>
|
||||
</ui:repeat>
|
||||
|
||||
</h:panelGroup>
|
||||
|
||||
|
||||
</h:panelGroup>
|
||||
|
||||
</ui:define>
|
||||
</ui:composition>
|
||||
</f:view>
|
||||
</html>
|
@ -14,20 +14,23 @@
|
||||
<h:panelGroup layout="block" rendered="#{userBean.loggedIn}">
|
||||
|
||||
|
||||
<h3 class="m-text-center">Kreditkarte</h3>
|
||||
<h3 class="m-text-center m-text m-small">Kreditkarte</h3>
|
||||
<h:panelGroup layout="block" styleClass="m-row">
|
||||
<ui:repeat value="#{paymentBean.creditCard}" var="payment">
|
||||
<div class="m-col-t-3">
|
||||
<div class="m-block m-primary">
|
||||
#{payment.owner}<br/>
|
||||
#{payment.number}<br/>
|
||||
#{payment.number} /
|
||||
#{payment.checksum}<br/>
|
||||
#{payment.expiration}
|
||||
Ablaufdatum:
|
||||
<h:outputText value="#{payment.expiration}" >
|
||||
<f:convertDateTime pattern="dd.MM.yyyy" />
|
||||
</h:outputText>
|
||||
</div>
|
||||
</div>
|
||||
</ui:repeat>
|
||||
<div class="m-col-t-3">
|
||||
<h:outputLink value="payment-add.jsf">
|
||||
<h:outputLink value="payment-add-credit.jsf">
|
||||
<div class="m-block m-text-center">
|
||||
<i class="fas fa-plus fa-4x"/>
|
||||
</div>
|
||||
@ -36,7 +39,9 @@
|
||||
</h:panelGroup>
|
||||
|
||||
|
||||
<h3 class="m-text-center">PayPal</h3>
|
||||
|
||||
|
||||
<h3 class="m-text-center m-text m-small">PayPal</h3>
|
||||
<h:panelGroup layout="block" styleClass="m-row">
|
||||
<ui:repeat value="#{paymentBean.payPal}" var="payment">
|
||||
<div class="m-col-t-3">
|
||||
@ -46,7 +51,7 @@
|
||||
</div>
|
||||
</ui:repeat>
|
||||
<div class="m-col-t-3">
|
||||
<h:outputLink value="payment-add.jsf">
|
||||
<h:outputLink value="payment-add-paypal.jsf">
|
||||
<div class="m-block m-text-center">
|
||||
<i class="fas fa-plus fa-4x"/>
|
||||
</div>
|
||||
|
@ -2,5 +2,5 @@
|
||||
Server info: <%= application.getServerInfo() %><br>
|
||||
Servlet version: <%= application.getMajorVersion() %>.<%= application.getMinorVersion() %><br>
|
||||
JSP version: <%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion() %><br>
|
||||
JSF version: <%= FacesContext.class.getPackage().getImplementationVersion()%>
|
||||
JSF version: <%= FacesContext.class.getPackage().getImplementationVersion()%><br>
|
||||
Java version: <%= System.getProperty("java.version") %><br>
|
||||
|
Loading…
Reference in New Issue
Block a user