Index: icefaces/component/src/com/icesoft/faces/component/selectinputdate/SelectInputDate.java =================================================================== --- icefaces/component/src/com/icesoft/faces/component/selectinputdate/SelectInputDate.java (revision 72) +++ icefaces/component/src/com/icesoft/faces/component/selectinputdate/SelectInputDate.java (working copy) @@ -168,7 +168,8 @@ private static final Pattern timePattern = Pattern.compile("[aHkKhmsS]"); private Integer submittedHours = null; private Integer submittedMinutes = null; - private String submittedAmPm= null; + private Integer submittedSeconds = null; + private String submittedAmPm= null; /** * Creates an instance and sets renderer type to "com.icesoft.faces.Calendar". */ @@ -692,9 +693,10 @@ values[23] = selectedDayLink; values[24] = showPopup; values[25] = submittedHours; - values[26] = submittedMinutes; - values[27] = submittedAmPm; - values[28] = popupDate; + values[26] = submittedMinutes; + values[27] = submittedSeconds; + values[28] = submittedAmPm; + values[29] = popupDate; return ((Object) (values)); } @@ -729,19 +731,21 @@ selectedDayLink = (String) values[23]; showPopup = (List) values[24]; submittedHours = (Integer)values[25]; - submittedMinutes = (Integer)values[26]; - submittedAmPm = (String)values[27]; - popupDate = (Date) values[28]; + submittedMinutes = (Integer)values[26]; + submittedSeconds = (Integer)values[27]; + submittedAmPm = (String)values[28]; + popupDate = (Date) values[29]; } public Object saveSeriesState(FacesContext facesContext) { - Object values[] = new Object[6]; + Object values[] = new Object[7]; values[0] = navEvent ? Boolean.TRUE : Boolean.FALSE; values[1] = navDate; values[2] = submittedHours; values[3] = submittedMinutes; - values[4] = submittedAmPm; - values[5] = popupDate; + values[4] = submittedSeconds; + values[5] = submittedAmPm; + values[6] = popupDate; return values; } @@ -751,8 +755,9 @@ navDate = (Date) values[1]; submittedHours = (Integer)values[2]; submittedMinutes = (Integer)values[3]; - submittedAmPm = (String)values[4]; - popupDate = (Date) values[5]; + submittedSeconds = (Integer)values[4]; + submittedAmPm = (String)values[5]; + popupDate = (Date) values[6]; } private Map linkMap = new HashMap(); @@ -1124,6 +1129,11 @@ pattern.indexOf("h") >= 0 || pattern.indexOf("k") >= 0; } + + boolean isSecond(FacesContext context) { + String pattern = getDateTimeConverterPattern(resolveDateTimeConverter(context)); + return pattern.indexOf("s") >= 0; + } /** * This method is necesary since DateTimeConverter.getDateFormat(Locale) is private @@ -1199,6 +1209,21 @@ return submittedMinutes; } + void setSecondsSubmittedValue(Object submittedSeconds) { + if (submittedSeconds == null) + this.submittedSeconds = null; + else + try { + this.submittedSeconds = new Integer(submittedSeconds.toString()); + } catch (NumberFormatException e) { + this.submittedSeconds = null; + } + } + + Integer getSecondsSubmittedValue() { + return submittedSeconds; + } + void setAmPmSubmittedValue(Object submittedAmPm) { if (submittedAmPm == null) this.submittedAmPm = null; Index: icefaces/component/src/com/icesoft/faces/component/selectinputdate/SelectInputDateRenderer.java =================================================================== --- icefaces/component/src/com/icesoft/faces/component/selectinputdate/SelectInputDateRenderer.java (revision 72) +++ icefaces/component/src/com/icesoft/faces/component/selectinputdate/SelectInputDateRenderer.java (working copy) @@ -115,8 +115,9 @@ private static final String PREV_YEAR = "_py"; private static final String NEXT_YEAR = "_ny"; private static final String SELECT_HOUR = "_hr"; - private static final String SELECT_MIN = "_min"; - private static final String SELECT_AM_PM = "_amPm"; + private static final String SELECT_MIN = "_min"; + private static final String SELECT_SEC = "_sec"; + private static final String SELECT_AM_PM = "_amPm"; // constant for selectinputdate links private static final String CALENDAR = "_c_"; @@ -132,7 +133,8 @@ private static final int IS_NEXT_YEAR = 6; private static final int IS_HOUR = 7; private static final int IS_MIN = 8; - private static final int IS_AM_PM = 9; + private static final int IS_SEC = 9; + private static final int IS_AM_PM = 10; private static final String INPUT_TEXT_TITLE = "com.icesoft.faces.component.selectinputdate.INPUT_TEXT_TITLE"; @@ -606,6 +608,9 @@ Element td = domContext.createElement(HTML.TD_ELEM); td.setAttribute(HTML.COLSPAN_ATTR, "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); @@ -617,7 +622,8 @@ //System.out.println("SIDR.encodeEnd() hrs: " + hrs[0] + ", " + hrs[hrs.length-1]); int hourIndex; int min; - int amPm; + int sec; + int amPm; //System.out.println("SIDR.encodeEnd() actuallyHaveTime: " + actuallyHaveTime); if (!actuallyHaveTime && selectInputDate.getHoursSubmittedValue() != null && @@ -628,7 +634,9 @@ //System.out.println("SIDR.encodeEnd() hour: " + hourIndex); min = selectInputDate.getMinutesSubmittedValue().intValue(); //System.out.println("SIDR.encodeEnd() min: " + min); - String amPmStr = selectInputDate.getAmPmSubmittedValue(); + sec = selectInputDate.getSecondsSubmittedValue().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; @@ -662,7 +670,8 @@ //System.out.println("SIDR.encodeEnd() hourIndex: " + hourIndex); min = timeKeeper.get(Calendar.MINUTE); - amPm = timeKeeper.get(Calendar.AM_PM) ; + sec = timeKeeper.get(Calendar.SECOND); + amPm = timeKeeper.get(Calendar.AM_PM) ; //System.out.println("SIDR.encodeEnd() amPm: " + amPm); } for (int i = 0; i < hrs.length; i++ ) { @@ -675,6 +684,8 @@ } 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); @@ -694,15 +705,50 @@ } minutes.appendChild(minutesOption); } - - Text colon = domContext.createTextNode(":"); + + Text Colon = domContext.createTextNode(":"); tfoot.appendChild(tr); tr.appendChild(td); - td.appendChild(hours); - td.appendChild(colon); - td.appendChild(minutes); + 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); @@ -726,7 +772,8 @@ } amPmElement.appendChild(amPmElementOption); amPmElement.appendChild(amPmElementOption2); - td.appendChild(amPmElement); + tdAamPm.appendChild(amPmElement); + tr2.appendChild(tdAamPm); } table.appendChild(tfoot); } @@ -1471,6 +1518,9 @@ else if( (clientId+SELECT_MIN).equals(eventCapturedId) ) { return IS_MIN; } + else if( (clientId+SELECT_SEC).equals(eventCapturedId) ) { + return IS_SEC; + } else if( (clientId+SELECT_AM_PM).equals(eventCapturedId) ) { return IS_AM_PM; } @@ -1515,7 +1565,8 @@ String yearClientId = clientId + SELECT_YEAR; String hoursClientId = clientId + SELECT_HOUR; String minutesClientId = clientId + SELECT_MIN; - String amPmClientId = clientId + SELECT_AM_PM; + String secondsClientId = clientId + SELECT_SEC; + String amPmClientId = clientId + SELECT_AM_PM; if (requestParameterMap.containsKey(hoursClientId)) { //System.out.println("SIDR.decode() Hours: " + requestParameterMap.get(hoursClientId)); dateSelect.setHoursSubmittedValue(requestParameterMap.get(hoursClientId)); @@ -1526,6 +1577,11 @@ dateSelect.setMinutesSubmittedValue(requestParameterMap.get(minutesClientId)); } + if (requestParameterMap.containsKey(secondsClientId)) { +//System.out.println("SIDR.decode() Seconds: " + requestParameterMap.get(secondsClientId)); + dateSelect.setSecondsSubmittedValue(requestParameterMap.get(secondsClientId)); + } + if (requestParameterMap.containsKey(amPmClientId)) { //System.out.println("SIDR.decode() AmPm: " + requestParameterMap.get(amPmClientId)); dateSelect.setAmPmSubmittedValue(requestParameterMap.get(amPmClientId)); @@ -1561,6 +1617,7 @@ "IS_NEXT_YEAR", "IS_HOUR", "IS_MIN", + "IS_SEC", "IS_AM_PM" }; System.out.println("SIDR.decode() link: " + checkStrings[check]); @@ -1596,6 +1653,7 @@ decodePopup(facesContext, component); } else if (check == IS_HOUR || check == IS_MIN || + check == IS_SEC || check == IS_AM_PM) { decodeTime(facesContext, component); } @@ -1609,6 +1667,7 @@ if (enterKeyPressed) { dateSelect.setHoursSubmittedValue(null); dateSelect.setMinutesSubmittedValue(null); + dateSelect.setSecondsSubmittedValue(null); component.queueEvent(new ActionEvent(component)); } } @@ -1765,6 +1824,7 @@ String hoursClientId = clientId + SELECT_HOUR; String minutesClientId = clientId + SELECT_MIN; + String secondsClientId = clientId + SELECT_SEC; String amPmClientId = clientId + SELECT_AM_PM; int setMilitaryHour = -1; @@ -1803,19 +1863,26 @@ requestParameterMap.get(minutesClientId).toString()); //System.out.println("mergeTimeIntoDateString() setMinute: " + setMinute); } + if (requestParameterMap.containsKey(secondsClientId)) { + setSecond = Integer.parseInt( + requestParameterMap.get(secondsClientId).toString()); +//System.out.println("mergeTimeIntoDateString() setSeconds: " + setSeconds); + } } catch(NumberFormatException e) { // We use drop down menus for the hours and minutes, so this shouldn't be possible if (log.isDebugEnabled()) { log.debug("Invalid hour ("+ requestParameterMap.get(hoursClientId)+") or minute ("+ - requestParameterMap.get(minutesClientId)+")"); + requestParameterMap.get(minutesClientId)+") or second ("+ + requestParameterMap.get(secondsClientId)+")"); } setMilitaryHour = -1; setMinute = -1; + setSecond = -1; } - if (setMilitaryHour != -1 || setMinute != -1) { + if (setMilitaryHour != -1 || setMinute != -1 || setSecond != -1) { Date date; try { date = (Date) converter.getAsObject(facesContext, dateSelect, submittedDate); @@ -1835,6 +1902,9 @@ if (setMinute != -1) { timeKeeper.set(Calendar.MINUTE, setMinute); } + if (setSecond != -1) { + timeKeeper.set(Calendar.SECOND, setSecond); + } date = timeKeeper.getTime(); //System.out.println("mergeTimeIntoDateString() after calendar date: " + date); submittedDate = converter.getAsString(facesContext, dateSelect, date);