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 2005/12/21 15:11:58 UTC

svn commit: r358294 - in /myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar: HtmlCalendarRenderer.java resource/popcalendar.js resource/pt.js

Author: mmarinschek
Date: Wed Dec 21 06:11:52 2005
New Revision: 358294

URL: http://svn.apache.org/viewcvs?rev=358294&view=rev
Log:
calendar works in IE now  - yes, thanks! Please learn from me and never append a child to the body element in IE ;)

Modified:
    myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java
    myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/resource/popcalendar.js
    myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/resource/pt.js

Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java?rev=358294&r1=358293&r2=358294&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java Wed Dec 21 06:11:52 2005
@@ -27,6 +27,7 @@
 import org.apache.myfaces.custom.buffer.HtmlBufferResponseWriterWrapper;
 import org.apache.myfaces.custom.prototype.PrototypeResourceLoader;
 import org.apache.myfaces.custom.inputTextHelp.HtmlTextHelpRenderer;
+import org.apache.myfaces.custom.inputTextHelp.HtmlInputTextHelp;
 import org.apache.commons.lang.StringEscapeUtils;
 
 import javax.faces.application.Application;
@@ -120,14 +121,14 @@
 
             Application application = facesContext.getApplication();
 
-            HtmlInputText inputText = getOrCreateInputTextChild(inputCalendar, application);
+            HtmlInputTextHelp inputText = getOrCreateInputTextChild(inputCalendar, application);
 
             RendererUtils.copyHtmlInputTextAttributes(inputCalendar, inputText);
 
             inputText.setConverter(null); // value for this transient component will already be converted
             inputText.setTransient(true);
-            //inputText.setHelpText(inputCalendar.getHelpText());
-            //inputText.setSelectText(true);
+            inputText.setHelpText(inputCalendar.getHelpText());
+            inputText.setSelectText(true);
 
             if (value == null && inputCalendar.getSubmittedValue() != null)
             {
@@ -157,22 +158,28 @@
             //Set back the correct id to the input calendar
             inputCalendar.setId(inputText.getId());
 
+            ResponseWriter writer = facesContext.getResponseWriter();
+
+            writer.startElement(HTML.SPAN_ELEM,inputCalendar);
+            writer.writeAttribute(HTML.ID_ATTR,inputCalendar.getClientId(facesContext)+"Span",
+                    JSFAttr.ID_ATTR);
+            writer.endElement(HTML.SPAN_ELEM);
+
             if (!inputCalendar.isDisabled())
             {
-	            ResponseWriter writer = facesContext.getResponseWriter();
-
 	            writer.startElement(HTML.SCRIPT_ELEM, component);
 	            writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR,HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT,null);
 
                 String calendarVar = JavascriptUtils.getValidJavascriptName(
                         inputCalendar.getClientId(facesContext)+"CalendarVar",false);
 
-                writer.writeText("alert('1'); var "+calendarVar+"=new org_apache_myfaces_PopupCalendar();\n",null);
+                writer.writeText("var "+calendarVar+"=new org_apache_myfaces_PopupCalendar();\n",null);
                 writer.writeText(getLocalizedLanguageScript(facesContext,symbols, months,
 	                    timeKeeper.getFirstDayOfWeek(),inputCalendar,calendarVar)+"\n",null);
-                writer.writeText(calendarVar+".init();\n",null);
+                writer.writeText(calendarVar+".init(document.getElementById('"+
+                        inputCalendar.getClientId(facesContext)+"Span"+"'));\n",null);
                 writer.writeText(getScriptBtn(facesContext, inputCalendar,
-                        dateFormat,inputCalendar.getPopupButtonString()+"\n"),null);
+                        dateFormat,inputCalendar.getPopupButtonString())+"\n",null);
 	            writer.endElement(HTML.SCRIPT_ELEM);
             }
         }
@@ -236,9 +243,9 @@
         }
     }
 
-    private HtmlInputText getOrCreateInputTextChild(HtmlInputCalendar inputCalendar, Application application)
+    private HtmlInputTextHelp getOrCreateInputTextChild(HtmlInputCalendar inputCalendar, Application application)
     {
-        HtmlInputText inputText = null;
+        HtmlInputTextHelp inputText = null;
 
         List li = inputCalendar.getChildren();
 
@@ -246,16 +253,16 @@
         {
             UIComponent uiComponent = (UIComponent) li.get(i);
 
-            if(uiComponent instanceof HtmlInputText)
+            if(uiComponent instanceof HtmlInputTextHelp)
             {
-                inputText = (HtmlInputText) uiComponent;
+                inputText = (HtmlInputTextHelp) uiComponent;
                 break;
             }
         }
 
         if(inputText == null)
         {
-            inputText = (HtmlInputText) application.createComponent(HtmlInputText.COMPONENT_TYPE);
+            inputText = (HtmlInputTextHelp) application.createComponent(HtmlInputTextHelp.COMPONENT_TYPE);
         }
         return inputText;
     }
@@ -500,7 +507,7 @@
 
         String clientVar = JavascriptUtils.getValidJavascriptName(clientId+"CalendarVar",true);
 
-        String jsCalendarFunctionCall = clientVar+"._popUpCalendar(this,document.getElementById(\\'"+clientId+"\\'),\\'"+dateFormat+"\\')";
+        String jsCalendarFunctionCall = "document.getElementById(\\'"+clientId+"\\').value=\\'\\'; "+clientVar+"._popUpCalendar(this,document.getElementById(\\'"+clientId+"\\'),\\'"+dateFormat+"\\')";
         writer.writeAttribute(HTML.ONCLICK_ATTR, jsCalendarFunctionCall, null);
     }
 

Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/resource/popcalendar.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/resource/popcalendar.js?rev=358294&r1=358293&r2=358294&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/resource/popcalendar.js (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/resource/popcalendar.js Wed Dec 21 06:11:52 2005
@@ -198,7 +198,7 @@
     this.bShow = false;
 }
 
-org_apache_myfaces_PopupCalendar.prototype.init=function(){
+org_apache_myfaces_PopupCalendar.prototype.init=function(containerCtl){
     if (this.dom){
 
         if(!this.calendarDiv)
@@ -206,7 +206,7 @@
             for	(i=0;i<this.imgSrc.length;i++)
                 this.img[i] = new Image;
 
-            var bodyTag = document.getElementsByTagName("body")[0];
+            var bodyTag = containerCtl;
 
             this.calendarDiv = document.createElement("div");
             this.calendarDiv.className=this.initData.themePrefix+"-div-style";
@@ -1280,3 +1280,4 @@
 	  return str;
 
 }
+

Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/resource/pt.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/resource/pt.js?rev=358294&r1=358293&r2=358294&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/resource/pt.js (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/calendar/resource/pt.js Wed Dec 21 06:11:52 2005
@@ -1782,4 +1782,4 @@
 
     return [valueL, valueT];
   }
-}
\ No newline at end of file
+}