Author: pyaschenko
Date: 2007-10-25 12:27:09 -0400 (Thu, 25 Oct 2007)
New Revision: 3543
Modified:
trunk/samples/calendar-sample/src/main/java/org/richfaces/CalendarBean.java
trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
Log:
RF-1117
Modified: trunk/samples/calendar-sample/src/main/java/org/richfaces/CalendarBean.java
===================================================================
--- trunk/samples/calendar-sample/src/main/java/org/richfaces/CalendarBean.java 2007-10-25
16:07:57 UTC (rev 3542)
+++ trunk/samples/calendar-sample/src/main/java/org/richfaces/CalendarBean.java 2007-10-25
16:27:09 UTC (rev 3543)
@@ -45,7 +45,8 @@
private boolean popup;
private boolean readonly;
private boolean showInput;
- private boolean enableManualInput;
+ private boolean enableManualInput;
+ private boolean disabled;
private String pattern;
private Date currentDate;
private Date selectedDate;
@@ -100,6 +101,7 @@
enableManualInput=false;
showInput=true;
boundary = "inactive";
+ disabled = false;
}
@@ -223,4 +225,12 @@
public int getCounter() {
return counter++;
}
+
+ public boolean isDisabled() {
+ return disabled;
+ }
+
+ public void setDisabled(boolean disabled) {
+ this.disabled = disabled;
+ }
}
\ No newline at end of file
Modified: trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp
===================================================================
--- trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp 2007-10-25 16:07:57
UTC (rev 3542)
+++ trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp 2007-10-25 16:27:09
UTC (rev 3543)
@@ -20,9 +20,6 @@
.Selecteddayclass {
background-color: #0087FF;
}
- .even-day {
- background-color: #44aa00;
- }
</style>
</head>
<body>
@@ -54,6 +51,7 @@
direction="#{calendarBean.direction}"
buttonLabel="Select Date"
enableManualInput="#{calendarBean.enableManualInput}"
+ disabled="#{calendarBean.disabled}"
showInput="#{calendarBean.showInput}"
boundaryDatesMode="#{calendarBean.boundary}"
currentDateChangeListener="#{calendarBean.dcl}"
@@ -71,6 +69,8 @@
<h:outputText value="optionalFooter Facet" />
</f:facet>
+ <f:facet name="weekDay"><f:verbatim><span
style="padding: 2px; font-size: 10px" >{weekDayLabel +
weekDayLabelShort}</span></f:verbatim></f:facet>
+
<f:validator validatorId="org.richfaces.CalendarValidator" />
<h:panelGrid columns="2">
@@ -132,6 +132,10 @@
<h:selectBooleanCheckbox value="#{calendarBean.showInput}"
onclick="submit()">
</h:selectBooleanCheckbox>
+ <h:outputText value="Disabled:"></h:outputText>
+ <h:selectBooleanCheckbox value="#{calendarBean.disabled}"
+ onclick="submit()">
+ </h:selectBooleanCheckbox>
Modified:
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
===================================================================
---
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-10-25
16:07:57 UTC (rev 3542)
+++
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-10-25
16:27:09 UTC (rev 3543)
@@ -570,6 +570,17 @@
if(this.params.submitFunction) this.submitFunction =
this.params.submitFunction.bind(this);
this.prepareEvents();
+
+ // add onclick event handlers to input field and popup button
+ if (this.params.popup && !this.params.disabled)
+ {
+ var handler = new Function ('event',
"$('"+this.id+"').component.doSwitch();").bindAsEventListener();
+ Event.observe(this.POPUP_BUTTON_ID, "click", handler, false);
+ if (!this.params.enableManualInput)
+ {
+ Event.observe(this.INPUT_DATE_ID, "click", handler, false);
+ }
+ }
},
doCollapse: function() {
Modified: trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
===================================================================
--- trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-10-25
16:07:57 UTC (rev 3542)
+++ trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-10-25
16:27:09 UTC (rev 3543)
@@ -13,83 +13,6 @@
<h:styles>/org/richfaces/renderkit/html/css/calendar.xcss</h:styles>
- <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">
- <script type="text/javascript">
- new Calendar('#{clientId}', {
-
- <jsp:scriptlet>/*<![CDATA[*/
- String mode = (String) component.getAttributes().get("mode");
- if(org.richfaces.component.UICalendar.AJAX_MODE.equals(mode)){
- /*]]>*/</jsp:scriptlet>
-
- submitFunction: <jsp:scriptlet>/*<![CDATA[*/writeSubmitFunction(context,
component);/*]]>*/</jsp:scriptlet>,
-
- <jsp:scriptlet>/*<![CDATA[*/
- }
- /*]]>*/</jsp:scriptlet>
-
- dayListTableId: '#{clientId}Day',
- weekNumberBarId: '#{clientId}WeekNum',
- weekDayBarId: '#{clientId}WeekDay',
- currentDate: #{this:getCurrentDate(context, component)},
- selectedDate: #{this:getSelectedDate(context, component)},
- datePattern: '#{component.datePattern}',
- jointPoint: '#{component.jointPoint}',
- direction: '#{component.direction}',
- toolTipMode:'#{component.toolTipMode}',
- boundaryDatesMode:'#{component.boundaryDatesMode}',
- popup: #{component.popup},
- enableManualInput: #{component.attributes['enableManualInput']},
- showInput: #{component.attributes['showInput']},
- disabled: #{component.disabled},
- ajaxSingle: #{component.attributes['ajaxSingle']},
- verticalOffset:'#{component.verticalOffset}',
- horizontalOffset: '#{component.horizontalOffset}',
- cellHeight:'#{component.cellHeight}',
- cellWidth:'#{component.cellWidth}',
- <f:call name="writeDayStyleClass"/>
- <f:call name="writeIsDayEnabled"/>
- <f:call name="writeSymbols" />,
- firstWeekDay: #{this:getFirstWeekDay(context, component)},
- minDaysInFirstWeek: #{this:getMinDaysInFirstWeek(context, component)}
-
- <f:call name="writeEventHandlerFunction"><f:parameter
value="ondateselected" /></f:call>
- <f:call name="writeEventHandlerFunction"><f:parameter
value="ondateselect" /></f:call>
- <f:call name="writeEventHandlerFunction"><f:parameter
value="ondatemouseover" /></f:call>
- <f:call name="writeEventHandlerFunction"><f:parameter
value="ondatemouseout" /></f:call>
- <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>
-
-
-
- <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>
-
- <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);
- /*]]>*/</jsp:scriptlet>
- );
- </script></div>
-
<f:call name="addPopupToAjaxRendered" />
<span id="#{clientId}Popup"> <jsp:scriptlet>
@@ -101,20 +24,13 @@
boolean disabled = getUtils().isBooleanAttribute(component,
"disabled");
boolean showInput = getUtils().isBooleanAttribute(component, "showInput");
boolean manualInput = getUtils().isBooleanAttribute(component,
"enableManualInput");
+ variables.setVariable("manualInput",new Boolean(!manualInput));
String onfieldclick =null;
String type="text";
- if(manualInput){
- variables.setVariable("manualInput",new Boolean(!manualInput));
- }
- else{
- variables.setVariable("manualInput",new Boolean(!manualInput));
- onfieldclick =
"$('"+clientId+"').component.doSwitch();";
- }
if (!showInput){
type="hidden";
}
- variables.setVariable("onfieldclick",onfieldclick);
variables.setVariable("type",type);
variables.setVariable("disabled",new Boolean(disabled));
]]>
@@ -133,7 +49,7 @@
onselect="#{component.attributes['oninputselect']}"
onfocus="#{component.attributes['oninputfocus']}"
onblur="#{component.attributes['oninputblur']}"
- onclick="#{onfieldclick} #{component.attributes['oninputclick']}"
+ onclick="#{component.attributes['oninputclick']}"
onkeypress="#{component.attributes['oninputkeypress']}"
onkeydown="#{component.attributes['oninputkeydown']}"
onkeyup="#{component.attributes['oninputkeyup']}"
@@ -152,14 +68,14 @@
]]>
</jsp:scriptlet> <img id="#{clientId}PopupButton"
class="rich-calendar-button #{component.attributes['buttonClass']}"
- accesskey="#{component.attributes['accesskey']}"
name="#{clientId}"
+ accesskey="#{component.attributes['accesskey']}"
style="vertical-align: middle"
tabindex="#{component.attributes['tabindex']}">
<jsp:scriptlet>
<![CDATA[
if(!disabled){
- getUtils().writeAttribute(writer, "onclick",
"$('"+clientId+"').component.doSwitch();");
+ //getUtils().writeAttribute(writer, "onclick",
"$('"+clientId+"').component.doSwitch();");
if(buttonIcon==null){
getUtils().writeAttribute(writer, "src",
variables.getVariable("icon"));
}
@@ -169,7 +85,7 @@
}
else{
- getUtils().writeAttribute(writer, "onclick", null);
+ //getUtils().writeAttribute(writer, "onclick", null);
if(buttonIconDisabled==null){
getUtils().writeAttribute(writer, "src",
variables.getVariable("disabledIcon"));
}
@@ -184,8 +100,7 @@
else{
]]>
</jsp:scriptlet>
- <button type="button" id="#{clientId}PopupButton"
name="#{clientId}"
- onclick="$('#{clientId}').component.doSwitch();return true;
#{component.attributes['oninputclick']}"
+ <button type="button" id="#{clientId}PopupButton"
name="#{clientId}PopupButton"
style="vertical-align: middle"
class="rich-calendar-button #{component.attributes['buttonClass']}"
tabindex="#{component.attributes['tabindex']}"
disabled="#{disabled}">
@@ -199,4 +114,82 @@
}
]]>
</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">
+ <script type="text/javascript">
+ new Calendar('#{clientId}', {
+
+ <jsp:scriptlet>/*<![CDATA[*/
+ String mode = (String) component.getAttributes().get("mode");
+ if(org.richfaces.component.UICalendar.AJAX_MODE.equals(mode)){
+ /*]]>*/</jsp:scriptlet>
+
+ submitFunction: <jsp:scriptlet>/*<![CDATA[*/writeSubmitFunction(context,
component);/*]]>*/</jsp:scriptlet>,
+
+ <jsp:scriptlet>/*<![CDATA[*/
+ }
+ /*]]>*/</jsp:scriptlet>
+
+ dayListTableId: '#{clientId}Day',
+ weekNumberBarId: '#{clientId}WeekNum',
+ weekDayBarId: '#{clientId}WeekDay',
+ currentDate: #{this:getCurrentDate(context, component)},
+ selectedDate: #{this:getSelectedDate(context, component)},
+ datePattern: '#{component.datePattern}',
+ jointPoint: '#{component.jointPoint}',
+ direction: '#{component.direction}',
+ toolTipMode:'#{component.toolTipMode}',
+ boundaryDatesMode:'#{component.boundaryDatesMode}',
+ popup: #{component.popup},
+ enableManualInput: #{component.attributes['enableManualInput']},
+ showInput: #{component.attributes['showInput']},
+ disabled: #{component.disabled},
+ ajaxSingle: #{component.attributes['ajaxSingle']},
+ verticalOffset:'#{component.verticalOffset}',
+ horizontalOffset: '#{component.horizontalOffset}',
+ cellHeight:'#{component.cellHeight}',
+ cellWidth:'#{component.cellWidth}',
+ <f:call name="writeDayStyleClass"/>
+ <f:call name="writeIsDayEnabled"/>
+ <f:call name="writeSymbols" />,
+ firstWeekDay: #{this:getFirstWeekDay(context, component)},
+ minDaysInFirstWeek: #{this:getMinDaysInFirstWeek(context, component)}
+
+ <f:call name="writeEventHandlerFunction"><f:parameter
value="ondateselected" /></f:call>
+ <f:call name="writeEventHandlerFunction"><f:parameter
value="ondateselect" /></f:call>
+ <f:call name="writeEventHandlerFunction"><f:parameter
value="ondatemouseover" /></f:call>
+ <f:call name="writeEventHandlerFunction"><f:parameter
value="ondatemouseout" /></f:call>
+ <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>
+
+
+
+ <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>
+
+ <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);
+ /*]]>*/</jsp:scriptlet>
+ );
+ </script></div>
+
</f:root>