Skip to content

Commit

Permalink
b:dateTimePicker fix for allow-input-toggle and inline mode
Browse files Browse the repository at this point in the history
The assignment of the JQuery identifier wasn't correct in the different
cases, "inline", "popup". Also there was a difference between rendering
with an assigned id and with none id.

Fix TheCoder4eu#590
  • Loading branch information
jens committed Jan 4, 2017
1 parent 4f0cc10 commit f5ee461
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ private String encodeHTML(FacesContext fc, ResponseWriter rw, DateTimePicker dtp
String styleClass = dtp.getStyleClass();
if(styleClass == null) styleClass = "";
styleClass = styleClass.trim();
String datePickerId;

String responsiveStyleClass = Responsive.getResponsiveStyleClass(dtp, false);
String label = dtp.getLabel();
Expand Down Expand Up @@ -241,7 +242,8 @@ private String encodeHTML(FacesContext fc, ResponseWriter rw, DateTimePicker dtp
rw.writeAttribute("class", ("input-group date " + styleClass).trim(), "class");
if(dtp.getStyle() != null) rw.writeAttribute("style", (dtp.isDisabled() ? "opacity: 0.65; pointer-events: none;" : "") + dtp.getStyle(), "style");
else if(dtp.isDisabled()) rw.writeAttribute("style", "opacity: 0.65; pointer-events: none;", null);
rw.writeAttribute("id", divPrefix + clientId, null);
datePickerId = divPrefix + clientId;
rw.writeAttribute("id", datePickerId, null);
if (!clientIdHasBeenRendered) {
Tooltip.generateTooltip(fc, dtp, rw);
clientIdHasBeenRendered=true;
Expand Down Expand Up @@ -269,7 +271,8 @@ private String encodeHTML(FacesContext fc, ResponseWriter rw, DateTimePicker dtp
String inputGroup = dtp.isShowIcon() ? "input-group " : "";
rw.writeAttribute("class", (inputGroup +"date " + styleClass).trim(), "class");
if(dtp.getStyle() != null) rw.writeAttribute("style", dtp.getStyle(), "style");
rw.writeAttribute("id", divPrefix + clientId, null);
datePickerId = divPrefix + clientId;
rw.writeAttribute("id", datePickerId, null);
if (!clientIdHasBeenRendered) {
Tooltip.generateTooltip(fc, dtp, rw);
clientIdHasBeenRendered=true;
Expand Down Expand Up @@ -326,7 +329,7 @@ private String encodeHTML(FacesContext fc, ResponseWriter rw, DateTimePicker dtp
}
Tooltip.activateTooltips(fc, dtp);

return divPrefix;
return datePickerId;
}

private void generateStyleClass(DateTimePicker dtp, ResponseWriter rw)
Expand Down Expand Up @@ -360,7 +363,7 @@ private void generateStyleClass(DateTimePicker dtp, ResponseWriter rw)
* Encode the javascript code
* @throws IOException
*/
private void encodeJS(FacesContext fc, ResponseWriter rw, DateTimePicker dtp, String divPrefix)
private void encodeJS(FacesContext fc, ResponseWriter rw, DateTimePicker dtp, String datePickerId)
throws IOException {
String clientId = dtp.getClientId();
String fieldId = dtp.getFieldId();
Expand Down Expand Up @@ -391,7 +394,7 @@ private void encodeJS(FacesContext fc, ResponseWriter rw, DateTimePicker dtp, St
:
getDateAsString(fc, dtp, v, LocaleUtils.momentToJavaFormat(format), sloc)) + "'";

String fullSelector = "#" + BsfUtils.escapeJQuerySpecialCharsInSelector(clientId);
String fullSelector = "#" + BsfUtils.escapeJQuerySpecialCharsInSelector(datePickerId);

String defaultDate = BsfUtils.isStringValued(dtp.getInitialDate()) ?
dtp.getInitialDate().contains("moment") ? dtp.getInitialDate() : "'" + dtp.getInitialDate() + "'" : "";
Expand Down

0 comments on commit f5ee461

Please sign in to comment.