You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sv...@apache.org on 2004/12/03 13:55:30 UTC

cvs commit: incubator-myfaces/src/components/org/apache/myfaces/custom/htmlEditor/resource myFacesUtils.js

svieujot    2004/12/03 04:55:30

  Modified:    src/components/org/apache/myfaces/custom/htmlEditor
                        HtmlEditorRenderer.java
               webapps/examples/web htmlEditor.jsp
               src/components/org/apache/myfaces/custom/htmlEditor/resource
                        myFacesUtils.js
  Log:
  Get ride of the save button / process.
  
  Revision  Changes    Path
  1.3       +17 -21    incubator-myfaces/src/components/org/apache/myfaces/custom/htmlEditor/HtmlEditorRenderer.java
  
  Index: HtmlEditorRenderer.java
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/src/components/org/apache/myfaces/custom/htmlEditor/HtmlEditorRenderer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HtmlEditorRenderer.java	3 Dec 2004 08:31:28 -0000	1.2
  +++ HtmlEditorRenderer.java	3 Dec 2004 12:55:30 -0000	1.3
  @@ -19,6 +19,7 @@
   import java.util.Map;
   
   import javax.faces.component.UIComponent;
  +import javax.faces.component.UIForm;
   import javax.faces.context.FacesContext;
   import javax.faces.context.ResponseWriter;
   import javax.faces.render.Renderer;
  @@ -32,6 +33,9 @@
    * @author Sylvain Vieujot (latest modification by $Author$)
    * @version $Revision$ $Date$
    * $Log$
  + * Revision 1.3  2004/12/03 12:55:30  svieujot
  + * Get ride of the save button / process.
  + *
    * Revision 1.2  2004/12/03 08:31:28  manolito
    * writer.append copy'n'paste error?
    *
  @@ -46,6 +50,15 @@
           RendererUtils.checkParamValidity(context, component, HtmlEditor.class);
           HtmlEditor editor = (HtmlEditor) component;
           String clientId = editor.getClientId(context);
  +        String formId;
  +        {
  +            UIComponent tmpComponent = editor.getParent();
  +            while(!(tmpComponent instanceof UIForm) ){
  +                tmpComponent = tmpComponent.getParent();
  +            }
  +            formId = tmpComponent.getClientId(context);
  +        }
  +            
           
           AddResource.addStyleSheet(HtmlEditorRenderer.class, "kupustyles.css", context);
           AddResource.addStyleSheet(HtmlEditorRenderer.class, "kupudrawerstyles.css", context);
  @@ -128,24 +141,7 @@
       					writer.write(" ");
                 		writer.endElement(HTML.BUTTON_ELEM);
               	writer.endElement(HTML.SPAN_ELEM);
  -            	
  -            	// Save button
  -            	// TODO : Remove the need for this button
  -            	writer.startElement(HTML.SPAN_ELEM,null);
  -				writer.writeAttribute(HTML.CLASS_ATTR, "kupu-tb-buttongroup",null);
  -					writer.startElement(HTML.BUTTON_ELEM,null);
  -					writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null);
  -					writer.writeAttribute(HTML.TYPE_ATTR, "button", null);
  -					writer.writeAttribute(HTML.CLASS_ATTR, "kupu-save", null);
  -					writer.writeAttribute(HTML.ID_ATTR, "kupu-save-button", null);
  -					writer.writeAttribute(HTML.TITLE_ATTR, "Save", null);
  -					writer.writeAttribute("i18n:attributes", "title", null);
  -					writer.writeAttribute(HTML.ACCESSKEY_ATTR, "s", null);
  -					writer.writeAttribute(HTML.ONCLICK_ATTR, "kupu.prepareForm(this.form, '"+clientId+"');", null);
  -						writer.write(" ");
  -					writer.endElement(HTML.BUTTON_ELEM);
  -                writer.endElement(HTML.SPAN_ELEM);
  -            	
  +
               	writer.startElement(HTML.SELECT_ELEM,null);
               	writer.writeAttribute(HTML.ID_ATTR, "kupu-tb-styles",null);
               		writer.startElement(HTML.OPTION_ELEM,null);
  @@ -834,7 +830,7 @@
           AddResource.addJavaScriptToHeader(HtmlEditorRenderer.class, "myFacesUtils.js", context);
           writer.startElement(HTML.SCRIPT_ELEM, null);
           writer.writeAttribute(HTML.SCRIPT_LANGUAGE_ATTR, HTML.SCRIPT_LANGUAGE_JAVASCRIPT, null);
  -        	writer.write("myFacesKupuSet(\""+encodedText+"\");");
  +        	writer.write("myFacesKupuSet(\""+encodedText+"\",\""+clientId+"\",\""+formId+"\");");
           writer.endElement(HTML.SCRIPT_ELEM);
       }
       
  
  
  
  1.2       +0 -6      incubator-myfaces/webapps/examples/web/htmlEditor.jsp
  
  Index: htmlEditor.jsp
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/web/htmlEditor.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- htmlEditor.jsp	2 Dec 2004 22:28:30 -0000	1.1
  +++ htmlEditor.jsp	3 Dec 2004 12:55:30 -0000	1.2
  @@ -59,12 +59,6 @@
   				<h:form>
   					<x:htmlEditor value="#{editor.text}"/>
   					<h:commandButton value="Submit"/>
  -					<f:verbatim>
  -						<p><i>
  -							Note : You need to press the Save button before submiting.<br/>
  -							This need will hopefully be removed in a future version.
  -						</i></p>
  -					</f:verbatim>
   				</h:form>
   
               </h:panelGroup>
  
  
  
  1.2       +18 -3     incubator-myfaces/src/components/org/apache/myfaces/custom/htmlEditor/resource/myFacesUtils.js
  
  Index: myFacesUtils.js
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/src/components/org/apache/myfaces/custom/htmlEditor/resource/myFacesUtils.js,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- myFacesUtils.js	2 Dec 2004 22:28:28 -0000	1.1
  +++ myFacesUtils.js	3 Dec 2004 12:55:30 -0000	1.2
  @@ -19,10 +19,14 @@
    * @version $Revision$ $Date$
    */
   var myFacesKupuTextToLoad;
  -var myFacesKupuOriginalDocOnLoad;
  +var myFacesKupuClientId;
  +var myFacesKupuFormId;
  +var myFacesKupuOriginalDocOnSubmit;
   
  -function myFacesKupuSet(text) {
  +function myFacesKupuSet(text, clientId, formId){
   	myFacesKupuTextToLoad = text;
  +	myFacesKupuClientId = clientId;
  +	myFacesKupuFormId = formId;
   	
   	var onLoadSrc;
       if( document.all ) // IE
  @@ -32,6 +36,10 @@
   
   	myFacesKupuOriginalDocOnLoad = onLoadSrc.onload;
   	onLoadSrc.onload = myFacesKupuInit;
  +	
  +	var form = document.forms[myFacesKupuFormId];
  +	myFacesKupuOriginalDocOnSubmit = form.onsubmit;
  +	form.onsubmit = myFacesKupuSubmit;
   }
   
   function myFacesKupuInit(){
  @@ -40,4 +48,11 @@
   
   	kupu = startKupu();
   	kupu.getInnerDocument().documentElement.getElementsByTagName('body')[0].innerHTML = myFacesKupuTextToLoad;
  +}
  +
  +function myFacesKupuSubmit(){
  +	kupu.prepareForm(document.forms[myFacesKupuFormId], myFacesKupuClientId);
  +
  +	if( myFacesKupuOriginalDocOnSubmit )
  +		return myFacesKupuOriginalDocOnSubmit();
   }