]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 7 Jun 2017 20:47:46 +0000 (22:47 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 7 Jun 2017 20:49:32 +0000 (22:49 +0200)
- moved generic methods to BaseBean
- added new controller for receipts
- renamed income controller as it is not for administrative purposes
- continued with receipt form, used PrimeFaces tags for calendar

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jfinancials/beans/BaseFinancialsController.java
src/java/org/mxchange/jfinancials/beans/financial/income/FinancialsAdminFinancialIncomeWebRequestBean.java [deleted file]
src/java/org/mxchange/jfinancials/beans/financial/income/FinancialsAdminFinancialIncomeWebRequestController.java [deleted file]
src/java/org/mxchange/jfinancials/beans/financial/income/FinancialsIncomeWebRequestBean.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/financial/income/FinancialsIncomeWebRequestController.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/financial/receipt/FinancialsReceiptWebRequestBean.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/financial/receipt/FinancialsReceiptWebRequestController.java [new file with mode: 0644]
web/WEB-INF/templates/contact/form_contact_data.tpl
web/user/financials/login_financials_add_income.xhtml
web/user/financials/login_financials_add_receipt.xhtml

index c18c2ee878f733f2a1a75695e6c4227293779e5a..6ecb7e3ee65d4723723015f08d495e141e60475b 100644 (file)
 package org.mxchange.jfinancials.beans;
 
 import java.io.Serializable;
-import java.security.Principal;
-import java.text.MessageFormat;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import javax.faces.application.FacesMessage;
-import javax.faces.context.FacesContext;
+import org.mxchange.jcoreee.bean.BaseBean;
 import org.mxchange.jusercore.model.user.UserUtils;
 
 /**
@@ -31,7 +25,7 @@ import org.mxchange.jusercore.model.user.UserUtils;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-public abstract class BaseFinancialsController implements Serializable {
+public abstract class BaseFinancialsController extends BaseBean implements Serializable {
 
        /**
         * Serial number
@@ -44,97 +38,6 @@ public abstract class BaseFinancialsController implements Serializable {
        protected BaseFinancialsController () {
        }
 
-       /**
-        * Determines principal's name or returns null if no principal (security) is
-        * set.
-        * <p>
-        * @return Principal's name or null
-        */
-       protected String determinePrincipalName () {
-               // Get principal
-               Principal userPrincipal = FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal();
-
-               // Init with null
-               String principalName = null;
-
-               // Is the principal set?
-               if (userPrincipal instanceof Principal) {
-                       // Get principal's name
-                       principalName = userPrincipal.getName();
-               }
-
-               // Return it
-               return principalName;
-       }
-
-       /**
-        * Returns given property key or throws an exception if not found.
-        * <p>
-        * @param parameterKey Property key
-        * <p>
-        * @return Property value
-        * <p>
-        * @throws NullPointerException If given key is not found
-        * @throws NumberFormatException If no number is given in context parameter
-        */
-       protected int getIntegerContextParameter (final String parameterKey) throws NullPointerException, NumberFormatException {
-               // Get context parameter
-               Integer contextValue = Integer.parseInt(this.getStringContextParameter(parameterKey));
-
-               // Return it
-               return contextValue;
-       }
-
-       /**
-        * Returns given property key or throws an exception if not found.
-        * <p>
-        * @param parameterKey Property key
-        * <p>
-        * @return Property value
-        * <p>
-        * @throws NullPointerException If given key is not found
-        */
-       protected String getStringContextParameter (final String parameterKey) throws NullPointerException {
-               // Get context parameter
-               String contextValue = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(parameterKey);
-
-               // Is it null?
-               if (null == contextValue) {
-                       // Throw NPE
-                       throw new NullPointerException(MessageFormat.format("parameterKey={0} is not set.", parameterKey)); //NOI18N
-               }
-
-               // Return it
-               return contextValue;
-       }
-
-       /**
-        * Checks whether debug mode is enabled for given controller
-        * <p>
-        * @param controllerName Name of controller
-        * <p>
-        * @return Whether debug mode is enabled
-        */
-       protected boolean isDebugModeEnabled (final String controllerName) {
-               // Parameters should be valid
-               if (null == controllerName) {
-                       // Throw NPE
-                       throw new NullPointerException("controllerName is null"); //NOI18N
-               } else if (controllerName.isEmpty()) {
-                       // Is empty
-                       throw new IllegalArgumentException("controllerName is empty"); //NOI18N
-               }
-
-               // Try to get context parameter
-               String contextParameter = this.getStringContextParameter(String.format("is_debug_%s_enabled", controllerName)); //NOI18N
-
-               // Is it set and true?
-               boolean isEnabled = (Boolean.parseBoolean(contextParameter) == Boolean.TRUE);
-
-               // Return it
-               return isEnabled;
-       }
-
        /**
         * Checks if given password is to weak to be used
         * <p>
@@ -159,62 +62,4 @@ public abstract class BaseFinancialsController implements Serializable {
                return isWeak;
        }
 
-       /**
-        * Shows a faces message for given causing exception. The message from the
-        * exception is being inserted into the message.
-        * <p>
-        * @param clientId Client id to send message to
-        * @param cause Causing exception
-        */
-       protected void showFacesMessage (final String clientId, final Throwable cause) {
-               // Get context and add message
-               this.showFacesMessage(clientId, cause.getMessage());
-       }
-
-       /**
-        * Shows a faces message with given message (i18n) key.
-        * <p>
-        * @param clientId Client id to send message to
-        * @param i18nKey Message key
-        * <p>
-        * @throws NullPointerException If clientId or i18nKey is null
-        * @throws IllegalArgumentException If clientId or i18nKey is empty
-        */
-       protected void showFacesMessage (final String clientId, final String i18nKey) throws NullPointerException, IllegalArgumentException {
-               // Both parameter must be valid
-               if (null == clientId) {
-                       // Throw NPE
-                       throw new NullPointerException("clientId is null"); //NOI18N
-               } else if (clientId.isEmpty()) {
-                       // Is empty
-                       throw new IllegalArgumentException("clientId is null"); //NOI18N
-               } else if (null == i18nKey) {
-                       // Throw NPE
-                       throw new NullPointerException("i18nKey is null"); //NOI18N
-               } else if (i18nKey.isEmpty()) {
-                       // Is empty
-                       throw new IllegalArgumentException("i18nKey is null"); //NOI18N
-               }
-
-               // Get current locale
-               Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
-
-               // Get bundle bundle
-               ResourceBundle bundle = ResourceBundle.getBundle("org.mxchange.localization.bundle", locale);
-
-               // Default is i18nKey
-               String message = i18nKey;
-
-               // Try it
-               try {
-                       // Get message
-                       message = bundle.getString(i18nKey);
-               } catch (final MissingResourceException ex) {
-                       // Did not find it, ignored
-               }
-
-               // Get context and add message
-               FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(message));
-       }
-
 }
diff --git a/src/java/org/mxchange/jfinancials/beans/financial/income/FinancialsAdminFinancialIncomeWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/financial/income/FinancialsAdminFinancialIncomeWebRequestBean.java
deleted file mode 100644 (file)
index dd92145..0000000
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jfinancials.beans.financial.income;
-
-import java.text.MessageFormat;
-import java.util.Arrays;
-import java.util.List;
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.RequestScoped;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jfinancials.beans.BaseFinancialsController;
-import org.mxchange.jfinancials.beans.login.user.FinancialsUserLoginWebSessionController;
-import org.mxchange.jfinancials.financial.income.FinancialIncomeSessionBeanRemote;
-import org.mxchange.jfinancials.model.income.BillableIncome;
-import org.mxchange.jfinancials.model.income.FinancialIncome;
-import org.mxchange.jfinancials.model.income.interval.FinancialInterval;
-
-/**
- * An administrative financial income bean (controller)
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("financialIncomeController")
-@RequestScoped
-public class FinancialsAdminFinancialIncomeWebRequestBean extends BaseFinancialsController implements FinancialsAdminFinancialIncomeWebRequestController {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 56_189_028_928_371L;
-
-       /**
-        * Remote contact bean
-        */
-       private FinancialIncomeSessionBeanRemote financialBean;
-
-       /**
-        * Income interval
-        */
-       private FinancialInterval incomeInterval;
-
-       /**
-        * Income single amount
-        */
-       private Float incomeSingleAmount;
-
-       /**
-        * Income (type) title
-        */
-       private String incomeTitle;
-
-       /**
-        * User instance
-        */
-       @Inject
-       private FinancialsUserLoginWebSessionController userLoginController;
-
-       /**
-        * Constructor
-        */
-       public FinancialsAdminFinancialIncomeWebRequestBean () {
-               // Call super constructor
-               super();
-       }
-
-       /**
-        * Adds income data by calling proper business method of the EJB.
-        * <p>
-        * @return Redirect outcome
-        */
-       public String addFinancialIncome () {
-               // Is all data valid?
-               if (!this.userLoginController.isUserLoggedIn()) {
-                       // Not logged-in
-                       throw new IllegalStateException("User is not logged-in"); //NOI18N
-               } else if (null == this.getIncomeInterval()) {
-                       // Throw NPE
-                       throw new NullPointerException("incomeInterval is null"); //NOI18N
-               } else if (null == this.getIncomeSingleAmount()) {
-                       // Throw again
-                       throw new NullPointerException("incomeSingleAmount is null"); //NOI18N
-               } else if (this.getIncomeSingleAmount() < 0) {
-                       // Not allowed value
-                       throw new IllegalArgumentException(MessageFormat.format("incomeSingleAmount={0} is not valid.", this.getIncomeSingleAmount())); //NOI18N
-               } else if (null == this.getIncomeTitle()) {
-                       // Throw again
-                       throw new NullPointerException("incomeTitle is null"); //NOI18N
-               } else if (this.getIncomeTitle().isEmpty()) {
-                       // Should not be empty
-                       throw new IllegalArgumentException("incomeTitle is empty"); //NOI18N
-               }
-
-               // Now that all required data has been entered, prepare new income instance
-               BillableIncome income = new FinancialIncome(this.getIncomeTitle(), this.getIncomeSingleAmount(), this.getIncomeInterval(), this.userLoginController.getLoggedInUser());
-
-               // Handle it over to the EJB
-               // @TODO Use updated income instance, e.g. fire event
-               BillableIncome updatedIncome = this.financialBean.addIncome(income);
-
-               // All fine
-               return "add_user_fiancial_income"; //NOI18N
-       }
-
-       @Override
-       public List<FinancialInterval> getAllIncomeIntervals () {
-               // Init array
-               List<FinancialInterval> incomeIntervals = Arrays.asList(FinancialInterval.values());
-
-               // Return it
-               return incomeIntervals;
-       }
-
-       @Override
-       public FinancialInterval getIncomeInterval () {
-               return this.incomeInterval;
-       }
-
-       @Override
-       public void setIncomeInterval (final FinancialInterval incomeInterval) {
-               this.incomeInterval = incomeInterval;
-       }
-
-       @Override
-       public Float getIncomeSingleAmount () {
-               return this.incomeSingleAmount;
-       }
-
-       @Override
-       public void setIncomeSingleAmount (final Float incomeSingleAmount) {
-               this.incomeSingleAmount = incomeSingleAmount;
-       }
-
-       @Override
-       public String getIncomeTitle () {
-               return this.incomeTitle;
-       }
-
-       @Override
-       public void setIncomeTitle (final String incomeTitle) {
-               this.incomeTitle = incomeTitle;
-       }
-
-       /**
-        * Post-initialization of this class
-        */
-       @PostConstruct
-       public void init () {
-               // Try it
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup
-                       this.financialBean = (FinancialIncomeSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/financial!org.mxchange.jfinancials.financial.income.FinancialIncomeSessionBeanRemote"); //NOI18N
-               } catch (final NamingException e) {
-                       // Throw again
-                       throw new FaceletException(e);
-               }
-       }
-
-}
diff --git a/src/java/org/mxchange/jfinancials/beans/financial/income/FinancialsAdminFinancialIncomeWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/financial/income/FinancialsAdminFinancialIncomeWebRequestController.java
deleted file mode 100644 (file)
index 85b993d..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jfinancials.beans.financial.income;
-
-import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jfinancials.model.income.interval.FinancialInterval;
-
-/**
- * An administrative interface for financial income beans
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface FinancialsAdminFinancialIncomeWebRequestController extends Serializable {
-
-       /**
-        * Getter for income single amount
-        * <p>
-        * @return Income single amount
-        */
-       Float getIncomeSingleAmount ();
-
-       /**
-        * Setter for income single amount
-        * <p>
-        * @param incomeSingleAmount Income single amount
-        */
-       void setIncomeSingleAmount (final Float incomeSingleAmount);
-
-       /**
-        * Getter for income (type) title
-        * <p>
-        * @return Income title
-        */
-       String getIncomeTitle ();
-
-       /**
-        * Setter for income (type) title
-        * <p>
-        * @param incomeTitle Income title
-        */
-       void setIncomeTitle (final String incomeTitle);
-
-       /**
-        * Getter for income interval
-        * <p>
-        * @return Income interval
-        */
-       FinancialInterval getIncomeInterval ();
-
-       /**
-        * Setter for income (type) interval
-        * <p>
-        * @param incomeInterval Income interval
-        */
-       void setIncomeInterval (final FinancialInterval incomeInterval);
-
-       /**
-        * Returns a list of all all income intervals
-        * <p>
-        * @return Income intervals
-        */
-       List<FinancialInterval> getAllIncomeIntervals ();
-
-}
diff --git a/src/java/org/mxchange/jfinancials/beans/financial/income/FinancialsIncomeWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/financial/income/FinancialsIncomeWebRequestBean.java
new file mode 100644 (file)
index 0000000..5accbae
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.beans.financial.income;
+
+import java.text.MessageFormat;
+import java.util.Arrays;
+import java.util.List;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.RequestScoped;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jfinancials.beans.login.user.FinancialsUserLoginWebSessionController;
+import org.mxchange.jfinancials.financial.income.FinancialIncomeSessionBeanRemote;
+import org.mxchange.jfinancials.model.income.BillableIncome;
+import org.mxchange.jfinancials.model.income.FinancialIncome;
+import org.mxchange.jfinancials.model.income.interval.FinancialInterval;
+
+/**
+ * An administrative financial income bean (controller)
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("financialIncomeController")
+@RequestScoped
+public class FinancialsIncomeWebRequestBean extends BaseFinancialsController implements FinancialsIncomeWebRequestController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 56_189_028_928_371L;
+
+       /**
+        * Remote contact bean
+        */
+       private FinancialIncomeSessionBeanRemote financialBean;
+
+       /**
+        * Income interval
+        */
+       private FinancialInterval incomeInterval;
+
+       /**
+        * Income single amount
+        */
+       private Float incomeSingleAmount;
+
+       /**
+        * Income (type) title
+        */
+       private String incomeTitle;
+
+       /**
+        * User instance
+        */
+       @Inject
+       private FinancialsUserLoginWebSessionController userLoginController;
+
+       /**
+        * Constructor
+        */
+       public FinancialsIncomeWebRequestBean () {
+               // Call super constructor
+               super();
+       }
+
+       /**
+        * Adds income data by calling proper business method of the EJB.
+        * <p>
+        * @return Redirect outcome
+        */
+       public String addIncome () {
+               // Is all data valid?
+               if (!this.userLoginController.isUserLoggedIn()) {
+                       // Not logged-in
+                       throw new IllegalStateException("User is not logged-in"); //NOI18N
+               } else if (null == this.getIncomeInterval()) {
+                       // Throw NPE
+                       throw new NullPointerException("incomeInterval is null"); //NOI18N
+               } else if (null == this.getIncomeSingleAmount()) {
+                       // Throw again
+                       throw new NullPointerException("incomeSingleAmount is null"); //NOI18N
+               } else if (this.getIncomeSingleAmount() < 0) {
+                       // Not allowed value
+                       throw new IllegalArgumentException(MessageFormat.format("incomeSingleAmount={0} is not valid.", this.getIncomeSingleAmount())); //NOI18N
+               } else if (null == this.getIncomeTitle()) {
+                       // Throw again
+                       throw new NullPointerException("incomeTitle is null"); //NOI18N
+               } else if (this.getIncomeTitle().isEmpty()) {
+                       // Should not be empty
+                       throw new IllegalArgumentException("incomeTitle is empty"); //NOI18N
+               }
+
+               // Now that all required data has been entered, prepare new income instance
+               BillableIncome income = new FinancialIncome(this.getIncomeTitle(), this.getIncomeSingleAmount(), this.getIncomeInterval(), this.userLoginController.getLoggedInUser());
+
+               // Handle it over to the EJB
+               // @TODO Use updated income instance, e.g. fire event
+               BillableIncome updatedIncome = this.financialBean.addIncome(income);
+
+               // All fine
+               return "add_user_fiancial_income"; //NOI18N
+       }
+
+       @Override
+       public List<FinancialInterval> allIncomeIntervals () {
+               // Init array
+               List<FinancialInterval> incomeIntervals = Arrays.asList(FinancialInterval.values());
+
+               // Return it
+               return incomeIntervals;
+       }
+
+       @Override
+       public FinancialInterval getIncomeInterval () {
+               return this.incomeInterval;
+       }
+
+       @Override
+       public void setIncomeInterval (final FinancialInterval incomeInterval) {
+               this.incomeInterval = incomeInterval;
+       }
+
+       @Override
+       public Float getIncomeSingleAmount () {
+               return this.incomeSingleAmount;
+       }
+
+       @Override
+       public void setIncomeSingleAmount (final Float incomeSingleAmount) {
+               this.incomeSingleAmount = incomeSingleAmount;
+       }
+
+       @Override
+       public String getIncomeTitle () {
+               return this.incomeTitle;
+       }
+
+       @Override
+       public void setIncomeTitle (final String incomeTitle) {
+               this.incomeTitle = incomeTitle;
+       }
+
+       /**
+        * Post-initialization of this class
+        */
+       @PostConstruct
+       public void init () {
+               // Try it
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Try to lookup
+                       this.financialBean = (FinancialIncomeSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/financial!org.mxchange.jfinancials.financial.income.FinancialIncomeSessionBeanRemote"); //NOI18N
+               } catch (final NamingException e) {
+                       // Throw again
+                       throw new FaceletException(e);
+               }
+       }
+
+}
diff --git a/src/java/org/mxchange/jfinancials/beans/financial/income/FinancialsIncomeWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/financial/income/FinancialsIncomeWebRequestController.java
new file mode 100644 (file)
index 0000000..e25f954
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.beans.financial.income;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jfinancials.model.income.interval.FinancialInterval;
+
+/**
+ * An administrative interface for financial income beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsIncomeWebRequestController extends Serializable {
+
+       /**
+        * Getter for income single amount
+        * <p>
+        * @return Income single amount
+        */
+       Float getIncomeSingleAmount ();
+
+       /**
+        * Setter for income single amount
+        * <p>
+        * @param incomeSingleAmount Income single amount
+        */
+       void setIncomeSingleAmount (final Float incomeSingleAmount);
+
+       /**
+        * Getter for income (type) title
+        * <p>
+        * @return Income title
+        */
+       String getIncomeTitle ();
+
+       /**
+        * Setter for income (type) title
+        * <p>
+        * @param incomeTitle Income title
+        */
+       void setIncomeTitle (final String incomeTitle);
+
+       /**
+        * Getter for income interval
+        * <p>
+        * @return Income interval
+        */
+       FinancialInterval getIncomeInterval ();
+
+       /**
+        * Setter for income (type) interval
+        * <p>
+        * @param incomeInterval Income interval
+        */
+       void setIncomeInterval (final FinancialInterval incomeInterval);
+
+       /**
+        * Returns a list of all all income intervals
+        * <p>
+        * @return Income intervals
+        */
+       List<FinancialInterval> allIncomeIntervals ();
+
+}
diff --git a/src/java/org/mxchange/jfinancials/beans/financial/receipt/FinancialsReceiptWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/financial/receipt/FinancialsReceiptWebRequestBean.java
new file mode 100644 (file)
index 0000000..62dcccf
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.beans.financial.receipt;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.RequestScoped;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jfinancials.beans.login.user.FinancialsUserLoginWebSessionController;
+import org.mxchange.jfinancials.financial.receipt.FinancialReceiptSessionBeanRemote;
+
+/**
+ * An administrative financial receipt bean (controller)
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("financialReceiptController")
+@RequestScoped
+public class FinancialsReceiptWebRequestBean extends BaseFinancialsController implements FinancialsReceiptWebRequestController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 56_189_028_928_371L;
+
+       /**
+        * Remote contact bean
+        */
+       private FinancialReceiptSessionBeanRemote financialBean;
+
+       /**
+        * User instance
+        */
+       @Inject
+       private FinancialsUserLoginWebSessionController userLoginController;
+
+       /**
+        * Constructor
+        */
+       public FinancialsReceiptWebRequestBean () {
+               // Call super constructor
+               super();
+       }
+
+       /**
+        * Post-initialization of this class
+        */
+       @PostConstruct
+       public void init () {
+               // Try it
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Try to lookup
+                       this.financialBean = (FinancialReceiptSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/financial!org.mxchange.jfinancials.financial.receipt.FinancialReceiptSessionBeanRemote"); //NOI18N
+               } catch (final NamingException e) {
+                       // Throw again
+                       throw new FaceletException(e);
+               }
+       }
+
+}
diff --git a/src/java/org/mxchange/jfinancials/beans/financial/receipt/FinancialsReceiptWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/financial/receipt/FinancialsReceiptWebRequestController.java
new file mode 100644 (file)
index 0000000..67416d8
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.beans.financial.receipt;
+
+import java.io.Serializable;
+
+/**
+ * An administrative interface for financial receipt beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsReceiptWebRequestController extends Serializable {
+
+}
index 2d9fc075db1eefa21798ff7bf7051bb7e0420fd5..822148caec2b841ba071fc156b81e54432bdddbb 100644 (file)
@@ -4,7 +4,8 @@
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
-       xmlns:p="http://primefaces.org/ui">
+       xmlns:p="http://primefaces.org/ui"
+       >
 
        <div class="para notice">
                #{msg.PERSONAL_DATA_MINIMUM_NOTICE}
index b789487e27bf7e368d6e380bbe80da287e7a516d..a81cd7f8ba3e5fb224d66505500efa9eb45b6983 100644 (file)
@@ -44,7 +44,7 @@
                                                <div class="table_right_medium">
                                                        <h:selectOneMenu styleClass="select" id="incomeInterval" value="#{financialIncomeController.incomeInterval}" required="true" requiredMessage="#{msg.FIELD_FINANCIAL_INCOME_REQUIRED}">
                                                                <f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" noSelectionOption="true" />
-                                                               <f:selectItems value="#{financialIncomeController.allIncomeIntervals}" var="incomeInterval" itemValue="#{incomeInterval}" itemLabel="#{msg[incomeInterval.concat('_INTERVAL')]}" />
+                                                               <f:selectItems value="#{financialIncomeController.allIncomeIntervals()}" var="incomeInterval" itemValue="#{incomeInterval}" itemLabel="#{msg[incomeInterval.concat('_INTERVAL')]}" />
                                                        </h:selectOneMenu>
                                                </div>
 
@@ -68,7 +68,7 @@
                                        <div class="table_footer">
                                                <h:commandButton styleClass="reset right_space" type="reset" value="#{msg.BUTTON_RESET_FORM}" />
 
-                                               <h:commandButton styleClass="submit" id="submit_add_income" type="submit" action="#{financialIncomeController.addFinancialIncome()}" value="#{msg.BUTTON_LOGIN_FINCIAL_ADD_INCOME}" />
+                                               <h:commandButton styleClass="submit" id="submit_add_income" type="submit" action="#{financialIncomeController.addIncome()}" value="#{msg.BUTTON_LOGIN_FINCIAL_ADD_INCOME}" />
                                        </div>
                                </h:panelGroup>
                        </h:form>
index 9cfbc754b0ce042eb9954ea423587aac56c0b724..1a0e88eeb88410b6ee0934feb64ffde3ba30af94 100644 (file)
@@ -4,7 +4,8 @@
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:h="http://xmlns.jcp.org/jsf/html"
          xmlns:f="http://xmlns.jcp.org/jsf/core"
-         >
+         xmlns:p="http://primefaces.org/ui">
+       >
 
        <ui:composition template="/WEB-INF/templates/login/user/user_base.tpl">
                <ui:define name="login_title">
 
                <ui:define name="content">
                        <h:form id="form_add_financials_receipt">
+                               <h:panelGroup styleClass="table_medium" layout="block">
+                                       <div class="table_header">
+                                               <h:outputText value="#{msg.LOGIN_FINANCIAL_ADD_RECEIPT_FORM_TITLE}" />
+                                       </div>
 
+                                       <div class="table_row">
+                                               <div class="table_left_medium">
+                                                       <h:outputLabel for="receiptCompany" value="#{msg.LOGIN_FINANCIAL_SELECT_RECEIPT_COMPANY}" />
+                                               </div>
+
+                                               <div class="table_right_medium">
+                                                       <h:selectOneMenu styleClass="select" id="receiptCompany" value="#{financialReceiptController.incomeInterval}" required="true" requiredMessage="#{msg.FIELD_FINANCIAL_RECEIPT_COMPANY_REQUIRED}">
+                                                               <f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" noSelectionOption="true" />
+                                                               <f:selectItems value="#{financialReceiptController.allRegisteredCompanies()}" var="receiptCompany" itemValue="#{receiptCompany}" itemLabel="#{receiptCompany.someFoo}" />
+                                                       </h:selectOneMenu>
+                                               </div>
+
+                                               <div class="clear"></div>
+                                       </div>
+
+                                       <div class="table_row">
+                                               <div class="table_left_medium">
+                                                       <h:outputLabel for="receiptCreated" value="#{msg.LOGIN_FINANCIAL_ENTER_RECEIPT_CREATED}" />
+                                               </div>
+
+                                               <div class="table_right_medium">
+                                                       <p:calendar id="receiptCreated" locale="#{localizationController.locale.displayCountry}" value="#{financialReceiptController.receiptCreated}" />
+                                               </div>
+
+                                               <div class="clear"></div>
+                                       </div>
+
+                                       <div class="table_row">
+                                               <h:outputText value="#{msg.LOGIN_FINANCIAL_COMPANY_NOT_FOUND}" />
+                                               <h:outputText value="&nbsp;" />
+                                               <p:link title="#{msg.LINK_LOGIN_FINANCIAL_ADD_COMPANY_TITLE}" outcome="login_add_receipt_company" value="#{msg.LINK_LOGIN_FINANCIAL_ADD_COMPANY}" />
+                                       </div>
+
+                                       <div class="table_footer">
+                                               <h:commandButton styleClass="reset right_space" type="reset" value="#{msg.BUTTON_RESET_FORM}" />
+
+                                               <h:commandButton styleClass="submit" id="submit_add_income" type="submit" action="#{financialReceiptController.addReceipt()}" value="#{msg.BUTTON_LOGIN_FINCIAL_ADD_INCOME}" />
+                                       </div>
+                               </h:panelGroup>
                        </h:form>
                </ui:define>
        </ui:composition>