List of usage examples for java.util Calendar getFirstDayOfWeek
public int getFirstDayOfWeek()
SUNDAY
in the U.S., MONDAY
in France. From source file:com.icesoft.faces.component.selectinputdate.SelectInputDateRenderer.java
public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException { validateParameters(facesContext, uiComponent, SelectInputDate.class); DOMContext domContext = DOMContext.attachDOMContext(facesContext, uiComponent); SelectInputDate selectInputDate = (SelectInputDate) uiComponent; Date value;//from w ww . jav a 2s .c om boolean actuallyHaveTime = false; if (selectInputDate.isNavEvent()) { if (log.isTraceEnabled()) { log.trace("Rendering Nav Event"); } value = selectInputDate.getNavDate(); //System.out.println("navDate: " + value); } else if (selectInputDate.isRenderAsPopup() && !selectInputDate.isEnterKeyPressed(facesContext)) { value = selectInputDate.getPopupDate(); if (value != null) { actuallyHaveTime = true; } } else { if (log.isTraceEnabled()) { log.trace("Logging non nav event"); } value = CustomComponentUtils.getDateValue(selectInputDate); if (value != null) { actuallyHaveTime = true; } //System.out.println("CustomComponentUtils.getDateValue: " + value); } DateTimeConverter converter = selectInputDate.resolveDateTimeConverter(facesContext); TimeZone tz = selectInputDate.resolveTimeZone(facesContext); Locale currentLocale = selectInputDate.resolveLocale(facesContext); DateFormatSymbols symbols = new DateFormatSymbols(currentLocale); //System.out.println("SIDR.encodeEnd() timezone: " + tz); //System.out.println("SIDR.encodeEnd() locale: " + currentLocale); Calendar timeKeeper = Calendar.getInstance(tz, currentLocale); timeKeeper.setTime(value != null ? value : new Date()); // get the parentForm UIComponent parentForm = findForm(selectInputDate); // if there is no parent form - ERROR if (parentForm == null) { log.error("SelectInputDate::must be in a FORM"); return; } String clientId; if (!domContext.isInitialized()) { Element root = domContext.createRootElement(HTML.DIV_ELEM); boolean popupState = selectInputDate.isShowPopup(); clientId = uiComponent.getClientId(facesContext); if (uiComponent.getId() != null) root.setAttribute("id", clientId + ROOT_DIV); Element table = domContext.createElement(HTML.TABLE_ELEM); if (selectInputDate.isRenderAsPopup()) { if (log.isTraceEnabled()) { log.trace("Render as popup"); } // ICE-2492 root.setAttribute(HTML.CLASS_ATTR, Util.getQualifiedStyleClass(uiComponent, CSS_DEFAULT.DEFAULT_CALENDARPOPUP_CLASS, false)); Element dateText = domContext.createElement(HTML.INPUT_ELEM); //System.out.println("value: " + selectInputDate.getValue()); dateText.setAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_TEXT); // ICE-2302 dateText.setAttribute(HTML.VALUE_ATTR, selectInputDate.getTextToRender()); dateText.setAttribute(HTML.ID_ATTR, clientId + SelectInputDate.CALENDAR_INPUTTEXT); dateText.setAttribute(HTML.NAME_ATTR, clientId + SelectInputDate.CALENDAR_INPUTTEXT); dateText.setAttribute(HTML.CLASS_ATTR, selectInputDate.getCalendarInputClass()); dateText.setAttribute(HTML.ONFOCUS_ATTR, "setFocus('');"); dateText.setAttribute("onkeypress", this.ICESUBMIT); boolean withinSingleSubmit = org.icefaces.impl.util.Util.withinSingleSubmit(selectInputDate); if (withinSingleSubmit) { JavascriptContext.addJavascriptCall(facesContext, "ice.cancelSingleSubmit('" + clientId + ROOT_DIV + "');"); } String singleSubmitCall = "ice.fullSubmit('@this', '@all', event, this, function(p) { p('ice.submit.type', 'ice.se'); p('ice.submit.serialization', 'form');});"; String onblur = combinedPassThru("setFocus('');", selectInputDate.getPartialSubmit() ? ICESUBMITPARTIAL : withinSingleSubmit ? singleSubmitCall : null); dateText.setAttribute(HTML.ONBLUR_ATTR, onblur); if (selectInputDate.getTabindex() != null) { dateText.setAttribute(HTML.TABINDEX_ATTR, selectInputDate.getTabindex()); } if (selectInputDate.getAutocomplete() != null && "off".equalsIgnoreCase(selectInputDate.getAutocomplete())) { dateText.setAttribute(HTML.AUTOCOMPLETE_ATTR, "off"); } String tooltip = null; tooltip = selectInputDate.getInputTitle(); if (tooltip == null || tooltip.length() == 0) { // extract the popupdate format and use it as a tooltip tooltip = getMessageWithParamFromResource(facesContext, INPUT_TEXT_TITLE, selectInputDate.getSpecifiedPopupDateFormat()); } if (tooltip != null && tooltip.length() > 0) { dateText.setAttribute(HTML.TITLE_ATTR, tooltip); } if (selectInputDate.isDisabled()) { dateText.setAttribute(HTML.DISABLED_ATTR, HTML.DISABLED_ATTR); } if (selectInputDate.isReadonly()) { dateText.setAttribute(HTML.READONLY_ATTR, HTML.READONLY_ATTR); } int maxlength = selectInputDate.getMaxlength(); if (maxlength > 0) { dateText.setAttribute(HTML.MAXLENGTH_ATTR, String.valueOf(maxlength)); } root.appendChild(dateText); Element calendarButton = domContext.createElement(HTML.INPUT_ELEM); calendarButton.setAttribute(HTML.ID_ATTR, clientId + CALENDAR_BUTTON); calendarButton.setAttribute(HTML.NAME_ATTR, clientId + CALENDAR_BUTTON); calendarButton.setAttribute(HTML.TYPE_ATTR, "image"); calendarButton.setAttribute(HTML.ONFOCUS_ATTR, "setFocus('');"); calendarButton.setAttribute(HTML.ONMOUSEDOWN_ATTR, "if (Event.isLeftClick(event)) this.selfClick = true;"); calendarButton.setAttribute(HTML.ONKEYDOWN_ATTR, "if (event.keyCode == 13 || event.keyCode == 32) this.selfClick = true;"); // render onclick to set value of hidden field to true String formClientId = parentForm.getClientId(facesContext); String hiddenValue1 = "document.forms['" + formClientId + "']['" + this.getLinkId(facesContext, uiComponent) + "'].value='"; String hiddenValue2 = "document.forms['" + formClientId + "']['" + getHiddenFieldName(facesContext, uiComponent) + "'].value='"; String onClick = "if (!this.selfClick) return false; this.selfClick = false; " + hiddenValue1 + clientId + CALENDAR_BUTTON + "';" + hiddenValue2 + "toggle';" + "iceSubmitPartial( document.forms['" + formClientId + "'], this,event);" + hiddenValue1 + "';" + hiddenValue2 + "';" + "Ice.Calendar.addCloseListener('" + clientId + "','" + formClientId + "','" + this.getLinkId(facesContext, uiComponent) + "','" + getHiddenFieldName(facesContext, uiComponent) + "');" + "return false;"; calendarButton.setAttribute(HTML.ONCLICK_ATTR, onClick); if (selectInputDate.getTabindex() != null) { try { int tabIndex = Integer.valueOf(selectInputDate.getTabindex()).intValue(); tabIndex += 1; calendarButton.setAttribute(HTML.TABINDEX_ATTR, String.valueOf(tabIndex)); } catch (NumberFormatException e) { if (log.isInfoEnabled()) { log.info("NumberFormatException on tabindex"); } } } if (selectInputDate.isDisabled()) { calendarButton.setAttribute(HTML.DISABLED_ATTR, HTML.DISABLED_ATTR); } if (selectInputDate.isReadonly()) { calendarButton.setAttribute(HTML.READONLY_ATTR, HTML.READONLY_ATTR); } root.appendChild(calendarButton); // render a hidden field to manage the popup state; visible || hidden FormRenderer.addHiddenField(facesContext, getHiddenFieldName(facesContext, uiComponent)); String resolvedSrc; if (popupState) { JavascriptContext.addJavascriptCall(facesContext, "Ice.util.adjustMyPosition('" + clientId + CALENDAR_TABLE + "', '" + clientId + ROOT_DIV + "');"); if (selectInputDate.isImageDirSet()) { resolvedSrc = CoreUtils.resolveResourceURL(facesContext, selectInputDate.getImageDir() + selectInputDate.getClosePopupImage()); } else { // ICE-2127: allow override of button images via CSS calendarButton.setAttribute(HTML.CLASS_ATTR, selectInputDate.getClosePopupClass()); // without this Firefox would display a default text on top of the image resolvedSrc = CoreUtils.resolveResourceURL(facesContext, selectInputDate.getImageDir() + "spacer.gif"); } calendarButton.setAttribute(HTML.SRC_ATTR, resolvedSrc); addAttributeToElementFromResource(facesContext, CLOSE_POPUP_ALT, calendarButton, HTML.ALT_ATTR); addAttributeToElementFromResource(facesContext, CLOSE_POPUP_TITLE, calendarButton, HTML.TITLE_ATTR); } else { if (selectInputDate.isImageDirSet()) { resolvedSrc = CoreUtils.resolveResourceURL(facesContext, selectInputDate.getImageDir() + selectInputDate.getOpenPopupImage()); } else { // ICE-2127: allow override of button images via CSS calendarButton.setAttribute(HTML.CLASS_ATTR, selectInputDate.getOpenPopupClass()); // without this Firefox would display a default text on top of the image resolvedSrc = CoreUtils.resolveResourceURL(facesContext, selectInputDate.getImageDir() + "spacer.gif"); } calendarButton.setAttribute(HTML.SRC_ATTR, resolvedSrc); addAttributeToElementFromResource(facesContext, OPEN_POPUP_ALT, calendarButton, HTML.ALT_ATTR); addAttributeToElementFromResource(facesContext, OPEN_POPUP_TITLE, calendarButton, HTML.TITLE_ATTR); FormRenderer.addHiddenField(facesContext, formClientId + UINamingContainer.getSeparatorChar(FacesContext.getCurrentInstance()) + "j_idcl"); FormRenderer.addHiddenField(facesContext, clientId + CALENDAR_CLICK); PassThruAttributeRenderer.renderHtmlAttributes(facesContext, uiComponent, passThruAttributesWithoutTabindex); domContext.stepOver(); return; } Text br = domContext.createTextNodeUnescaped("<br/>"); root.appendChild(br); Element calendarDiv = domContext.createElement(HTML.DIV_ELEM); calendarDiv.setAttribute(HTML.ID_ATTR, clientId + CALENDAR_POPUP); calendarDiv.setAttribute(HTML.NAME_ATTR, clientId + CALENDAR_POPUP); calendarDiv.setAttribute(HTML.STYLE_ELEM, "position:absolute;z-index:10;"); addAttributeToElementFromResource(facesContext, POPUP_CALENDAR_TITLE, calendarDiv, HTML.TITLE_ATTR); table.setAttribute(HTML.ID_ATTR, clientId + CALENDAR_TABLE); table.setAttribute(HTML.NAME_ATTR, clientId + CALENDAR_TABLE); table.setAttribute(HTML.CLASS_ATTR, selectInputDate.getStyleClass()); table.setAttribute(HTML.STYLE_ATTR, "position:absolute;"); table.setAttribute(HTML.CELLPADDING_ATTR, "0"); table.setAttribute(HTML.CELLSPACING_ATTR, "0"); // set mouse events on table bug 372 String mouseOver = selectInputDate.getOnmouseover(); table.setAttribute(HTML.ONMOUSEOVER_ATTR, mouseOver); String mouseOut = selectInputDate.getOnmouseout(); table.setAttribute(HTML.ONMOUSEOUT_ATTR, mouseOut); String mouseMove = selectInputDate.getOnmousemove(); table.setAttribute(HTML.ONMOUSEMOVE_ATTR, mouseMove); addAttributeToElementFromResource(facesContext, POPUP_CALENDAR_SUMMARY, table, HTML.SUMMARY_ATTR); Element positionDiv = domContext.createElement(HTML.DIV_ELEM); positionDiv.appendChild(table); calendarDiv.appendChild(positionDiv); Text iframe = domContext.createTextNodeUnescaped("<!--[if lte IE" + " 6.5]><iframe src='" + CoreUtils.resolveResourceURL(FacesContext.getCurrentInstance(), "/xmlhttp/blank") + "' class=\"iceSelInpDateIFrameFix\"></iframe><![endif]-->"); calendarDiv.appendChild(iframe); root.appendChild(calendarDiv); } else { if (log.isTraceEnabled()) { log.trace("Select input Date Normal"); } table.setAttribute(HTML.ID_ATTR, clientId + CALENDAR_TABLE); table.setAttribute(HTML.NAME_ATTR, clientId + CALENDAR_TABLE); table.setAttribute(HTML.CLASS_ATTR, selectInputDate.getStyleClass()); addAttributeToElementFromResource(facesContext, CALENDAR_TITLE, table, HTML.TITLE_ATTR); table.setAttribute(HTML.CELLPADDING_ATTR, "0"); table.setAttribute(HTML.CELLSPACING_ATTR, "0"); // set mouse events on table bug 372 String mouseOver = selectInputDate.getOnmouseover(); table.setAttribute(HTML.ONMOUSEOVER_ATTR, mouseOver); String mouseOut = selectInputDate.getOnmouseout(); table.setAttribute(HTML.ONMOUSEOUT_ATTR, mouseOut); String mouseMove = selectInputDate.getOnmousemove(); table.setAttribute(HTML.ONMOUSEMOVE_ATTR, mouseMove); addAttributeToElementFromResource(facesContext, CALENDAR_SUMMARY, table, HTML.SUMMARY_ATTR); root.appendChild(table); Element dateText = domContext.createElement(HTML.INPUT_ELEM); dateText.setAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN); dateText.setAttribute(HTML.VALUE_ATTR, selectInputDate.getTextToRender()); dateText.setAttribute(HTML.ID_ATTR, clientId + SelectInputDate.CALENDAR_INPUTTEXT); dateText.setAttribute(HTML.NAME_ATTR, clientId + SelectInputDate.CALENDAR_INPUTTEXT); root.appendChild(dateText); } } clientId = uiComponent.getClientId(facesContext); String[] weekdays = mapWeekdays(symbols); String[] weekdaysLong = mapWeekdaysLong(symbols); String[] months = mapMonths(symbols); // use the currentDay to set focus - do not set int lastDayInMonth = timeKeeper.getActualMaximum(Calendar.DAY_OF_MONTH); int currentDay = timeKeeper.get(Calendar.DAY_OF_MONTH); // starts at 1 if (currentDay > lastDayInMonth) { currentDay = lastDayInMonth; } timeKeeper.set(Calendar.DAY_OF_MONTH, 1); int weekDayOfFirstDayOfMonth = mapCalendarDayToCommonDay(timeKeeper.get(Calendar.DAY_OF_WEEK)); int weekStartsAtDayIndex = mapCalendarDayToCommonDay(timeKeeper.getFirstDayOfWeek()); // do not require a writer - clean out all methods that reference a writer ResponseWriter writer = facesContext.getResponseWriter(); Element root = (Element) domContext.getRootNode(); Element table = null; if (selectInputDate.isRenderAsPopup()) { if (log.isTraceEnabled()) { log.trace("SelectInputDate as Popup"); } // assumption input text is first child Element dateText = (Element) root.getFirstChild(); //System.out.println("dateText currentValue: " + currentValue); dateText.setAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_TEXT); // ICE-2302 dateText.setAttribute(HTML.VALUE_ATTR, selectInputDate.getTextToRender()); int maxlength = selectInputDate.getMaxlength(); if (maxlength > 0) { dateText.setAttribute(HTML.MAXLENGTH_ATTR, String.valueOf(maxlength)); } // get tables , our table is the first and only one NodeList tables = root.getElementsByTagName(HTML.TABLE_ELEM); // assumption we want the first table in tables. there should only be one table = (Element) tables.item(0); PassThruAttributeRenderer.renderHtmlAttributes(facesContext, uiComponent, passThruAttributesWithoutTabindex); Element tr1 = domContext.createElement(HTML.TR_ELEM); table.appendChild(tr1); writeMonthYearHeader(domContext, facesContext, writer, selectInputDate, timeKeeper, currentDay, tr1, selectInputDate.getMonthYearRowClass(), currentLocale, months, weekdays, weekdaysLong, converter); Element tr2 = domContext.createElement(HTML.TR_ELEM); table.appendChild(tr2); writeWeekDayNameHeader(domContext, weekStartsAtDayIndex, weekdays, facesContext, writer, selectInputDate, tr2, selectInputDate.getWeekRowClass(), timeKeeper, months, weekdaysLong, converter); writeDays(domContext, facesContext, writer, selectInputDate, timeKeeper, currentDay, weekStartsAtDayIndex, weekDayOfFirstDayOfMonth, lastDayInMonth, table, months, weekdays, weekdaysLong, converter, (actuallyHaveTime ? value : null)); } else { if (log.isTraceEnabled()) { log.trace("renderNormal::endcodeEnd"); } // assume table is the first child table = (Element) root.getFirstChild(); PassThruAttributeRenderer.renderHtmlAttributes(facesContext, uiComponent, passThruAttributes); Element tr1 = domContext.createElement(HTML.TR_ELEM); table.appendChild(tr1); writeMonthYearHeader(domContext, facesContext, writer, selectInputDate, timeKeeper, currentDay, tr1, selectInputDate.getMonthYearRowClass(), currentLocale, months, weekdays, weekdaysLong, converter); Element tr2 = domContext.createElement(HTML.TR_ELEM); writeWeekDayNameHeader(domContext, weekStartsAtDayIndex, weekdays, facesContext, writer, selectInputDate, tr2, selectInputDate.getWeekRowClass(), timeKeeper, months, weekdaysLong, converter); table.appendChild(tr2); writeDays(domContext, facesContext, writer, selectInputDate, timeKeeper, currentDay, weekStartsAtDayIndex, weekDayOfFirstDayOfMonth, lastDayInMonth, table, months, weekdays, weekdaysLong, converter, (actuallyHaveTime ? value : null)); } //System.out.println("SIDR.encodeEnd() isTime? " + SelectInputDate.isTime(converter)); if (SelectInputDate.isTime(converter)) { Element tfoot = domContext.createElement(HTML.TFOOT_ELEM); Element tr = domContext.createElement(HTML.TR_ELEM); Element td = domContext.createElement(HTML.TD_ELEM); td.setAttribute(HTML.COLSPAN_ATTR, selectInputDate.isRenderWeekNumbers() ? "8" : "7"); td.setAttribute(HTML.CLASS_ATTR, selectInputDate.getTimeClass()); Element tbl = domContext.createElement(HTML.TABLE_ELEM); Element tr2 = domContext.createElement(HTML.TR_ELEM); Element tdHours = domContext.createElement(HTML.TD_ELEM); Element hours = domContext.createElement(HTML.SELECT_ELEM); hours.setAttribute(HTML.ID_ATTR, clientId + SELECT_HOUR); hours.setAttribute(HTML.NAME_ATTR, clientId + SELECT_HOUR); hours.setAttribute(HTML.CLASS_ATTR, selectInputDate.getTimeDropDownClass()); hours.setAttribute(HTML.ONCHANGE_ATTR, DomBasicRenderer.ICESUBMITPARTIAL); // Convert from an hour to an index into the list of hours int hrs[] = selectInputDate.getHours(facesContext); //System.out.println("SIDR.encodeEnd() hrs: " + hrs[0] + ", " + hrs[hrs.length-1]); int hourIndex; int min; int sec; int amPm; //System.out.println("SIDR.encodeEnd() actuallyHaveTime: " + actuallyHaveTime); if (!actuallyHaveTime && selectInputDate.getHoursSubmittedValue() != null && selectInputDate.getMinutesSubmittedValue() != null) { //System.out.println("SIDR.encodeEnd() Using submitted hours and minutes"); hourIndex = selectInputDate.getHoursSubmittedValue().intValue(); //System.out.println("SIDR.encodeEnd() hour: " + hourIndex); min = selectInputDate.getMinutesSubmittedValue().intValue(); //System.out.println("SIDR.encodeEnd() min: " + min); String amPmStr = selectInputDate.getAmPmSubmittedValue(); //System.out.println("SIDR.encodeEnd() amPmStr: " + amPmStr); if (amPmStr != null) { amPm = amPmStr.equalsIgnoreCase("PM") ? 1 : 0; } else { amPm = (hourIndex >= 12) ? 1 : 0; } //System.out.println("SIDR.encodeEnd() amPm: " + amPm); if (hrs[0] == 1) { hourIndex--; if (hourIndex < 0) { hourIndex = hrs.length - 1; } } //System.out.println("SIDR.encodeEnd() hourIndex: " + hourIndex); } else { if (hrs.length > 12) { hourIndex = timeKeeper.get(Calendar.HOUR_OF_DAY); //System.out.println("SIDR.encodeEnd() hour 24: " + hourIndex); } else { hourIndex = timeKeeper.get(Calendar.HOUR); //System.out.println("SIDR.encodeEnd() hour 12: " + hourIndex); } if (hrs[0] == 1) { hourIndex--; if (hourIndex < 0) { hourIndex = hrs.length - 1; } } //System.out.println("SIDR.encodeEnd() hourIndex: " + hourIndex); min = timeKeeper.get(Calendar.MINUTE); amPm = timeKeeper.get(Calendar.AM_PM); //System.out.println("SIDR.encodeEnd() amPm: " + amPm); } if (!actuallyHaveTime && selectInputDate.getSecondsSubmittedValue() != null) { sec = selectInputDate.getSecondsSubmittedValue().intValue(); } else { sec = timeKeeper.get(Calendar.SECOND); } for (int i = 0; i < hrs.length; i++) { Element hoursOption = domContext.createElement(HTML.OPTION_ELEM); hoursOption.setAttribute(HTML.VALUE_ATTR, String.valueOf(hrs[i])); Text hourText = domContext.createTextNode(String.valueOf(hrs[i])); hoursOption.appendChild(hourText); if (i == hourIndex) { hoursOption.setAttribute(HTML.SELECTED_ATTR, "true"); } hours.appendChild(hoursOption); } Element tdColon = domContext.createElement(HTML.TD_ELEM); Element tdMinutes = domContext.createElement(HTML.TD_ELEM); Element minutes = domContext.createElement(HTML.SELECT_ELEM); minutes.setAttribute(HTML.ID_ATTR, clientId + SELECT_MIN); minutes.setAttribute(HTML.NAME_ATTR, clientId + SELECT_MIN); minutes.setAttribute(HTML.CLASS_ATTR, selectInputDate.getTimeDropDownClass()); minutes.setAttribute(HTML.ONCHANGE_ATTR, DomBasicRenderer.ICESUBMITPARTIAL); for (int i = 0; i < 60; i++) { Element minutesOption = domContext.createElement(HTML.OPTION_ELEM); minutesOption.setAttribute(HTML.VALUE_ATTR, String.valueOf(i)); String digits = String.valueOf(i); if (i < 10) { digits = "0" + digits; } Text minuteText = domContext.createTextNode(digits); minutesOption.appendChild(minuteText); if (i == min) { minutesOption.setAttribute(HTML.SELECTED_ATTR, "true"); } minutes.appendChild(minutesOption); } Text colon = domContext.createTextNode(":"); tfoot.appendChild(tr); tr.appendChild(td); td.appendChild(tbl); tbl.appendChild(tr2); tdHours.appendChild(hours); tr2.appendChild(tdHours); tdColon.appendChild(colon); tdMinutes.appendChild(minutes); tr2.appendChild(tdColon); tr2.appendChild(tdMinutes); if (selectInputDate.isSecond(facesContext)) { Element tdSeconds = domContext.createElement(HTML.TD_ELEM); Element tdSecColon = domContext.createElement(HTML.TD_ELEM); Element seconds = domContext.createElement(HTML.SELECT_ELEM); seconds.setAttribute(HTML.ID_ATTR, clientId + SELECT_SEC); seconds.setAttribute(HTML.NAME_ATTR, clientId + SELECT_SEC); seconds.setAttribute(HTML.CLASS_ATTR, selectInputDate.getTimeDropDownClass()); seconds.setAttribute(HTML.ONCHANGE_ATTR, DomBasicRenderer.ICESUBMITPARTIAL); for (int i = 0; i < 60; i++) { Element secondsOption = domContext.createElement(HTML.OPTION_ELEM); secondsOption.setAttribute(HTML.VALUE_ATTR, String.valueOf(i)); String digits = String.valueOf(i); if (i < 10) { digits = "0" + digits; } Text secondText = domContext.createTextNode(digits); secondsOption.appendChild(secondText); if (i == sec) { secondsOption.setAttribute(HTML.SELECTED_ATTR, "true"); } seconds.appendChild(secondsOption); } Text secondColon = domContext.createTextNode(":"); tdSecColon.appendChild(secondColon); tdSeconds.appendChild(seconds); tr2.appendChild(tdSecColon); tr2.appendChild(tdSeconds); } if (selectInputDate.isAmPm(facesContext)) { Element tdAamPm = domContext.createElement(HTML.TD_ELEM); Element amPmElement = domContext.createElement(HTML.SELECT_ELEM); amPmElement.setAttribute(HTML.ID_ATTR, clientId + SELECT_AM_PM); amPmElement.setAttribute(HTML.NAME_ATTR, clientId + SELECT_AM_PM); amPmElement.setAttribute(HTML.CLASS_ATTR, selectInputDate.getTimeDropDownClass()); amPmElement.setAttribute(HTML.ONCHANGE_ATTR, DomBasicRenderer.ICESUBMITPARTIAL); String[] symbolsAmPm = symbols.getAmPmStrings(); Element amPmElementOption = domContext.createElement(HTML.OPTION_ELEM); amPmElementOption.setAttribute(HTML.VALUE_ATTR, "AM"); Text amPmElementText = domContext.createTextNode(symbolsAmPm[0]); amPmElementOption.appendChild(amPmElementText); Element amPmElementOption2 = domContext.createElement(HTML.OPTION_ELEM); amPmElementOption2.setAttribute(HTML.VALUE_ATTR, "PM"); Text amPmElementText2 = domContext.createTextNode(symbolsAmPm[1]); amPmElementOption2.appendChild(amPmElementText2); if (amPm == 0) { amPmElementOption.setAttribute(HTML.SELECTED_ATTR, "true"); } else { amPmElementOption2.setAttribute(HTML.SELECTED_ATTR, "true"); } amPmElement.appendChild(amPmElementOption); amPmElement.appendChild(amPmElementOption2); tdAamPm.appendChild(amPmElement); tr2.appendChild(tdAamPm); } table.appendChild(tfoot); } // purge child components as they have been encoded no need to keep them around selectInputDate.getChildren().clear(); // steps to the position where the next sibling should be rendered domContext.stepOver(); }