diff --git a/core/src/main/java/org/primefaces/extensions/component/clockpicker/ClockPickerRenderer.java b/core/src/main/java/org/primefaces/extensions/component/clockpicker/ClockPickerRenderer.java
index b0631a2fa..b8f5a725f 100644
--- a/core/src/main/java/org/primefaces/extensions/component/clockpicker/ClockPickerRenderer.java
+++ b/core/src/main/java/org/primefaces/extensions/component/clockpicker/ClockPickerRenderer.java
@@ -112,29 +112,30 @@ private void encodeScript(final FacesContext context, final ClockPicker clockPic
}
protected static String getValueAsString(final FacesContext context, final ClockPicker clockPicker) {
- final Object submittedValue = clockPicker.getSubmittedValue();
+ Object submittedValue = clockPicker.getSubmittedValue();
if (submittedValue != null) {
return submittedValue.toString();
}
- final Object value = clockPicker.getValue();
+ Object value = clockPicker.getValue();
if (value == null) {
return null;
}
- else {
+
+ try {
if (clockPicker.getConverter() != null) {
- // convert via registered converter
return clockPicker.getConverter().getAsString(context, clockPicker, value);
}
- else {
- // use built-in converter
- if (value instanceof LocalTime) {
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
- return formatter.format((LocalTime) value);
- }
+ else if (value instanceof LocalTime) {
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
+ return formatter.format((LocalTime) value);
}
}
- return "";
+ catch (Exception e) {
+ return null;
+ }
+
+ return null;
}
@Override
@@ -155,7 +156,7 @@ public Object getConvertedValue(FacesContext context, UIComponent component,
}
}
catch (ConverterException e) {
- throw e;
+ return null;
}
// Delegate to global defined converter (e.g. joda or java8)
@@ -170,11 +171,9 @@ public Object getConvertedValue(FacesContext context, UIComponent component,
}
}
}
- catch (ConverterException e) {
- throw e;
+ catch (Exception e) {
+ return null;
}
return null;
-
}
-
}
\ No newline at end of file
diff --git a/core/src/main/resources/META-INF/primefaces-extensions.taglib.xml b/core/src/main/resources/META-INF/primefaces-extensions.taglib.xml
index 588e711ea..b3c1861d9 100755
--- a/core/src/main/resources/META-INF/primefaces-extensions.taglib.xml
+++ b/core/src/main/resources/META-INF/primefaces-extensions.taglib.xml
@@ -10438,7 +10438,7 @@ See showcase for an example. Default null.]]>
value
false
- java.time.LocalTime
+ java.lang.Object
diff --git a/core/src/main/resources/META-INF/resources/primefaces-extensions/clockpicker/1-clockpicker-widget.js b/core/src/main/resources/META-INF/resources/primefaces-extensions/clockpicker/1-clockpicker-widget.js
index ff96c5508..14e80d135 100644
--- a/core/src/main/resources/META-INF/resources/primefaces-extensions/clockpicker/1-clockpicker-widget.js
+++ b/core/src/main/resources/META-INF/resources/primefaces-extensions/clockpicker/1-clockpicker-widget.js
@@ -16,10 +16,56 @@ PrimeFaces.widget.ExtClockPicker = PrimeFaces.widget.BaseWidget.extend({
this.jqEl = this.jqId + '_input';
this.jq = $(this.jqEl);
- this.jq.clockpicker(this.cfg);
+ this.clockpicker = this.jq.clockpicker(this.cfg);
// pfs metadata
$(this.jqId + '_input').data(PrimeFaces.CLIENT_ID_DATA, this.id);
this.originalValue = this.jq.val();
+ },
+
+ // @override
+ refresh: function(cfg) {
+ // Destroy previous instance
+ if (this.clockpicker) {
+ this.clockpicker.remove()
+ }
+ // Reinitialize with new configuration
+ this._super(cfg);
+ },
+
+ // @override
+ destroy: function() {
+ this._super();
+ // Destroy clockpicker instance
+ this.remove()
+ },
+
+ /**
+ * Hides the clockpicker if it exists.
+ * @function hide
+ */
+ hide: function() {
+ if (this.clockpicker) {
+ this.clockpicker.hide()
+ }
+ },
+
+ /**
+ * Shows the clockpicker if it exists.
+ * @function show
+ */
+ show: function() {
+ if (this.clockpicker) {
+ this.clockpicker.show()
+ }
+ },
+ /**
+ * Removes the clockpicker and its event listeners if it exists.
+ * @function remove
+ */
+ remove: function() {
+ if (this.clockpicker) {
+ this.clockpicker.remove()
+ }
}
});
\ No newline at end of file
diff --git a/showcase/src/main/java/org/primefaces/extensions/showcase/controller/ClockPickerController.java b/showcase/src/main/java/org/primefaces/extensions/showcase/controller/ClockPickerController.java
index 411a7ea29..09e7f21b2 100644
--- a/showcase/src/main/java/org/primefaces/extensions/showcase/controller/ClockPickerController.java
+++ b/showcase/src/main/java/org/primefaces/extensions/showcase/controller/ClockPickerController.java
@@ -49,11 +49,16 @@ public ClockPickerController() {
}
public void showTime() {
- int hour = time.getHour();
- int min = time.getMinute();
+ if (time != null) {
+ int hour = time.getHour();
+ int min = time.getMinute();
- String message = String.format("Selected hour: %d, Selected min: %d", hour, min);
- addMessage(FacesMessage.SEVERITY_INFO, "Info Message", message);
+ String message = String.format("Selected hour: %d, Selected min: %d", hour, min);
+ addMessage(FacesMessage.SEVERITY_INFO, "Info Message", message);
+ }
+ else {
+ addMessage(FacesMessage.SEVERITY_ERROR, "Error Message", "Time is not selected.");
+ }
}
private void addMessage(FacesMessage.Severity severity, String summary, String detail) {
diff --git a/showcase/src/main/webapp/sections/clockpicker/example-basicUsage.xhtml b/showcase/src/main/webapp/sections/clockpicker/example-basicUsage.xhtml
index 5f0fc7005..6335b7dc0 100644
--- a/showcase/src/main/webapp/sections/clockpicker/example-basicUsage.xhtml
+++ b/showcase/src/main/webapp/sections/clockpicker/example-basicUsage.xhtml
@@ -7,7 +7,7 @@
-
+