You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mm...@apache.org on 2006/10/09 17:35:16 UTC
svn commit: r454408 -
/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/date/HtmlDateRenderer.java
Author: mmarinschek
Date: Mon Oct 9 08:35:15 2006
New Revision: 454408
URL: http://svn.apache.org/viewvc?view=rev&rev=454408
Log:
fix for button rendered in script
Modified:
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/date/HtmlDateRenderer.java
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/date/HtmlDateRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/date/HtmlDateRenderer.java?view=diff&rev=454408&r1=454407&r2=454408
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/date/HtmlDateRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/date/HtmlDateRenderer.java Mon Oct 9 08:35:15 2006
@@ -1,12 +1,12 @@
/*
* Copyright 2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -50,8 +50,8 @@
* <p>The message identifier of the {@link FacesMessage} to be created if
* the creditcard check fails.</p>
*/
- public static final String DATE_MESSAGE_ID = "org.apache.myfaces.Date.INVALID";
-
+ public static final String DATE_MESSAGE_ID = "org.apache.myfaces.Date.INVALID";
+
private static final String ID_DAY_POSTFIX = ".day";
private static final String ID_MONTH_POSTFIX = ".month";
private static final String ID_YEAR_POSTFIX = ".year";
@@ -66,14 +66,14 @@
return inputDate.isDisabled();
}
-
+
public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {
RendererUtils.checkParamValidity(facesContext, uiComponent, HtmlInputDate.class);
HtmlInputDate inputDate = (HtmlInputDate) uiComponent;
Locale currentLocale = facesContext.getViewRoot().getLocale();
UserData userData = (UserData) inputDate.getSubmittedValue();
- if( userData == null )
+ if( userData == null )
userData = inputDate.getUserData(currentLocale);
String type = inputDate.getType();
boolean ampm = inputDate.isAmpm();
@@ -85,7 +85,7 @@
ResponseWriter writer = facesContext.getResponseWriter();
HtmlRendererUtils.writePrettyLineSeparator(facesContext);
-
+
writer.startElement(HTML.SPAN_ELEM, uiComponent);
writer.writeAttribute(HTML.ID_ATTR, clientId, null);
@@ -93,7 +93,7 @@
encodeInputDay(inputDate, writer, clientId, userData, disabled, readonly);
encodeInputMonth(inputDate, writer, clientId, userData, currentLocale, disabled, readonly);
encodeInputYear(inputDate, writer, clientId, userData, disabled, readonly);
-
+
if( inputDate.isPopupCalendar() && ! disabled && ! readonly )
encodePopupCalendarButton(facesContext, uiComponent, writer, clientId, currentLocale);
}
@@ -112,10 +112,10 @@
encodeInputAmpm(uiComponent, writer, clientId, userData, disabled, readonly, currentLocale);
}
}
-
+
writer.endElement(HTML.SPAN_ELEM);
}
-
+
protected void encodeInputField(UIComponent uiComponent, ResponseWriter writer, String id,
String value, int size, boolean disabled, boolean readonly) throws IOException {
writer.startElement(HTML.INPUT_ELEM, uiComponent);
@@ -140,7 +140,7 @@
}
writer.endElement(HTML.INPUT_ELEM);
}
-
+
protected void encodeInputDay(UIComponent uiComponent, ResponseWriter writer, String clientId,
UserData userData, boolean disabled, boolean readonly) throws IOException {
encodeInputField(uiComponent, writer, clientId + ID_DAY_POSTFIX, userData.getDay(), 2, disabled, readonly);
@@ -164,7 +164,7 @@
}
int selectedMonth = userData.getMonth() == null ? -1 : Integer.parseInt(userData.getMonth())-1;
-
+
String[] months = HtmlCalendarRenderer.mapMonths(new DateFormatSymbols(currentLocale));
encodeEmptyInputMonthSelection(uiComponent, writer, selectedMonth);
for (int i = 0; i < months.length; i++) {
@@ -187,14 +187,14 @@
writer.writeText("", null);
writer.endElement(HTML.SELECT_ELEM);
}
-
+
protected void encodeEmptyInputMonthSelection(UIComponent component, ResponseWriter writer, int selectedMonth) throws IOException{
writer.startElement(HTML.OPTION_ELEM, component);
writer.writeAttribute(HTML.VALUE_ATTR, "-1", null);
-
+
if(selectedMonth == -1)
writer.writeAttribute(HTML.SELECTED_ATTR, HTML.SELECTED_ATTR, null);
-
+
writer.writeText(((HtmlInputDate)component).getEmptyMonthSelection(), null);
writer.endElement(HTML.OPTION_ELEM);
}
@@ -203,22 +203,22 @@
UserData userData, boolean disabled, boolean readonly) throws IOException {
encodeInputField(uiComponent, writer, clientId + ID_YEAR_POSTFIX, userData.getYear(), 4, disabled, readonly);
}
-
+
protected void encodeInputHours(UIComponent uiComponent, ResponseWriter writer, String clientId,
UserData userData, boolean disabled, boolean readonly) throws IOException {
encodeInputField(uiComponent, writer, clientId + ID_HOURS_POSTFIX, userData.getHours(), 2, disabled, readonly);
}
-
+
protected void encodeInputMinutes(UIComponent uiComponent, ResponseWriter writer, String clientId,
UserData userData, boolean disabled, boolean readonly) throws IOException {
encodeInputField(uiComponent, writer, clientId + ID_MINUTES_POSTFIX, userData.getMinutes(), 2, disabled, readonly);
}
-
+
protected void encodeInputSeconds(UIComponent uiComponent, ResponseWriter writer, String clientId,
UserData userData, boolean disabled, boolean readonly) throws IOException {
encodeInputField(uiComponent, writer, clientId + ID_SECONDS_POSTFIX, userData.getSeconds(), 2, disabled, readonly);
}
-
+
protected void encodeAmpmChoice(DateFormatSymbols symbols, UIComponent uiComponent, ResponseWriter writer, int calendar_ampm, int selected) throws IOException {
String[] ampm_choices = symbols.getAmPmStrings();
writer.write("\t\t");
@@ -229,7 +229,7 @@
writer.writeText(ampm_choices[calendar_ampm], null);
writer.endElement(HTML.OPTION_ELEM);
}
-
+
protected void encodeInputAmpm(UIComponent uiComponent, ResponseWriter writer, String clientId,
UserData userData, boolean disabled, boolean readonly, Locale currentLocale) throws IOException {
writer.startElement(HTML.SELECT_ELEM, uiComponent);
@@ -248,7 +248,7 @@
}
DateFormatSymbols symbols = new DateFormatSymbols(currentLocale);
-
+
int selectedAmpm = userData.getAmpm() == null ? -1 : Integer.parseInt(userData.getAmpm());
encodeEmtypAmpmChoice(uiComponent, writer, selectedAmpm);
encodeAmpmChoice(symbols, uiComponent, writer, Calendar.AM, selectedAmpm);
@@ -259,18 +259,18 @@
writer.writeText("", null);
writer.endElement(HTML.SELECT_ELEM);
}
-
+
protected void encodeEmtypAmpmChoice(UIComponent component, ResponseWriter writer, int selectedAmpm) throws IOException{
writer.startElement(HTML.OPTION_ELEM, component);
writer.writeAttribute(HTML.VALUE_ATTR, "-1", null);
-
+
if(selectedAmpm == -1)
writer.writeAttribute(HTML.SELECTED_ATTR, HTML.SELECTED_ATTR, null);
-
+
writer.writeText(((HtmlInputDate)component).getEmptyAmpmSelection(), null);
writer.endElement(HTML.OPTION_ELEM);
}
-
+
protected void encodePopupCalendarButton(FacesContext facesContext, UIComponent uiComponent, ResponseWriter writer, String clientId, Locale currentLocale) throws IOException{
DateFormatSymbols symbols = new DateFormatSymbols(currentLocale);
@@ -297,7 +297,10 @@
writer.write(localizedLanguageScript);
writer.writeText(calendarVar+".init(document.getElementById('"+
uiComponent.getClientId(facesContext)+"Span"+"'));\n",null);
- HtmlCalendarRenderer.getScriptBtn(writer, facesContext, uiComponent,
+
+
+ writer.endElement(HTML.SCRIPT_ELEM);
+ HtmlCalendarRenderer.getScriptBtn(writer, facesContext, uiComponent,
dateFormat,"...",new FunctionCallProvider(){
public String getFunctionCall(FacesContext facesContext, UIComponent uiComponent, String dateFormat)
{
@@ -305,19 +308,17 @@
String clientVar = JavascriptUtils.getValidJavascriptName(clientId+"CalendarVar",true);
- return clientVar+"._popUpCalendarForInputDate(\\'"+clientId+"\\',\\'"+dateFormat+"\\');";
+ return clientVar+"._popUpCalendarForInputDate('"+clientId+"','"+dateFormat+"');";
}
});
-
- writer.endElement(HTML.SCRIPT_ELEM);
}
public void decode(FacesContext facesContext, UIComponent uiComponent) {
RendererUtils.checkParamValidity(facesContext, uiComponent, HtmlInputDate.class);
-
+
HtmlInputDate inputDate = (HtmlInputDate) uiComponent;
-
+
if( isDisabled(facesContext, inputDate) ) // For safety, do not set the submited value if the component is disabled.
return;
@@ -335,7 +336,7 @@
userData.setMonth( (String) requestMap.get(clientId + ID_MONTH_POSTFIX) );
userData.setYear( (String) requestMap.get(clientId + ID_YEAR_POSTFIX) );
}
-
+
if( ! type.equals( "date" ) ){
userData.setHours( (String) requestMap.get(clientId + ID_HOURS_POSTFIX) );
userData.setMinutes( (String) requestMap.get(clientId + ID_MINUTES_POSTFIX) );
@@ -349,7 +350,7 @@
}
inputDate.setSubmittedValue( userData );
}
-
+
public Object getConvertedValue(FacesContext context, UIComponent uiComponent, Object submittedValue) throws ConverterException {
UserData userData = (UserData) submittedValue;
try {