*/
package org.mxchange.jcoreee.bean.faces;
+import java.io.Serializable;
+import java.math.BigDecimal;
import java.security.Principal;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.ResourceBundle;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
-import org.mxchange.jcoreee.bean.BaseBean;
/**
* An abstract bean for faces (web) projects.
* <p>
* @author Roland Häder<roland@mxchange.org>
*/
-public abstract class BaseFacesBean extends BaseBean {
+public abstract class BaseFacesBean implements Serializable {
/**
* Loaded resource bundles ("cached")
/**
* Removes all bundles from web application. Typically you want to invoke
- * this method in a ServletContextListener implemetation on the
+ * this method in a ServletContextListener implementation on the
* contextDestroyed() method.
*/
public static void removeBundles () {
* Protected constructor
*/
protected BaseFacesBean () {
- // Call super constructor
- super();
+ }
+
+ /**
+ * A filter for prices
+ * <p>
+ * @param value Actual value to check
+ * @param filter Filter value to check against {@code value}
+ * @param locale Locale
+ * <p>
+ * @return Whether price ({@code value}) is at least {@code filter}
+ *
+ * @see https://www.primefaces.org/showcase/ui/data/datatable/filter.xhtml
+ */
+ @SuppressWarnings ("unchecked")
+ public boolean filterByPrice (final Object value, final Object filter, final Locale locale) {
+ // Get trimmed string or NULL
+ final String filterText = (filter == null) ? null : filter.toString().trim();
+
+ // Is null or empty?
+ if (filterText == null || filterText.isEmpty()) {
+ // Then return TRUE
+ return true;
+ }
+
+ // Is value NULL or not castable?
+ if (value == null) {
+ // Return FALSE
+ return false;
+ } else if (!(value instanceof Comparable)) {
+ // Not castable
+ throw new ClassCastException("value is not instance of Comparable");
+ }
+
+ // Do the cast and compare
+ return ((Comparable<BigDecimal>) value).compareTo(BigDecimal.valueOf(Double.valueOf(filterText))) >= 0;
}
/**