Author: alexsmirnov
Date: 2010-11-22 13:35:31 -0500 (Mon, 22 Nov 2010)
New Revision: 20133
Modified:
branches/RF-8742-1/
branches/RF-8742-1/examples/input-demo/src/main/webapp/examples/calendar.xhtml
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractCalendar.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
branches/RF-8742-1/ui/input/ui/src/main/templates/calendar.template.xml
Log:
Merged revisions 20116,20118-20119,20128-20129 via svnmerge from
https://svn.jboss.org/repos/richfaces/trunk
.......
r20116 | amarkhel | 2010-11-19 03:49:05 -0800 (Fri, 19 Nov 2010) | 1 line
RF-9683 Calendar component: data model support. Calling getCurrentDate() was replaces by
getCurrentDateOrDefault()
.......
r20118 | abelevich | 2010-11-19 04:40:47 -0800 (Fri, 19 Nov 2010) | 1 line
RF-9781
.......
r20119 | amarkhel | 2010-11-19 05:09:29 -0800 (Fri, 19 Nov 2010) | 1 line
RF-9630 Calendar component: disabled state support. Processing the disabled calendar
icon was added.
.......
r20128 | amarkhel | 2010-11-22 04:48:50 -0800 (Mon, 22 Nov 2010) | 3 lines
https://jira.jboss.org/browse/RF-9685 Calendar component: client-side events + demo
https://jira.jboss.org/browse/RF-7794 rich:calendar needs event handler
"onclean",
https://jira.jboss.org/browse/RF-9602 calendar: onchange not implemented so value
can't be stored via ajax for (common use-case)
.......
r20129 | amarkhel | 2010-11-22 04:49:02 -0800 (Mon, 22 Nov 2010) | 3 lines
https://jira.jboss.org/browse/RF-9685 Calendar component: client-side events + demo
https://jira.jboss.org/browse/RF-7794 rich:calendar needs event handler
"onclean",
https://jira.jboss.org/browse/RF-9602 calendar: onchange not implemented so value
can't be stored via ajax for (common use-case)
.......
Property changes on: branches/RF-8742-1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk:1-20107
+ /trunk:1-20132
Modified: branches/RF-8742-1/examples/input-demo/src/main/webapp/examples/calendar.xhtml
===================================================================
---
branches/RF-8742-1/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-22
13:30:34 UTC (rev 20132)
+++
branches/RF-8742-1/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-22
18:35:31 UTC (rev 20133)
@@ -4,6 +4,7 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j"
xmlns:calendar="http://richfaces.org/input">
<!--
JBoss, Home of Professional Open Source
@@ -34,7 +35,7 @@
</h:head>
<h:body>
<h:form id="form">
- <h:panelGrid id="panel" columns="2">
+ <h:panelGrid id="panel" columns="3">
<h:panelGroup layout="block">
<calendar:calendar value="#{calendarBean.selectedDate}"
id="calendar"
jointPoint="#{calendarBean.jointPoint}"
direction="#{calendarBean.direction}"
@@ -43,9 +44,24 @@
dataModel="#{calendarDataModel}"
mode="#{calendarBean.mode}"
showApplyButton="#{calendarBean.showApply}" cellWidth="24px"
- cellHeight="22px" style="width:200px"
minDaysInFirstWeek="3">
- <f:convertDateTime pattern="#{calendarBean.pattern}" />
+ cellHeight="22px" style="width:200px"
minDaysInFirstWeek="3"
+ oncollapse="return onEvent.call(this, event);"
+ onexpand="return onEvent.call(this, event);"
+ oncurrentdateselect="return onEvent.call(this, event);"
+ oncurrentdateselected="return onEvent.call(this, event);"
+ ondateselect="return onEvent.call(this, event);"
+ ondateselected="return onEvent.call(this, event);"
+ ontimeselect="return onEvent.call(this, event);"
+ ontimeselected="return onEvent.call(this, event);"
+ oncomplete="return onEvent.call(this, event);"
+ onclean="return onEvent.call(this, event);"
+ ondatemouseout="return onEvent.call(this, event);"
+ ondatemouseover="return onEvent.call(this, event);"
+
+ >
+ <f:ajax event="change" render="echo-text" />
</calendar:calendar>
+ <h:outputText id="echo-text"
value="#{calendarBean.selectedDate}" />
</h:panelGroup>
<h:panelGrid columns="2">
<h:outputText value="Popup Mode:" />
@@ -101,6 +117,17 @@
<f:selectItem itemLabel="bottom-right"
itemValue="bottom-right" />
</h:selectOneMenu>
</h:panelGrid>
+ <h:panelGroup layout="block">
+ <div>
+ <a4j:log mode="inline"></a4j:log>
+ </div>
+ <script type="text/javascript">
+ onEvent = function(event, element, data){
+ RichFaces.log.info("jQuery Event: "+(event instanceof
jQuery.Event)+"; event: "+event.type+"; data:"+(data ||
(event['rich']||{})['data'])+"; this.id:"+this.id+";
component:"+
(event['rich']||{})['component']||RichFaces.$(this.id));
+ };
+ //RichFaces.Event.bindById("form:calendar", "dateselect dateselected
currentdateselect currentdateselected timeselect timeselected changed clean collapse
expand complete datemouseout datemouseout", onEvent);
+ </script>
+ </h:panelGroup>
</h:panelGrid>
</h:form>
</h:body>
Modified:
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractCalendar.java
===================================================================
---
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractCalendar.java 2010-11-22
13:30:34 UTC (rev 20132)
+++
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractCalendar.java 2010-11-22
18:35:31 UTC (rev 20133)
@@ -272,7 +272,47 @@
@Attribute(events = @EventName("inputblur"))
public abstract String getOninputblur();
+
+ @Attribute(events = @EventName("change"))
+ public abstract String getOnchange();
+
+ @Attribute(events = @EventName("dateselect"))
+ public abstract String getOndateselect();
+
+ @Attribute(events = @EventName("dateselected"))
+ public abstract String getOndateselected();
+
+ @Attribute(events = @EventName("currentdateselect"))
+ public abstract String getOncurrentdateselect();
+
+ @Attribute(events = @EventName("currentdateselected"))
+ public abstract String getOncurrentdateselected();
+ @Attribute(events = @EventName("complete"))
+ public abstract String getOncomplete();
+
+ @Attribute(events = @EventName("collapse"))
+ public abstract String getOncollapse();
+
+ @Attribute(events = @EventName("datemouseout"))
+ public abstract String getOndatemouseout();
+
+ @Attribute(events = @EventName("datemouseover"))
+ public abstract String getOndatemouseover();
+
+ @Attribute(events = @EventName("expand"))
+ public abstract String getOnExpand();
+
+ @Attribute(events = @EventName("timeselect"))
+ public abstract String getOntimeselect();
+
+ @Attribute(events = @EventName("timeselected"))
+ public abstract String getOntimeselected();
+
+ @Attribute(events = @EventName("clean"))
+ public abstract String getOnclean();
+
+
@Attribute
public Object getLocale() {
Object locale = getStateHelper().eval(PropertyKeys.locale);
@@ -494,9 +534,9 @@
if (Modes.AJAX.toString().equalsIgnoreCase(getMode())) {
dateRangeBegin = CalendarHelper.getAsDate(facesContext, this,
- getDefaultPreloadBegin((Date) getCurrentDate()));
+ getDefaultPreloadBegin((Date) getCurrentDateOrDefault()));
dateRangeEnd = CalendarHelper.getAsDate(facesContext, this,
- getDefaultPreloadEnd((Date) getCurrentDate()));
+ getDefaultPreloadEnd((Date) getCurrentDateOrDefault()));
} else {
dateRangeBegin = CalendarHelper.getAsDate(facesContext, this,
getPreloadDateRangeBegin());
dateRangeEnd = CalendarHelper.getAsDate(facesContext, this,
getPreloadDateRangeEnd());
Modified:
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java
===================================================================
---
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java 2010-11-22
13:30:34 UTC (rev 20132)
+++
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java 2010-11-22
18:35:31 UTC (rev 20133)
@@ -104,7 +104,7 @@
public abstract String getOnkeypress();
@Attribute(events=@EventName("keyup"))
- public abstract String getOnkeypup();
+ public abstract String getOnkeyup();
@Attribute(events=@EventName("mousedown"))
public abstract String getOnmousedown();
@@ -149,7 +149,7 @@
public abstract String getOninputkeypress();
@Attribute(events=@EventName("inputkeyup"))
- public abstract String getOninputkeypup();
+ public abstract String getOninputkeyup();
@Attribute(events=@EventName("inputfocus"))
public abstract String getOninputfocus();
Modified:
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
---
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-11-22
13:30:34 UTC (rev 20132)
+++
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-11-22
18:35:31 UTC (rev 20133)
@@ -41,7 +41,6 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.PartialViewContext;
-import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.DateTimeConverter;
@@ -79,58 +78,10 @@
public static final String CALENDAR_BUNDLE =
"org.richfaces.renderkit.calendar";
- public static final String OPTION_ENABLE_MANUAL_INPUT =
"enableManualInput";
-
public static final String OPTION_DISABLED = "disabled";
- public static final String OPTION_READONLY = "readonly";
-
- public static final String OPTION_RESET_TIME_ON_DATE_SELECT =
"resetTimeOnDateSelect";
-
- public static final String OPTION_SHOW_APPLY_BUTTON = "showApplyButton";
-
public static final String OPTION_MIN_DAYS_IN_FIRST_WEEK =
"minDaysInFirstWeek";
- public static final String OPTION_POPUP = "popup";
-
- public static final String OPTION_SHOW_INPUT = "showInput";
-
- public static final String OPTION_SHOW_HEADER = "showHeader";
-
- public static final String OPTION_SHOW_FOOTER = "showFooter";
-
- public static final String OPTION_SHOW_WEEKS_BAR = "showWeeksBar";
-
- public static final String OPTION_TODAY_CONTROL_MODE = "todayControlMode";
-
- public static final String OPTION_DATE_PATTERN = "datePattern";
-
- public static final String OPTION_JOINT_POINT = "jointPoint";
-
- public static final String OPTION_DIRECTION = "direction";
-
- public static final String OPTION_BOUNDARY_DATES_MODE =
"boundaryDatesMode";
-
- public static final String OPTION_HORIZONTAL_OFFSET = "horizontalOffset";
-
- public static final String OPTION_VERTICAL_OFFSET = "verticalOffset";
-
- public static final String OPTION_CURRENT_DATE = "currentDate";
-
- public static final String OPTION_SELECTED_DATE = "selectedDate";
-
- public static final String OPTION_DAY_CELL_CLASS = "dayCellClass";
-
- public static final String OPTION_DAY_STYLE_CLASS = "dayStyleClass";
-
- public static final String OPTION_LABELS = "labels";
-
- public static final String OPTION_DEFAULT_TIME = "defaultTime";
-
- public static final String OPTION_HIDE_POPUP_ON_SCROLL =
"hidePopupOnScroll";
-
- public static final String OPTION_SHOW_WEEK_DAYS_BAR = "showWeekDaysBar";
-
public static final String MONTH_LABELS_SHORT = "monthLabelsShort";
public static final String MONTH_LABELS = "monthLabels";
@@ -149,9 +100,6 @@
public static final String CURRENT_DATE_INPUT = "InputCurrentDate";
- public static final String OPTION_MODE = "mode";
-
-
protected static final Map<String, ComponentAttribute>
CALENDAR_INPUT_HANDLER_ATTRIBUTES =
Collections.unmodifiableMap(ComponentAttribute.createMap(
new ComponentAttribute(HtmlConstants.ONCLICK_ATTRIBUTE)
.setEventNames("inputclick")
@@ -205,8 +153,8 @@
return;
}
- AbstractCalendar calendar = (AbstractCalendar)component;
- if (calendar.isDisabled()){
+ AbstractCalendar calendar = (AbstractCalendar) component;
+ if (calendar.isDisabled()) {
return;
}
@@ -245,7 +193,7 @@
// skip conversion of already converted date
if (submittedValue instanceof Date) {
- return (Date)submittedValue;
+ return (Date) submittedValue;
}
// Store submitted value in the local variable as a string
@@ -276,7 +224,7 @@
Object curVal = calendar.getValue();
Converter converter = SelectUtils.findConverter(facesContext, calendar,
"value");
- if(converter == null) {
+ if (converter == null) {
converter = createDefaultConverter();
}
@@ -285,7 +233,7 @@
if (converter != null) {
value = converter.getAsString(facesContext, calendar, curVal);
} else {
- value = curVal !=null ? curVal.toString() : "";
+ value = curVal != null ? curVal.toString() : "";
}
}
@@ -298,7 +246,7 @@
}
public String getButtonIcon(FacesContext facesContext, UIComponent component) {
- boolean disable = (Boolean)component.getAttributes().get("disabled");
+ boolean disable = (Boolean)component.getAttributes().get(OPTION_DISABLED);
String buttonIcon =
(String)component.getAttributes().get("buttonIcon");
if (disable) {
buttonIcon =
(String)component.getAttributes().get("buttonIconDisabled");
@@ -307,16 +255,15 @@
if(buttonIcon != null && buttonIcon.trim().length() != 0) {
buttonIcon = RenderKitUtils.getResourceURL(buttonIcon, facesContext);
} else {
- buttonIcon = disable ? CALENDAR_ICON_RESOURCE_NAME:
CALENDAR_ICON_RESOURCE_NAME;
+ buttonIcon = disable ? CALENDAR_DISABLE_ICON_RESOURCE_NAME:
CALENDAR_ICON_RESOURCE_NAME;
buttonIcon = RenderKitUtils.getResourcePath(facesContext,
"org.richfaces.images",buttonIcon);
}
-
return buttonIcon;
}
public Object getSelectedDate(FacesContext facesContext, UIComponent component)
throws IOException {
Object returnValue = null;
- AbstractCalendar calendar = (AbstractCalendar)component;
+ AbstractCalendar calendar = (AbstractCalendar) component;
if (calendar.isValid()) {
Date date;
Object value = calendar.getValue();
@@ -344,13 +291,14 @@
return result;
}
- public Object getCurrentDate(FacesContext facesContext, AbstractCalendar calendar)
throws IOException {
+ public Object getCurrentDate(FacesContext facesContext, UIComponent component) throws
IOException {
+ AbstractCalendar calendar = (AbstractCalendar) component;
Date date = CalendarHelper.getCurrentDateOrDefault(facesContext, calendar);
return formatDate(date);
}
public String getCurrentDateAsString(FacesContext facesContext, UIComponent
component) throws IOException {
- AbstractCalendar calendar = (AbstractCalendar)component;
+ AbstractCalendar calendar = (AbstractCalendar) component;
Format formatter = new SimpleDateFormat("MM/yyyy");
Date currentDate = CalendarHelper.getCurrentDateOrDefault(facesContext,
calendar);
@@ -368,7 +316,7 @@
return result;
}
- public String getDayCellClass(FacesContext facesContext, AbstractCalendar calendar)
{
+ public String getDayCellClass(FacesContext facesContext, UIComponent component) {
//TODO: refactor this
/*
String cellwidth = (String)
component.getAttributes().get("cellWidth");
@@ -387,12 +335,15 @@
return calendar.isDayEnabled() ? JSReference.TRUE : JSReference.FALSE;
}
- public JSReference getDayStyleClass(FacesContext context, AbstractCalendar calendar)
{
+ public JSReference getDayStyleClass(FacesContext context, UIComponent component) {
+ AbstractCalendar calendar = (AbstractCalendar) component;
String dayStyleClass = calendar.getDayStyleClass();
return ((dayStyleClass != null && dayStyleClass.trim().length() != 0)) ?
new JSReference(dayStyleClass) : null;
}
- public Map<String, Object> getLabels(FacesContext facesContext,
AbstractCalendar calendar) {
+ public Map<String, Object> getLabels(FacesContext facesContext, UIComponent
component) {
+ AbstractCalendar calendar = (AbstractCalendar) component;
+
ResourceBundle bundle1 = null;
ResourceBundle bundle2 = null;
@@ -401,7 +352,7 @@
String messageBundle = facesContext.getApplication().getMessageBundle();
Locale locale = CalendarHelper.getAsLocale(facesContext, calendar);
if (null != messageBundle) {
- bundle1 = ResourceBundle.getBundle(messageBundle,locale , loader);
+ bundle1 = ResourceBundle.getBundle(messageBundle, locale, loader);
}
try {
@@ -419,10 +370,10 @@
protected Map<String, Object> getCollectedLabels(ResourceBundle [] bundles ,
String[] names) {
Map<String, Object> labels = new HashMap<String, Object>();
if (bundles != null && names != null) {
- for (String name: names) {
+ for (String name : names) {
String label = null;
String bundleKey = "RICH_CALENDAR_" + name.toUpperCase() +
"_LABEL";
- for (ResourceBundle bundle: bundles) {
+ for (ResourceBundle bundle : bundles) {
if (bundle != null) {
try {
label = bundle.getString(bundleKey);
@@ -440,7 +391,9 @@
return labels;
}
- public Map<String, Object> getPreparedDefaultTime(FacesContext facesContext,
AbstractCalendar abstractCalendar) {
+ public Map<String, Object> getPreparedDefaultTime(FacesContext facesContext,
UIComponent component) {
+ AbstractCalendar abstractCalendar = (AbstractCalendar) component;
+
Date date = CalendarHelper.getFormattedDefaultTime(abstractCalendar);
Map<String, Object> result = new HashMap<String, Object>();
if (date != null) {
@@ -473,7 +426,9 @@
return shiftedLabels;
}
- protected Map<String, Object> getLocaleOptions(FacesContext facesContext,
AbstractCalendar calendarComponent) {
+ protected Map<String, Object> getLocaleOptions(FacesContext facesContext,
UIComponent component) {
+ AbstractCalendar calendarComponent = (AbstractCalendar) component;
+
Map<String, Object> map = new HashMap<String, Object>();
Locale locale = CalendarHelper.getAsLocale(facesContext, calendarComponent);
@@ -532,74 +487,30 @@
if (0 <= day && day <= 6) {
RenderKitUtils.addToScriptHash(map, FIRST_DAY_WEEK, day);
} else if (day != Integer.MIN_VALUE) {
- facesContext.getExternalContext().log(day + " value of firstWeekDay
attribute is not a legal one for component: " + MessageUtil.getLabel(facesContext,
calendarComponent) + ". Default value was applied.");
+ facesContext.getExternalContext().log(
+ day + " value of firstWeekDay attribute is not a legal one for
component: "
+ + MessageUtil.getLabel(facesContext, calendarComponent) + ".
Default value was applied.");
}
return map;
}
-
- public ScriptOptions createCalendarScriptOption(FacesContext facesContext,
UIComponent component) throws IOException {
- AbstractCalendar calendar = (AbstractCalendar)component;
- ScriptOptions scriptOptions = new ScriptOptions(component);
- scriptOptions.addOption(OPTION_ENABLE_MANUAL_INPUT);
- scriptOptions.addOption(OPTION_DISABLED);
- scriptOptions.addOption(OPTION_READONLY);
- scriptOptions.addOption(OPTION_RESET_TIME_ON_DATE_SELECT);
- scriptOptions.addOption(OPTION_SHOW_APPLY_BUTTON);
- scriptOptions.addOption(OPTION_POPUP);
- scriptOptions.addOption(OPTION_SHOW_INPUT);
- scriptOptions.addOption(OPTION_SHOW_HEADER);
- scriptOptions.addOption(OPTION_SHOW_FOOTER);
- scriptOptions.addOption(OPTION_SHOW_WEEKS_BAR);
- scriptOptions.addOption(OPTION_TODAY_CONTROL_MODE);
- scriptOptions.addOption(OPTION_DATE_PATTERN);
- scriptOptions.addOption(OPTION_JOINT_POINT);
- scriptOptions.addOption(OPTION_DIRECTION);
- scriptOptions.addOption(OPTION_BOUNDARY_DATES_MODE);
- scriptOptions.addOption(OPTION_HORIZONTAL_OFFSET);
- scriptOptions.addOption(OPTION_VERTICAL_OFFSET);
- scriptOptions.addOption(OPTION_CURRENT_DATE, getCurrentDate(facesContext,
calendar));
- scriptOptions.addOption(OPTION_SELECTED_DATE, getSelectedDate(facesContext,
calendar));
- scriptOptions.addOption(OPTION_DAY_CELL_CLASS, getDayCellClass(facesContext,
calendar));
- scriptOptions.addOption(OPTION_DAY_STYLE_CLASS, getDayStyleClass(facesContext,
calendar));
- /*
- *add to script option
- *<cdk:scriptOption attributes="ondateselected, ondateselect,
ontimeselect, ontimeselected, onchanged, ondatemouseover, ondatemouseout, onexpand,
oncollapse, oncurrentdateselect, oncurrentdateselected"
wrapper="eventHandler" />
- * */
- scriptOptions.addOption(OPTION_LABELS, getLabels(facesContext, calendar));
- scriptOptions.addOption(OPTION_DEFAULT_TIME, getPreparedDefaultTime(facesContext,
calendar));
- scriptOptions.addOption(OPTION_HIDE_POPUP_ON_SCROLL);
- scriptOptions.addOption("showWeekDaysBar");
-
- scriptOptions.addOption("styleClass");
- scriptOptions.addOption("style", HtmlUtil.concatStyles("z-index:
" + calendar.getZindex(), calendar.getStyle()));
- scriptOptions.addOption(OPTION_MODE, calendar.getMode());
-
- return scriptOptions;
+
+ public String getStyleWithZindex(FacesContext facesContext, UIComponent component) {
+ AbstractCalendar calendar = (AbstractCalendar) component;
+ String style = HtmlUtil.concatStyles("z-index: " +
calendar.getZindex(), calendar.getStyle());
+ return style;
}
- public void buildAddLocaleScript(ResponseWriter writer, FacesContext facesContext,
UIComponent component) throws IOException {
- if (component instanceof AbstractCalendar) {
- AbstractCalendar calendar = (AbstractCalendar)component;
- JSFunction function = new
JSFunction("RichFaces.ui.Calendar.addLocale",
CalendarHelper.getAsLocale(facesContext, calendar).toString(),
getLocaleOptions(facesContext, calendar));
- writer.write(function.toScript());
- writer.write(";");
- }
+ public Locale getAsLocale(FacesContext facesContext, UIComponent component) {
+ return CalendarHelper.getAsLocale(facesContext, component);
}
- public void buildCalendarScript(ResponseWriter writer, FacesContext facesContext,
UIComponent component) throws IOException {
- if (component instanceof AbstractCalendar) {
- AbstractCalendar calendar = (AbstractCalendar)component;
- ScriptOptions scriptOptions = createCalendarScriptOption(facesContext,
calendar);
- JSFunction function = new JSFunction("new RichFaces.ui.Calendar",
calendar.getClientId(facesContext), CalendarHelper.getAsLocale(facesContext,
calendar).toString(), scriptOptions, "");
- StringBuffer scriptBuffer = new StringBuffer();
- scriptBuffer.append(function.toScript()).append(".load(");
- Object preload = calendar.getPreload();
- if (null != preload){
- scriptBuffer.append(RenderKitUtils.toScriptArgs(preload));
- }
-
- scriptBuffer.append(");");
- writer.write(scriptBuffer.toString());
+ public String writePreloadBody(FacesContext context, UIComponent component) throws
IOException {
+ AbstractCalendar calendar = (AbstractCalendar) component;
+ Object preload = calendar.getPreload();
+ if (preload != null) {
+ return RenderKitUtils.toScriptArgs(preload);
+ } else {
+ return null;
}
}
Modified: branches/RF-8742-1/ui/input/ui/src/main/templates/calendar.template.xml
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/templates/calendar.template.xml 2010-11-22
13:30:34 UTC (rev 20132)
+++ branches/RF-8742-1/ui/input/ui/src/main/templates/calendar.template.xml 2010-11-22
18:35:31 UTC (rev 20133)
@@ -67,11 +67,25 @@
<span style="display: none;"
id="#{clientId}Content"></span>
<span style="display: none;" id="#{clientId}Script">
<script type="text/javascript">
- <cdk:call
- expression="buildAddLocaleScript(responseWriter, facesContext,
component);" />
- <cdk:call
- expression="buildCalendarScript(responseWriter, facesContext, component);"
/>
- </script>
+
+ <cdk:scriptObject name="options">
+ <cdk:scriptOption attributes="enableManualInput disabled readonly
resetTimeOnDateSelect showApplyButton popup showInput showHeader showFooter showWeeksBar
todayControlMode datePattern jointPoint direction boundaryDatesMode horizontalOffset
verticalOffset hidePopupOnScrol showWeekDaysBar styleClass mode" />
+ <cdk:scriptOption attributes="onchange ondateselect ondateselected
oncurrentdateselected oncollapse onexpand ondatemouseover ondatemouseout onclean
ontimeselect ontimeselected" wrapper="eventHandler" />
+ <cdk:scriptOption name="currentDate"
value="#{getCurrentDate(facesContext, component)}" />
+ <cdk:scriptOption name="selectedDate"
value="#{getSelectedDate(facesContext, component)}" />
+ <cdk:scriptOption name="dayCellClass"
value="#{getDayCellClass(facesContext, component)}" />
+ <cdk:scriptOption name="dayStyleClass"
value="#{getDayStyleClass(facesContext, component)}" />
+ <cdk:scriptOption name="labels" value="#{getLabels(facesContext,
component)}" />
+ <cdk:scriptOption name="defaultTime"
value="#{getPreparedDefaultTime(facesContext, component)}" />
+ <cdk:scriptOption name="style"
value="#{getStyleWithZindex(facesContext, component)}" />
+ </cdk:scriptObject>
+
+ RichFaces.ui.Calendar.addLocale("#{getAsLocale(facesContext,
component).toString()}",
+ #{toScriptArgs(getLocaleOptions(facesContext, component))});
+ new RichFaces.ui.Calendar("#{clientId}", "#{getAsLocale(facesContext,
component).toString()}",
+ #{toScriptArgs(options)}).load(#{writePreloadBody(facesContext, component)});
+
+ --></script>
</span>
</span>
</cc:implementation>