]> git.mxchange.org Git - pizzaservice-war.git/blobdiff - src/java/org/mxchange/pizzaapplication/beans/BasePizzaController.java
Please rename:
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / beans / BasePizzaController.java
index 29e50a59bf08a7bed708b9ef2c30939cac7f07d7..88e5c23e3db62e446c2738225f651e6524f1aac5 100644 (file)
@@ -33,6 +33,47 @@ public abstract class BasePizzaController implements Serializable {
         */
        private static final long serialVersionUID = 50_837_597_127_567_140L;
 
+       /**
+        * 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("parameterKey=" + parameterKey + " is not set.");
+               }
+
+               // Return it
+               return contextValue;
+       }
+
        /**
         * Checks whether debug mode is enabled for given controller
         * <p>
@@ -65,55 +106,25 @@ public abstract class BasePizzaController implements Serializable {
         * exception is being inserted into the message.
         * <p>
         * @param clientId Client id to send message to
-        * @param cause Causing exception
+        * @param cause    Causing exception
         */
        protected void showFacesMessage (final String clientId, final Throwable cause) {
                // Trace message
                System.out.println(MessageFormat.format("showFacesMessage: clientId={0},cause={1} - CALLED!", clientId, cause));
 
                // Get context and add message
-               FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(cause.getMessage()));
-       }
-
-       /**
-        * 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;
+               this.showFacesMessage(clientId, cause.getMessage());
        }
 
        /**
-        * Returns given property key or throws an exception if not found.
+        * Shows a faces message with given message.
         * <p>
-        * @param parameterKey Property key
-        * <p>
-        * @return Property value
-        * <p>
-        * @throws NullPointerException If given key is not found
+        * @param clientId Client id to send message to
+        * @param message Causing exception
         */
-       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("parameterKey=" + parameterKey + " is not set.");
-               }
-
-               // Return it
-               return contextValue;
+       protected void showFacesMessage (final String clientId, final String message) {
+               // Get context and add message
+               FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(message));
        }
 
 }