Author: nbelaevski
Date: 2007-12-06 15:57:49 -0500 (Thu, 06 Dec 2007)
New Revision: 4575
Modified:
branches/3.1.x/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
branches/3.1.x/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
Log:
http://jira.jboss.com/jira/browse/RF-1551
Modified:
branches/3.1.x/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
---
branches/3.1.x/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-12-06
20:28:56 UTC (rev 4574)
+++
branches/3.1.x/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-12-06
20:57:49 UTC (rev 4575)
@@ -25,6 +25,8 @@
import java.io.IOException;
import java.text.DateFormatSymbols;
+import java.text.Format;
+import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
@@ -86,10 +88,17 @@
AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
if (ajaxContext.isAjaxRequest()) {
+ String clientId = component.getClientId(context);
+
ajaxContext.getAjaxRenderedAreas().add(
- component.getClientId(context) + "Popup");
+ clientId + "Popup");
+
+ ajaxContext.getAjaxRenderedAreas().add(
+ clientId + "IFrame");
+
+ ajaxContext.getAjaxRenderedAreas().add(
+ clientId + "Initializers");
}
-
}
public Object getConvertedValue(FacesContext context,
@@ -445,9 +454,15 @@
return String.valueOf(cal.getMinimalDaysInFirstWeek());
}
- public String getCurrentDate(FacesContext context, UICalendar calendar)
+ public String getCurrentDateAsString(FacesContext context, UICalendar calendar, Date
date)
throws IOException {
- Date date = calendar.getCurrentDateOrDefault();
+
+ Format formatter = new SimpleDateFormat("MM/yyyy");
+ return formatter.format(date);
+ }
+
+ public String getCurrentDate(FacesContext context, UICalendar calendar, Date date)
+ throws IOException {
return ScriptUtils.toScript(formatDate(date));
}
Modified:
branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
===================================================================
---
branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-12-06
20:28:56 UTC (rev 4574)
+++
branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-12-06
20:57:49 UTC (rev 4575)
@@ -561,10 +561,7 @@
this.isVisible = false;
}
- var htmlTextHeader = (!this.params.popup ? '<input
id="'+this.INPUT_DATE_ID+'"
name="'+this.INPUT_DATE_ID+'" type="hidden"
style="display:none"
value="'+this.getSelectedDateString(this.params.datePattern)+'"/>\n'
: '') +
- '<input id="'+this.id+'InputCurrentDate"
name="'+this.id+'InputCurrentDate" type="hidden"
style="display:none"
value="'+Richfaces.Calendar.formatDate(this.getCurrentDate(),"MM/yyyy")+'"/>\n'
+
- (this.params.popup && Richfaces.browser.isIE6 ? '<iframe
src="javascript:\'\'" frameborder="0" scrolling="no"
id="' + this.IFRAME_ID + '" style="display:none; position:
absolute; width: 1px; height: 1px;
background-color:white;">'+'</iframe>\n' : '' )+
- '<table id="'+this.id+'" border="0"
cellpadding="0" cellspacing="0" class="rich-calendar-exterior
rich-calendar-popup'+(this.params.className ? ' '+this.params.className :
'')+'"
style="'+popupStyles+this.params.style+'"><tbody>\n';
+ var htmlTextHeader = '<table id="'+this.id+'"
border="0" cellpadding="0" cellspacing="0"
class="rich-calendar-exterior rich-calendar-popup'+(this.params.className ? '
'+this.params.className : '')+'"
style="'+popupStyles+this.params.style+'"><tbody>\n';
var colspan = (this.params.showWeeksBar ? "8" : "7");
var htmlHeaderOptional = (this.params.optionalHeaderMarkup) ? '<tr><td
class="rich-calendar-header-optional" colspan="'+colspan+'"
id="'+this.id+'HeaderOptional"></td></tr>' :
'';
var htmlFooterOptional = (this.params.optionalFooterMarkup) ? '<tr><td
class="rich-calendar-footer-optional" colspan="'+colspan+'"
id="'+this.id+'FooterOptional"></td></tr>' :
'';
@@ -630,7 +627,30 @@
//obj.innerHTML =
htmlTextIFrame+htmlTextHeader+htmlHeaderOptional+htmlControlsHeader+htmlTextWeekDayBar+htmlTextWeek+htmlControlsFooter+htmlFooterOptional+htmlTextFooter;
var span=$(this.POPUP_ID);
- new
Insertion.After(span,htmlTextIFrame+htmlTextHeader+htmlHeaderOptional+htmlControlsHeader+htmlTextWeekDayBar+htmlTextWeek+htmlControlsFooter+htmlFooterOptional+htmlTextFooter);
+
+ if (this.params.popup/* && Richfaces.browser.isIE6*/) {
+ for (var container = span.nextSibling; container; ) {
+ if (container.id == this.IFRAME_ID) {
+ Element.replace(container,
+ '<iframe src="javascript:\'\'" frameborder="0"
scrolling="no" id="' + this.IFRAME_ID + '"
style="display:none; position: absolute; width: 1px; height: 1px;
background-color:white;">'+'</iframe>\n');
+
+ break;
+ }
+
+ container = container.nextSibling
+ }
+ }
+
+ for (var container = span.nextSibling; container; ) {
+ if (container.id == id) {
+ Element.replace(container,
+ htmlTextIFrame+htmlTextHeader+htmlHeaderOptional+htmlControlsHeader+htmlTextWeekDayBar+htmlTextWeek+htmlControlsFooter+htmlFooterOptional+htmlTextFooter);
+ break;
+ }
+
+ container = container.nextSibling;
+ }
+
// set content
var obj=$(id);
obj.component = this;
Modified: branches/3.1.x/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
===================================================================
---
branches/3.1.x/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-12-06
20:28:56 UTC (rev 4574)
+++
branches/3.1.x/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-12-06
20:57:49 UTC (rev 4575)
@@ -16,11 +16,21 @@
<f:call name="addPopupToAjaxRendered" />
<span id="#{clientId}Popup"
- x:passThruWithExclusions="value,name,type,id,styleClass,class,style">
<jsp:scriptlet>
+ x:passThruWithExclusions="value,name,type,id,styleClass,class,style">
+ <jsp:scriptlet>
<![CDATA[
boolean popup = getUtils().isBooleanAttribute(component, "popup");
if (!popup) {
getUtils().writeAttribute(writer, "style", "display: none");
+
+ ]]>
+ </jsp:scriptlet>
+ <input id="#{clientId}InputDate"
+ style="display:none"
+ name="#{clientId}InputDate"
+ value="#{this:getInputValue(context,component)}" type="hidden"
/>
+ <jsp:scriptlet>
+ <![CDATA[
} else {
boolean disabled = getUtils().isBooleanAttribute(component,
"disabled");
boolean showInput = getUtils().isBooleanAttribute(component, "showInput");
@@ -34,38 +44,42 @@
variables.setVariable("disabled",new Boolean(disabled));
]]>
- </jsp:scriptlet> <f:resource
+ </jsp:scriptlet>
+ <f:resource
name="org.richfaces.renderkit.html.iconimages.CalendarIcon"
var="icon" />
<f:resource
name="org.richfaces.renderkit.html.iconimages.DisabledCalendarIcon"
- var="disabledIcon" /> <input id="#{clientId}InputDate"
- name="#{clientId}InputDate"
- value="#{this:getInputValue(context,component)}" type="#{type}"
- disabled="#{disabled}"
- accesskey="#{component.attributes['accesskey']}"
- maxlength="#{component.attributes['maxlength']}"
- onchange="#{component.attributes['oninputchange']}"
- onselect="#{component.attributes['oninputselect']}"
- onfocus="#{component.attributes['oninputfocus']}"
- onblur="#{component.attributes['oninputblur']}"
- onclick="#{component.attributes['oninputclick']}"
- onkeypress="#{component.attributes['oninputkeypress']}"
- onkeydown="#{component.attributes['oninputkeydown']}"
- onkeyup="#{component.attributes['oninputkeyup']}"
- size="#{component.attributes['inputSize']}"
- style="vertical-align: middle;
#{component.attributes['inputStyle']}"
- class="rich-calendar-input #{component.attributes['inputClass']}"
- tabindex="#{component.attributes['tabindex']}">
+ var="disabledIcon" />
+
+ <input id="#{clientId}InputDate"
+ name="#{clientId}InputDate"
+ value="#{this:getInputValue(context,component)}" type="#{type}"
+ disabled="#{disabled}"
+ accesskey="#{component.attributes['accesskey']}"
+ maxlength="#{component.attributes['maxlength']}"
+ onchange="#{component.attributes['oninputchange']}"
+ onselect="#{component.attributes['oninputselect']}"
+ onfocus="#{component.attributes['oninputfocus']}"
+ onblur="#{component.attributes['oninputblur']}"
+ onclick="#{component.attributes['oninputclick']}"
+ onkeypress="#{component.attributes['oninputkeypress']}"
+ onkeydown="#{component.attributes['oninputkeydown']}"
+ onkeyup="#{component.attributes['oninputkeyup']}"
+ size="#{component.attributes['inputSize']}"
+ style="vertical-align: middle;
#{component.attributes['inputStyle']}"
+ class="rich-calendar-input #{component.attributes['inputClass']}"
+ tabindex="#{component.attributes['tabindex']}">
+ <jsp:scriptlet>
+ <![CDATA[
+ boolean manualInput = getUtils().isBooleanAttribute(component,
"enableManualInput");
+ if(!manualInput){
+ getUtils().writeAttribute(writer, "readonly", "readonly");
+ }
+ ]]>
+ </jsp:scriptlet>
+
+ </input>
<jsp:scriptlet>
- <![CDATA[
- boolean manualInput = getUtils().isBooleanAttribute(component,
"enableManualInput");
- if(!manualInput){
- getUtils().writeAttribute(writer, "readonly", "readonly");
- }
- ]]>
- </jsp:scriptlet>
-
- </input> <jsp:scriptlet>
<![CDATA[
String buttonIcon = org.richfaces.component.util.ViewUtil.getResourceURL((String)
component.getAttributes().get("buttonIcon"),context);
String buttonIconDisabled =
org.richfaces.component.util.ViewUtil.getResourceURL((String)
component.getAttributes().get("buttonIconDisabled"),context);
@@ -122,9 +136,19 @@
<![CDATA[
}
]]>
- </jsp:scriptlet> </span>
- <f:call name="dayCellClass" />
- <script type="text/javascript">
+ </jsp:scriptlet>
+ <c:object var="currentDate" type="java.util.Date"
value="#{component.currentDateOrDefault}" />
+
+ <input id="#{clientId}InputCurrentDate"
+ style="display:none"
+ name="#{clientId}InputCurrentDate"
+ value="#{this:getCurrentDateAsString(context,component,currentDate)}"
type="hidden" />
+
+ </span>
+ <div style="display: none;"
id="#{clientId}IFrame"></div>
+ <div style="display: none;" id="#{clientId}">
+ <f:call name="dayCellClass" />
+ <script type="text/javascript">
new Calendar('#{clientId}', {
<jsp:scriptlet>/*<![CDATA[*/
@@ -141,7 +165,7 @@
dayListTableId: '#{clientId}Day',
weekNumberBarId: '#{clientId}WeekNum',
weekDayBarId: '#{clientId}WeekDay',
- currentDate: #{this:getCurrentDate(context, component)},
+ currentDate: #{this:getCurrentDate(context, component, currentDate)},
selectedDate: #{this:getSelectedDate(context, component)},
datePattern: '#{component.datePattern}',
jointPoint: '#{component.jointPoint}',
@@ -204,4 +228,5 @@
/*]]>*/</jsp:scriptlet>
);
</script>
+ </div>
</f:root>