Author: nbelaevski
Date: 2007-07-20 09:12:47 -0400 (Fri, 20 Jul 2007)
New Revision: 1735
Modified:
trunk/sandbox/samples/calendar-sample/src/main/webapp/pages/index.jsp
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
trunk/sandbox/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
Log:
Source code optimized
Modified: trunk/sandbox/samples/calendar-sample/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/sandbox/samples/calendar-sample/src/main/webapp/pages/index.jsp 2007-07-20
12:55:55 UTC (rev 1734)
+++ trunk/sandbox/samples/calendar-sample/src/main/webapp/pages/index.jsp 2007-07-20
13:12:47 UTC (rev 1735)
@@ -10,7 +10,9 @@
<h:form>
<calendar:calendar id="calendar" data="#{calendarDataModel}"
locale="#{calendarBean.locale}">
<f:facet name="header">
- {nextMonthControl} | {previousMonthControl}
+ <f:verbatim>
+ {previousMonthControl} | {nextMonthControl}
+ </f:verbatim>
</f:facet>
<f:facet name="weekNumber">
<h:outputText style="font-weight: bold;" value="{weekNumber}"
/>
Modified:
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
---
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-07-20
12:55:55 UTC (rev 1734)
+++
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-07-20
13:12:47 UTC (rev 1735)
@@ -51,6 +51,8 @@
public static final String DATE_SCROLL = "DateScroll";
+ protected static final String MARKUP_SUFFIX = "Markup";
+
/*
* (non-Javadoc)
*
@@ -115,14 +117,21 @@
public void writeMarkupScriptBody(FacesContext context,
UIComponent component, boolean children) throws IOException {
- ResponseWriter responseWriter = context.getResponseWriter();
- responseWriter
- .write("function (context) { return this.invoke('getContent',
context).join('')");
- responseWriter.write("}.bind(");
writeScriptBody(context, component, children);
- responseWriter.write(")");
}
+ public void writeFacetMarkupScriptBody(FacesContext context,
+ 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 + ": ", null);
+ writeMarkupScriptBody(context, facet, false);
+ }
+ }
+
+
public void writePreloadBody(FacesContext context, UICalendar calendar)
throws IOException {
Object preload = calendar.getPreload();
Modified: trunk/sandbox/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
===================================================================
---
trunk/sandbox/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-07-20
12:55:55 UTC (rev 1734)
+++
trunk/sandbox/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-07-20
13:12:47 UTC (rev 1735)
@@ -34,40 +34,18 @@
minDaysInFirstWeek: 4,
headerOptionalMarkup: [new E('b',{},[new T('User defined
header')])],
footerOptionalMarkup: [new E('b',{},[new T('User defined
header')])],
- dayListMarkup:
- <jsp:scriptlet>/*<![CDATA[*/
- if (component.getChildCount() != 0) {
- writeMarkupScriptBody(context, component, true);
- } else {
- /*]]>*/</jsp:scriptlet>
- Calendar.getDayView
- <jsp:scriptlet>/*<![CDATA[*/
- }
- /*]]>*/</jsp:scriptlet>
- ,
-
- weekDayMarkup: <jsp:scriptlet>/*<![CDATA[*/
- UIComponent weekDayFacet = component.getFacet("weekDay");
- if (weekDayFacet != null && weekDayFacet.isRendered()) {
- writeMarkupScriptBody(context, weekDayFacet, false);
- } else {
- /*]]>*/</jsp:scriptlet>
- Calendar.getWeekDayView
- <jsp:scriptlet>/*<![CDATA[*/
- }
- /*]]>*/</jsp:scriptlet>
- ,
-
- weekNumberMarkup: <jsp:scriptlet>/*<![CDATA[*/
- UIComponent weekNumberFacet = component.getFacet("weekNumber");
- if (weekNumberFacet != null && weekNumberFacet.isRendered()) {
- writeMarkupScriptBody(context, weekNumberFacet, false);
- } else {
- /*]]>*/</jsp:scriptlet>
- Calendar.getWeekNumberView
- <jsp:scriptlet>/*<![CDATA[*/
- }
- /*]]>*/</jsp:scriptlet>
+ <jsp:scriptlet>/*<![CDATA[*/
+ if (component.getChildCount() != 0) {
+ /*]]>*/</jsp:scriptlet>
+ dayListMarkup:
+ <jsp:scriptlet>/*<![CDATA[*/
+ writeMarkupScriptBody(context, component, true);
+ }
+ /*]]>*/</jsp:scriptlet>
+ <f:call name="writeFacetMarkupScriptBody"><f:parameter
value="weekDay" /></f:call>
+ <f:call name="writeFacetMarkupScriptBody"><f:parameter
value="weekNumber" /></f:call>
+ <f:call name="writeFacetMarkupScriptBody"><f:parameter
value="header" /></f:call>
+ <f:call name="writeFacetMarkupScriptBody"><f:parameter
value="footer" /></f:call>
}).load(
<jsp:scriptlet>/*<![CDATA[*/
writePreloadBody(context, component);