Author: akushunin
Date: 2007-10-31 08:30:12 -0400 (Wed, 31 Oct 2007)
New Revision: 3632
Modified:
trunk/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss
trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
Log:
Calendar refactoring
Modified:
trunk/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
---
trunk/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-10-31
09:38:30 UTC (rev 3631)
+++
trunk/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-10-31
12:30:12 UTC (rev 3632)
@@ -99,11 +99,12 @@
}
UICalendar calendar = (UICalendar) component;
if (calendar.getConverter() != null) {
-
- return calendar.getConverter().getAsObject(context, component,
(String)submittedValue);
-
+
+ return calendar.getConverter().getAsObject(context, component,
+ (String) submittedValue);
+
} else {
- DateTimeConverter converter = new DateTimeConverter();
+ DateTimeConverter converter = new DateTimeConverter();
converter.setPattern(calendar.getDatePattern());
converter.setLocale(calendar.getLocale());
converter.setTimeZone(calendar.getTimeZone());
@@ -149,44 +150,87 @@
throws IOException {
}
-
- public void writeDayStyleClass(FacesContext context, UIComponent component) throws
IOException{
-
+
+ public void writeStyles(FacesContext context, UIComponent component)
+ throws IOException {
+
UICalendar calendar = (UICalendar) component;
- String dayStyleClass = (String)
calendar.getAttributes().get("dayStyleClass");
- if(dayStyleClass!=null && dayStyleClass.length()!=0){
+ String styleClass = (String) calendar.getAttributes().get("styleClass");
+ if (styleClass != null && styleClass.length() != 0) {
ResponseWriter writer = context.getResponseWriter();
- writer.writeText("dayStyleClass: "+dayStyleClass+", ", null);
- //getUtils().writeAttribute(writer,
"dayStyleClass",dayStyleClass+',');
+ writer.writeText("className: " + styleClass + ", ", null);
}
-
+ }
+
+ public void writeDayStyleClass(FacesContext context, UIComponent component)
+ throws IOException {
+
+ UICalendar calendar = (UICalendar) component;
+ String dayStyleClass = (String) calendar.getAttributes().get(
+ "dayStyleClass");
+ if (dayStyleClass != null && dayStyleClass.length() != 0) {
+ ResponseWriter writer = context.getResponseWriter();
+ writer.writeText("dayStyleClass: " + dayStyleClass + ", ", null);
+ // getUtils().writeAttribute(writer,
+ // "dayStyleClass",dayStyleClass+',');
}
- public void writeIsDayEnabled(FacesContext context, UIComponent component)throws
IOException{
+
+ }
+
+ public void writeIsDayEnabled(FacesContext context, UIComponent component)
+ throws IOException {
UICalendar calendar = (UICalendar) component;
- String isDayEnabled = (String)
calendar.getAttributes().get("isDayEnabled");
- if(isDayEnabled!=null && isDayEnabled.length()!=0){
+ String isDayEnabled = (String) calendar.getAttributes().get(
+ "isDayEnabled");
+ if (isDayEnabled != null && isDayEnabled.length() != 0) {
ResponseWriter writer = context.getResponseWriter();
- writer.writeText("isDayEnabled: "+isDayEnabled+", ", null);
- }
+ writer.writeText("isDayEnabled: " + isDayEnabled + ", ", null);
+ }
}
-
+
public void writeMarkupScriptBody(FacesContext context,
UIComponent component, boolean children) throws IOException {
writeScriptBody(context, component, children);
}
-
+
public void writeOptionalFacetMarkupScriptBody(FacesContext context,
- UIComponent component, String facetName) throws IOException{
-
+ UIComponent component, String facetName) throws IOException {
+
UIComponent facet = component.getFacet(facetName);
if (facet != null && facet.isRendered()) {
ResponseWriter writer = context.getResponseWriter();
- writer.writeText(", " + facetName + MARKUP_SUFFIX + ":
"+"[new E('b',{},", null);
+ writer.writeText(", " + facetName + MARKUP_SUFFIX + ": "
+ + "[new E('b',{},", null);
writeMarkupScriptBody(context, facet, false);
- writer.writeText(")]",null);
+ writer.writeText(")]", null);
}
}
-
+
+ public void writeDivBody(FacesContext context, UIComponent component)
+ throws IOException {
+ // if cellWidth/Height is set send dayCellClass to script
+ Integer cellwidth = (Integer) component.getAttributes()
+ .get("cellWidth");
+ Integer cellheight = (Integer) component.getAttributes().get(
+ "cellHeight");
+ ResponseWriter writer = context.getResponseWriter();
+ if (cellwidth != null && cellwidth > 0 || cellheight != null
+ && cellheight > 0) {
+
+ String clientId = component.getClientId(context);
+ String divStyle = "<style> ." + clientId + "DayCell{width:
"
+ + cellwidth + "px; height:" + cellheight + "px;
}<style/>";
+ writer.writeText(", dayCellClass: " + divStyle, null);
+ }
+
+ if (component.getChildCount() != 0) {
+
+ writer.writeText(",dayListMarkup: ", null);
+ writeMarkupScriptBody(context, component, true);
+
+ }
+ }
+
public void writeFacetMarkupScriptBody(FacesContext context,
UIComponent component, String facetName) throws IOException {
@@ -266,16 +310,15 @@
Date value = input.getAsDate(input.getSubmittedValue());
Date curVal = input.getAsDate(input.getValue());
-
- DateTimeConverter converter = new DateTimeConverter();
- converter.setPattern(input.getDatePattern());
- converter.setLocale(input.getLocale());
- converter.setTimeZone(input.getTimeZone());
- if (value == null) {
+ DateTimeConverter converter = new DateTimeConverter();
+ converter.setPattern(input.getDatePattern());
+ converter.setLocale(input.getLocale());
+ converter.setTimeZone(input.getTimeZone());
+ if (value == null) {
return converter.getAsString(context, input, curVal);
- }else{
- return converter.getAsString(context, input, value);
+ } else {
+ return converter.getAsString(context, input, value);
}
}
Modified:
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss
===================================================================
---
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss 2007-10-31
09:38:30 UTC (rev 3631)
+++
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss 2007-10-31
12:30:12 UTC (rev 3632)
@@ -20,11 +20,17 @@
border-bottom : 1px solid;
}
-.rich-cell-size{
+.rich-calendar-cell-size{
width : 25px;
height : 22px;
}
+.rich-calendar-cell-div{
+ width : 100%;
+ height : 100%;
+ overflow: hidden;
+}
+
.rich-calendar-cell{
border-bottom : 1px solid;
border-right : 1px solid;
Modified: trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
===================================================================
--- trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-10-31
09:38:30 UTC (rev 3631)
+++ trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-10-31
12:30:12 UTC (rev 3632)
@@ -14,8 +14,9 @@
<h:styles>/org/richfaces/renderkit/html/css/calendar.xcss</h:styles>
<f:call name="addPopupToAjaxRendered" />
-
- <span id="#{clientId}Popup"> <jsp:scriptlet>
+
+ <span id="#{clientId}Popup"
+ x:passThruWithExclusions="value,name,type,id,styleClass,class,style">
<jsp:scriptlet>
<![CDATA[
boolean popup = getUtils().isBooleanAttribute(component, "popup");
if (!popup) {
@@ -113,12 +114,7 @@
<![CDATA[
}
]]>
- </jsp:scriptlet> </span>
-
- <div id="#{clientId}"
- style="z-index: #{component.attributes['zindex']};
#{component.attributes['style']}"
- class="rich-calendar-popup #{component.attributes['styleClass']}"
- x:passThruWithExclusions="value,name,type,id,styleClass,class,style">
+ </jsp:scriptlet> </span>
<script type="text/javascript">
new Calendar('#{clientId}', {
@@ -150,8 +146,9 @@
ajaxSingle: #{component.attributes['ajaxSingle']},
verticalOffset:'#{component.verticalOffset}',
horizontalOffset: '#{component.horizontalOffset}',
- cellHeight:'#{component.cellHeight}',
- cellWidth:'#{component.cellWidth}',
+ style:'z-index: #{component.attributes['zindex']};
#{component.attributes['style']}'
+
+ <f:call name="writeStyles"/>
<f:call name="writeDayStyleClass"/>
<f:call name="writeIsDayEnabled"/>
<f:call name="writeSymbols" />,
@@ -165,18 +162,9 @@
<f:call name="writeEventHandlerFunction"><f:parameter
value="onexpand" /></f:call>
<f:call name="writeEventHandlerFunction"><f:parameter
value="oncollapse" /></f:call>
<f:call name="writeEventHandlerFunction"><f:parameter
value="oncurrentdateselect" /></f:call>
-
+
+ <f:call name="writeDivBody"></f:call>
-
- <jsp:scriptlet>/*<![CDATA[*/
- if (component.getChildCount() != 0) {
- /*]]>*/</jsp:scriptlet>
- ,dayListMarkup:
- <jsp:scriptlet>/*<![CDATA[*/
- writeMarkupScriptBody(context, component, true);
- }
- /*]]>*/</jsp:scriptlet>
-
<f:call name="writeOptionalFacetMarkupScriptBody"><f:parameter
value="optionalHeader" /></f:call>
<f:call name="writeOptionalFacetMarkupScriptBody"><f:parameter
value="optionalFooter" /></f:call>
@@ -190,6 +178,5 @@
writePreloadBody(context, component);
/*]]>*/</jsp:scriptlet>
);
- </script></div>
-
+ </script>
</f:root>