Author: akushunin
Date: 2007-12-17 10:18:47 -0500 (Mon, 17 Dec 2007)
New Revision: 4870
Modified:
trunk/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
Log:
RF-1416 Server side code implemented.
Modified:
trunk/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
---
trunk/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-12-15
03:03:34 UTC (rev 4869)
+++
trunk/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-12-17
15:18:47 UTC (rev 4870)
@@ -21,8 +21,6 @@
package org.richfaces.renderkit;
-
-
import java.io.IOException;
import java.text.DateFormatSymbols;
import java.text.Format;
@@ -33,6 +31,7 @@
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
+import java.util.ResourceBundle;
import java.util.Set;
import javax.faces.component.UIComponent;
@@ -72,9 +71,10 @@
public static final String DATE_SCROLL = "DateScroll";
protected static final String MARKUP_SUFFIX = "Markup";
-
- private final static Log log = LogFactory.getLog(CalendarRendererBase.class);
+ private final static Log log = LogFactory
+ .getLog(CalendarRendererBase.class);
+
/*
* (non-Javadoc)
*
@@ -90,16 +90,13 @@
AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
Set ajaxRenderedAreas = ajaxContext.getAjaxRenderedAreas();
String clientId = component.getClientId(context);
-
+
if (ajaxContext.isAjaxRequest() && ajaxRenderedAreas.contains(clientId)) {
- ajaxRenderedAreas.add(
- clientId + "Popup");
+ ajaxRenderedAreas.add(clientId + "Popup");
- ajaxRenderedAreas.add(
- clientId + "IFrame");
+ ajaxRenderedAreas.add(clientId + "IFrame");
- ajaxRenderedAreas.add(
- clientId + "Script");
+ ajaxRenderedAreas.add(clientId + "Script");
}
}
@@ -210,7 +207,7 @@
if (facet != null && facet.isRendered()) {
ResponseWriter writer = context.getResponseWriter();
writer.writeText(",\n " + facetName + MARKUP_SUFFIX + ": ",
null);
- writeMarkupScriptBody(context, facet, false);
+ writeMarkupScriptBody(context, facet, false);
}
}
@@ -338,16 +335,15 @@
public String getInputValue(FacesContext context, UIComponent component) {
UICalendar input = (UICalendar) component;
// XXX nick - nick - can contain either Date or String instance
- //Fix for myFaces 1.1.x RF-997
+ // Fix for myFaces 1.1.x RF-997
Date value = null;
try {
value = input.getAsDate(input.getSubmittedValue());
} catch (Exception e) {
if (log.isDebugEnabled()) {
- log.debug(" InputValue: "
- + e.toString(), e);
+ log.debug(" InputValue: " + e.toString(), e);
}
- value = null;
+ value = null;
}
Date curVal = input.getAsDate(input.getValue());
@@ -454,38 +450,39 @@
return String.valueOf(cal.getMinimalDaysInFirstWeek());
}
- public String getCurrentDateAsString(FacesContext context, UICalendar calendar, Date
date)
- throws IOException {
-
+ public String getCurrentDateAsString(FacesContext context,
+ UICalendar calendar, Date date) throws IOException {
+
Format formatter = new SimpleDateFormat("MM/yyyy");
return formatter.format(date);
}
- public String getCurrentDate(FacesContext context, UICalendar calendar, Date date)
- throws IOException {
+ public String getCurrentDate(FacesContext context, UICalendar calendar,
+ Date date) throws IOException {
return ScriptUtils.toScript(formatDate(date));
}
public String getSelectedDate(FacesContext context, UICalendar calendar)
throws IOException {
-
- //Fix for myFaces 1.1.x RF-997
- Date date;
- if(calendar.isValid()){
- Date submittedValue = calendar.getAsDate(calendar.getSubmittedValue());
+
+ // Fix for myFaces 1.1.x RF-997
+ Date date;
+ if (calendar.isValid()) {
+ Date submittedValue = calendar.getAsDate(calendar
+ .getSubmittedValue());
if (submittedValue != null) {
date = submittedValue;
} else {
date = calendar.getAsDate(calendar.getValue());
}
- }else{
+ } else {
date = calendar.getAsDate(calendar.getValue());
- //Date submittedValue = null;
- }
+ // Date submittedValue = null;
+ }
if (date != null) {
return ScriptUtils.toScript(formatSelectedDate(date));
- //TODO KAA Add ServerTime Processing;
+ // XXX KAA Add ServerTime Processing;
}
return ScriptUtils.toScript(null);
@@ -501,7 +498,7 @@
return result;
}
-
+
public static Object formatSelectedDate(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
@@ -509,9 +506,36 @@
result.addParameter(Integer.valueOf(calendar.get(Calendar.YEAR)));
result.addParameter(Integer.valueOf(calendar.get(Calendar.MONTH)));
result.addParameter(Integer.valueOf(calendar.get(Calendar.DATE)));
- result.addParameter(Integer.valueOf(calendar.get(Calendar.HOUR_OF_DAY)));
+ result
+ .addParameter(Integer.valueOf(calendar
+ .get(Calendar.HOUR_OF_DAY)));
result.addParameter(Integer.valueOf(calendar.get(Calendar.MINUTE)));
- result.addParameter(new Integer(0));
+ result.addParameter(new Integer(0));
return result;
}
+
+ public void writeLabels(FacesContext context, UICalendar calendar)
+ throws IOException {
+
+ String messageBundle = context.getApplication().getMessageBundle();
+ ResourceBundle bundle = ResourceBundle.getBundle(messageBundle);
+ ResponseWriter writer = context.getResponseWriter();
+ writer.writeText("\n labels:{", null);
+
+ if (null != bundle && messageBundle.contains("rich_calendar_labels"))
{
+
+ String applyLabel = bundle.getString("applyLabel");
+ writer.writeText("apply:'"+applyLabel + "', ", null);
+ String todayLabel = bundle.getString("todayLabel");
+ writer.writeText("today:'"+todayLabel + "', ", null);
+ String cleanLabel = bundle.getString("cleanLabel");
+ writer.writeText("clean:'"+cleanLabel + "', ", null);
+ String closeLabel = bundle.getString("closeLabel");
+ writer.writeText("close:'"+closeLabel+"', ", null);
+
+ }else{
+ writer.writeText("apply:'Apply', today:'Today',
clean:'Clean', close:'X'", null);
+ }
+ writer.writeText("};\n", null);
+ }
}
Modified: trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
===================================================================
--- trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-12-15
03:03:34 UTC (rev 4869)
+++ trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-12-17
15:18:47 UTC (rev 4870)
@@ -12,7 +12,7 @@
<h:scripts>new org.ajax4jsf.javascript.PrototypeScript(),new
org.ajax4jsf.javascript.AjaxScript(),/org/richfaces/renderkit/html/scripts/events.js,/org/richfaces/renderkit/html/scripts/utils.js,/org/richfaces/renderkit/html/scripts/json/json-dom.js,/org/richfaces/renderkit/html/scripts/scriptaculous/effects.js,/org/richfaces/renderkit/html/scripts/jquery/jquery.js,/org/richfaces/renderkit/html/scripts/jquery/jquery.js,/org/richfaces/renderkit/html/scripts/JQuerySpinBtn.js,/org/richfaces/renderkit/html/scripts/calendar.js</h:scripts>
<h:styles>/org/richfaces/renderkit/html/css/calendar.xcss</h:styles>
-
+
<f:call name="addPopupToAjaxRendered" />
<span id="#{clientId}Popup"
@@ -50,7 +50,7 @@
<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}"
@@ -228,6 +228,7 @@
writePreloadBody(context, component);
/*]]>*/</jsp:scriptlet>
);
+ <f:call name="writeLabels" />
</script>
</div>
</f:root>