Author: jkuhnert
Date: Mon Oct 23 07:42:12 2006
New Revision: 467005

URL: http://svn.apache.org/viewvc?view=rev&rev=467005
Log:
Added new InlineEditBox

Added:
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/InlineEditBox.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/InlineEditBox.jwc
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/InlineEditBox.script
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/WidgetMessages.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/WidgetMessages.properties
Modified:
    
tapestry/tapestry4/trunk/tapestry-annotations/src/java/org/apache/tapestry/annotations/EventListener.java
    tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/Home.html
    
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/dao/ProjectDao.java
    
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/ComponentEvent.script
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/Framework.library
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/IDirect.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/ScriptUtils.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/InlineEditBox.js
    tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js

Modified: 
tapestry/tapestry4/trunk/tapestry-annotations/src/java/org/apache/tapestry/annotations/EventListener.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-annotations/src/java/org/apache/tapestry/annotations/EventListener.java?view=diff&rev=467005&r1=467004&r2=467005
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-annotations/src/java/org/apache/tapestry/annotations/EventListener.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-annotations/src/java/org/apache/tapestry/annotations/EventListener.java
 Mon Oct 23 07:42:12 2006
@@ -4,7 +4,7 @@
 // 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
+// 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,
@@ -20,52 +20,54 @@
 import java.lang.annotation.Target;
 
 /**
- * Annotation used to connect an event on a component / page 
- * with a particular listener method. This is currently intended
- * to be used to connect client side events to listener methods but
- * may have uses elsewhere.
+ * Annotation used to connect an event on a component / page with a particular 
listener method. This
+ * is currently intended to be used to connect client side events to listener 
methods but may have
+ * uses elsewhere.
  * 
  * @author jkuhnert
  */
[EMAIL PROTECTED]({ ElementType.METHOD })
[EMAIL PROTECTED]( { ElementType.METHOD })
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
 public @interface EventListener
 {
+
     /**
-     * The unique [EMAIL PROTECTED] IComponent} ids of the targeted 
-     * sources that this listener will be listening to events on. 
+     * The unique [EMAIL PROTECTED] IComponent} ids of the targeted sources 
that this listener will be
+     * listening to events on.
      */
     String[] targets() default {};
-    
+
     /**
      * The unique html element ids to listen to the events on.
      */
     String[] elements() default {};
-    
+
     /**
-     * The list of events that should cause this listener to invoke. 
-     * Ie <code>events = {"onClick", "onOptionSelect"}</code> etc..
+     * The list of events that should cause this listener to invoke. Ie
+     * <code>events = {"onClick", "onOptionSelect"}</code> etc..
      */
     String[] events();
-    
+
     /**
-     * The form id of the form that should have its data submitted when one 
-     * of the specified events is triggered.
+     * The form id of the form that should have its data submitted when one of 
the specified events
+     * is triggered.
+     * 
      * @return
      */
     String submitForm() default "";
-    
+
     /**
-     * Whether or not to perform form validation if the [EMAIL PROTECTED] 
#form()} parameter has 
-     * been set. Default is false.
+     * Whether or not to perform form validation if the [EMAIL PROTECTED] 
#form()} parameter has been set.
+     * Default is false.
+     * 
      * @return
      */
     boolean validateForm() default false;
-    
+
     /**
-     * If used in conjunction with [EMAIL PROTECTED] #submitForm()}, will 
either submit the form
-     * normally or asynchronously. Default is asyncrhonous. 
+     * If used in conjunction with [EMAIL PROTECTED] #submitForm()}, will 
either submit the form normally or
+     * asynchronously. Default is asyncrhonous.
      * 
      * @return True if form should be submitted asynchronously, false 
otherwise.
      */

Modified: 
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/Home.html
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/Home.html?view=diff&rev=467005&r1=467004&r2=467005
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/Home.html 
(original)
+++ 
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/Home.html 
Mon Oct 23 07:42:12 2006
@@ -66,7 +66,7 @@
 
 <div jwcid="[EMAIL PROTECTED]" >
        <h2 jwcid="@If" condition="ognl:selectedProject" style="clear:left" >
-               <span jwcid="@Insert" value="ognl:selectedProject.name" />
+               <span jwcid="[EMAIL PROTECTED]" 
value="ognl:selectedProject.name" />
        </h2>
 </div>
 

Modified: 
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/dao/ProjectDao.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/dao/ProjectDao.java?view=diff&rev=467005&r1=467004&r2=467005
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/dao/ProjectDao.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/dao/ProjectDao.java
 Mon Oct 23 07:42:12 2006
@@ -70,4 +70,29 @@
             try { if (ps != null) ps.close(); } catch (Exception e) { }
         }
     }
+    
+    /**
+     * Updates the specified project.
+     * @param p The project to update.
+     */
+    public void update(Project p)
+    {
+        PreparedStatement ps = null;
+        
+        try {
+            
+            ps = _conn.prepareStatement("update projects set name = ? where 
project_id = ?");
+            
+            int x=0;
+            ps.setString(++x, p.getName());
+            ps.setLong(++x, p.getId());
+            
+            ps.executeUpdate();
+            
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        } finally {
+            try { if (ps != null) ps.close(); } catch (Exception e) { }
+        }
+    }
 }

Modified: 
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java?view=diff&rev=467005&r1=467004&r2=467005
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java
 Mon Oct 23 07:42:12 2006
@@ -42,8 +42,7 @@
  * @author jkuhnert
  */
 public abstract class TaskEntryPage extends BasePage
-{
-    
+{   
     private static final Logger _log = Logger.getLogger(TaskEntryPage.class);
     
     @Component(id = "projectChoose", bindings = { "model=projectModel", 
"value=selectedProject",
@@ -128,4 +127,9 @@
         getTaskDao().addTask(task);
     }
     
+    @EventListener(events = "onSave", targets="projName")
+    public void onNameUpdate()
+    {
+        getProjectDao().update(getSelectedProject());
+    }
 }

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/ComponentEvent.script
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/ComponentEvent.script?view=diff&rev=467005&r1=467004&r2=467005
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/ComponentEvent.script
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/ComponentEvent.script
 Mon Oct 23 07:42:12 2006
@@ -20,7 +20,9 @@
                 tapestry.event${event[1]}=function(e){
                     var content={beventname:"${event[0]}"};
                     tapestry.event.buildEventProperties(e, content);
-                    if (!content["beventtarget.id"]) 
content["beventtarget.id"]="${clientId}";
+                    if (!content["beventtarget.id"]) {
+                       content["beventtarget.id"]="${clientId}";
+                    }
                     tapestry.bind("${url}", content);
                 };
                 dojo.event.connect(dojo.byId("${clientId}"), "${event[0]}", 
tapestry, "event${event[1]}");
@@ -33,7 +35,9 @@
                 tapestry.formEvent${formEvent[4]}=function(e){
                     var content={beventname:"${formEvent[0]}"};
                     tapestry.event.buildEventProperties(e, content);
-                    if (!content["beventtarget.id"]) 
content["beventtarget.id"]="${clientId}";
+                    if (!content["beventtarget.id"]){
+                       content["beventtarget.id"]="${clientId}";
+                    }
                     
                     <foreach expression="formEvent[1]" key="formName">
                    var 
validateState=tapestry.form.forms["${formName}"].validateForm;

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/Framework.library
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/Framework.library?view=diff&rev=467005&r1=467004&r2=467005
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/Framework.library
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/Framework.library
 Mon Oct 23 07:42:12 2006
@@ -57,6 +57,7 @@
     <component-type type="If" specification-path="components/If.jwc"/>
     <component-type type="Image" specification-path="html/Image.jwc"/>
     <component-type type="ImageSubmit" 
specification-path="form/ImageSubmit.jwc"/>
+    <component-type type="InlineEditBox" 
specification-path="dojo/html/InlineEditBox.jwc" />
        <component-type type="Insert" 
specification-path="components/Insert.jwc"/>
     <component-type type="InsertText" 
specification-path="html/InsertText.jwc"/>
     <component-type type="InvokeListener" 
specification-path="components/InvokeListener.jwc"/>

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/IDirect.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/IDirect.java?view=diff&rev=467005&r1=467004&r2=467005
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/IDirect.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/IDirect.java
 Mon Oct 23 07:42:12 2006
@@ -25,7 +25,7 @@
 public interface IDirect extends IComponent, IDynamicInvoker
 {
     /**
-     *  Invoked by the direct service to have the component peform
+     *  Invoked by the direct service to have the component perform
      *  the appropriate action.  The [EMAIL PROTECTED] 
org.apache.tapestry.link.DirectLink} component will
      *  notify its listener.
      *

Added: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/InlineEditBox.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/InlineEditBox.java?view=auto&rev=467005
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/InlineEditBox.java
 (added)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/InlineEditBox.java
 Mon Oct 23 07:42:12 2006
@@ -0,0 +1,178 @@
+// Copyright 2004, 2005 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.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package org.apache.tapestry.dojo.html;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.hivemind.ApplicationRuntimeException;
+import org.apache.tapestry.IDirect;
+import org.apache.tapestry.IMarkupWriter;
+import org.apache.tapestry.IRequestCycle;
+import org.apache.tapestry.IScript;
+import org.apache.tapestry.PageRenderSupport;
+import org.apache.tapestry.TapestryUtils;
+import org.apache.tapestry.dojo.AbstractWidget;
+import org.apache.tapestry.engine.DirectServiceParameter;
+import org.apache.tapestry.engine.IEngineService;
+import org.apache.tapestry.json.JSONObject;
+
+
+/**
+ * Wraps a dojo InlineEditBox widget. 
+ * 
+ * <p>
+ * Manages a single string value that when hovered over can be edited "inline" 
in the document
+ * wherever it is referenced. Supports various modes of operation (ie 
disable/enabled), as well as 
+ * textarea or single line style edits.
+ * </p>
+ *
+ *
+ * <p>
+ * Some of the commonly used widget functions to listen to are:<br/>
+ * <ul>
+ *  <li><b>onSave - </b>When the save button is clicked. Default function 
listened to when updating
+ *  server side managed value.
+ *  </li>
+ *  <li><b>onUndo - </b>When cancel button is clicked.</li>
+ *  <li><b>onMouseOver - </b>Mouse moved over editable region.</li>
+ *  <li><b>onMouseOut - </b>Mouse moved away from editable region.</li>
+ * </ul>
+ * </p>
+ * 
+ * @author Jesse Kuhnert
+ */
+public abstract class InlineEditBox extends AbstractWidget implements IDirect
+{
+    /** 
+     * Default single line editing text mode. Use as one of two possible
+     * parameters to the <code>mode</code> parameter.
+     */
+    public static final String TEXT_MODE = "text";
+    
+    /** 
+     * Multi line editing text mode. Use as one of two possible
+     * parameters to the <code>mode</code> parameter.
+     */
+    public static final String TEXT_AREA_MODE = "textarea";
+    
+    public abstract String getValue();
+    public abstract void setValue(String value);
+    
+    public abstract String getMode();
+    
+    public abstract int getMinWidth();
+    
+    public abstract int getMinHeight();
+    
+    public abstract boolean getDoFade();
+    
+    public abstract boolean isDiabled();
+    
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public void renderWidget(IMarkupWriter writer, IRequestCycle cycle)
+    {
+        if (!cycle.isRewinding()) {
+            
+            writer.begin(getTemplateTagName()); // use whatever template tag 
they specified
+            
+            renderInformalParameters(writer, cycle);
+            
+            renderIdAttribute(writer, cycle);
+        }
+        
+        renderBody(writer, cycle);
+        
+        if (!cycle.isRewinding()) {
+            
+            writer.end();
+        }
+        
+        if(!TEXT_MODE.equals(getMode())
+                && !TEXT_AREA_MODE.equals(getMode())) {
+            throw new 
ApplicationRuntimeException(WidgetMessages.invalidTextMode(getMode()));
+        }
+        
+        JSONObject prop = new JSONObject();
+        prop.put("widgetId", getClientId());
+        prop.put("textValue", getValue());
+        prop.put("mode", getMode());
+        prop.put("minWidth", getMinWidth());
+        prop.put("minHeight", getMinHeight());
+        prop.put("doFade", getDoFade());
+        
+        Map parms = new HashMap();
+        parms.put("component", this);
+        parms.put("props", prop.toString());
+        
+        PageRenderSupport prs = TapestryUtils.getPageRenderSupport(cycle, 
this);
+        getScript().execute(this, cycle, prs, parms);
+    }
+    
+    /**
+     * Callback url used by client side widget to update server component.
+     * @return
+     */
+    public String getUpdateUrl()
+    {
+        DirectServiceParameter dsp =
+            new DirectServiceParameter(this, new Object[]{});
+        
+        return getEngine().getLink(true, dsp).getURL();
+    }
+    
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public List getUpdateComponents()
+    {
+        return Collections.EMPTY_LIST;
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public boolean isAsync()
+    {
+        return true;
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public boolean isJson()
+    {
+        return false;
+    }
+    
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public void trigger(IRequestCycle cycle)
+    {
+        String newValue = cycle.getParameter(getClientId());
+        
+        setValue(newValue);
+    }
+    
+    /** Injected. */
+    public abstract IEngineService getEngine();
+    
+    /** Injected. */
+    public abstract IScript getScript();
+}

Added: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/InlineEditBox.jwc
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/InlineEditBox.jwc?view=auto&rev=467005
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/InlineEditBox.jwc
 (added)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/InlineEditBox.jwc
 Mon Oct 23 07:42:12 2006
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 
+   Copyright 2004, 2005, 2006 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.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
+<!DOCTYPE component-specification PUBLIC
+        "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
+        "http://tapestry.apache.org/dtd/Tapestry_4_0.dtd";>
+
+<component-specification class="org.apache.tapestry.dojo.html.InlineEditBox"
+                         allow-body="yes" allow-informal-parameters="yes">
+
+    <description>
+        Creates an inline editable textbox/textarea.
+    </description>
+    
+    <parameter name="value" required="yes" />
+    
+    <parameter name="mode" default-value="literal:text" />
+    
+    <parameter name="minWidth" default-value="100" />
+    
+    <parameter name="minHeight" default-value="200" />
+    
+    <parameter name="doFade" default-value="false" />
+    
+    <parameter name="disabled" default-value="false" />
+    
+    <inject property="engine" object="service:tapestry.services.Direct"/>
+    
+    <inject property="script" type="script" object="InlineEditBox.script"/>
+
+</component-specification>

Added: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/InlineEditBox.script
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/InlineEditBox.script?view=auto&rev=467005
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/InlineEditBox.script
 (added)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/InlineEditBox.script
 Mon Oct 23 07:42:12 2006
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+<!DOCTYPE script PUBLIC
+  "-//Apache Software Foundation//Tapestry Script Specification 3.0//EN"
+  "http://tapestry.apache.org/dtd/Script_3_0.dtd";>
+<!-- 
+   Copyright 2004, 2005, 2006 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.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<script>
+
+<input-symbol key="component" required="yes" />
+<input-symbol key="props" required="yes" />
+    <initialization>
+    tapestry.widget.synchronizeWidgetState("${component.clientId}", 
"InlineEditBox", ${props}, ${component.destroy});
+    
+    var w=dojo.widget.byId("${component.clientId}");
+    <if-not expression="component.disabled">
+        w.enable();
+    </if-not><if expression="component.disabled">
+        w.disable();
+    </if>
+    
+    <if expression="component.destroy">
+    dojo.event.connectOnce(w, "onSave", function(newValue, oldValue){
+       tapestry.bind("${component.updateUrl}", 
{"${component.clientId}":newValue}, true);
+    });
+    </if>
+    </initialization>
+</script>

Added: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/WidgetMessages.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/WidgetMessages.java?view=auto&rev=467005
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/WidgetMessages.java
 (added)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/WidgetMessages.java
 Mon Oct 23 07:42:12 2006
@@ -0,0 +1,34 @@
+// Copyright 2004, 2005 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.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package org.apache.tapestry.dojo.html;
+
+import org.apache.hivemind.impl.MessageFormatter;
+
+
+/**
+ * Provides error message formatting functions for the dojo html 
+ * widget component package.
+ */
+public final class WidgetMessages
+{
+    protected static final MessageFormatter _formatter = new 
MessageFormatter(WidgetMessages.class);
+    
+    /* defeat instantiation */
+    private WidgetMessages() { }
+    
+    public static String invalidTextMode(String value)
+    {
+        return _formatter.format("invalid-text-mode", value);
+    }
+}

Added: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/WidgetMessages.properties
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/WidgetMessages.properties?view=auto&rev=467005
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/WidgetMessages.properties
 (added)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/WidgetMessages.properties
 Mon Oct 23 07:42:12 2006
@@ -0,0 +1,15 @@
+# Copyright 2006 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.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+invalid-text-mode=Text mode specified invalid: {0}. Valid mode options are 
"text" or "textarea".

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/ScriptUtils.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/ScriptUtils.java?view=diff&rev=467005&r1=467004&r2=467005
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/ScriptUtils.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/ScriptUtils.java
 Mon Oct 23 07:42:12 2006
@@ -1,4 +1,4 @@
-// Copyright May 8, 2006 The Apache Software Foundation
+// Copyright May 8, 2006 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.

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/InlineEditBox.js
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/InlineEditBox.js?view=diff&rev=467005&r1=467004&r2=467005
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/InlineEditBox.js
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/InlineEditBox.js
 Mon Oct 23 07:42:12 2006
@@ -1,5 +1,3 @@
-
-
 dojo.provide("dojo.widget.InlineEditBox");
 
 dojo.require("dojo.widget.*");
@@ -11,194 +9,201 @@
 dojo.require("dojo.html.layout");
 
 dojo.widget.defineWidget(
-"dojo.widget.InlineEditBox",
-dojo.widget.HtmlWidget,
-function(){
-// mutable objects need to be in constructor to give each instance its own copy
-this.history = [];
-},
+       "dojo.widget.InlineEditBox",
+       dojo.widget.HtmlWidget,
+       function(){
+               // mutable objects need to be in constructor to give each 
instance its own copy
+               this.history = [];
+       },
 {
-templatePath: dojo.uri.dojoUri("src/widget/templates/InlineEditBox.html"),
-templateCssPath: dojo.uri.dojoUri("src/widget/templates/InlineEditBox.css"),
-
-form: null,
-editBox: null,
-edit: null,
-text: null,
-textarea: null,
-submitButton: null,
-cancelButton: null,
-mode: "text",
-name: "",
-
-minWidth: 100, //px. minimum width of edit box
-minHeight: 200, //px. minimum width of edit box, if it's a TA
-
-editing: false,
-textValue: "",
-defaultText: "",
-doFade: false,
-
-onSave: function(newValue, oldValue, name){},
-onUndo: function(value){},
-
-postCreate: function(args, frag){
-// put original node back in the document, and attach handlers
-// which hide it and display the editor
-this.editable = this.getFragNodeRef(frag);
-dojo.html.insertAfter(this.editable, this.form);
-dojo.event.connect(this.editable, "onmouseover", this, "onMouseOver");
-dojo.event.connect(this.editable, "onmouseout", this, "onMouseOut");
-dojo.event.connect(this.editable, "onclick", this, "beginEdit");
-
-this.textValue = dojo.string.trim(this.editable.innerHTML);
-if(dojo.string.trim(this.textValue).length == 0){
-this.editable.innerHTML = this.defaultText;
-}
-},
-
-onMouseOver: function(){
-if(!this.editing){
-if (!this.isEnabled){
-dojo.html.addClass(this.editable, "editableRegionDisabled");
-} else {
-dojo.html.addClass(this.editable, "editableRegion");
-if(this.mode == "textarea"){
-dojo.html.addClass(this.editable, "editableTextareaRegion");
-}
-}
-}
-
-this.mouseover();
-},
-
-mouseover: function(e){
-// TODO: How do we deprecate a function without going into overkill with debug 
statements?
-// dojo.deprecated("onMouseOver should be used instead of mouseover to listen 
for mouse events");
-},
-
-onMouseOut: function(){
-if(!this.editing){
-dojo.html.removeClass(this.editable, "editableRegion");
-dojo.html.removeClass(this.editable, "editableTextareaRegion");
-dojo.html.removeClass(this.editable, "editableRegionDisabled");
-}
-
-this.mouseout();
-},
-
-mouseout: function(e){
-// dojo.deprecated("onMouseOut should be used instead of mouseout to listen 
for mouse events");
-},
-
-
-
-beginEdit: function(e){
-if(this.editing || !this.isEnabled){ return; }
-this.onMouseOut();
-this.editing = true;
-
-// setup the form's <input> or <textarea> field, as specified by mode
-var ee = this[this.mode.toLowerCase()];
-ee.value = dojo.string.trim(this.textValue);
-ee.style.fontSize = dojo.html.getStyle(this.editable, "font-size");
-ee.style.fontWeight = dojo.html.getStyle(this.editable, "font-weight");
-ee.style.fontStyle = dojo.html.getStyle(this.editable, "font-style");
-var bb = dojo.html.getBorderBox(this.editable);
-ee.style.width = Math.max(bb.width, this.minWidth) + "px";
-if(this.mode.toLowerCase()=="textarea"){
-ee.style.display = "block";
-ee.style.height = Math.max(bb.height, this.minHeight) + "px";
-} else {
-ee.style.display = "";
-}
-
-// show the edit form and hide the read only version of the text
-this.form.style.display = "";
-this.editable.style.display = "none";
-
-ee.focus();
-ee.select();
-this.submitButton.disabled = true;
-},
-
-saveEdit: function(e){
-e.preventDefault();
-e.stopPropagation();
-var ee = this[this.mode.toLowerCase()];
-if((this.textValue != ee.value)&&
-(dojo.string.trim(ee.value) != "")){
-this.doFade = true;
-this.history.push(this.textValue);
-this.onSave(ee.value, this.textValue, this.name);
-this.textValue = ee.value;
-this.editable.innerHTML = "";
-var textNode = document.createTextNode( this.textValue );
-this.editable.appendChild( textNode );
-}else{
-this.doFade = false;
-}
-this.finishEdit(e);
-},
-
-cancelEdit: function(e){
-if(!this.editing){ return false; }
-this.editing = false;
-this.form.style.display="none";
-this.editable.style.display = "";
-return true;
-},
-
-finishEdit: function(e){
-if(!this.cancelEdit(e)){ return; }
-if(this.doFade) {
-dojo.lfx.highlight(this.editable, dojo.gfx.color.hex2rgb("#ffc"), 
700).play(300);
-}
-this.doFade = false;
-},
-
-setText: function(txt){
-// sets the text without informing the server
-txt = "" + txt;
-var tt = dojo.string.trim(txt);
-this.textValue = tt
-this.editable.innerHTML = tt;
-},
-
-undo: function(){
-if(this.history.length > 0){
-var curValue = this.textValue;
-var value = this.history.pop();
-this.editable.innerHTML = value;
-this.textValue = value;
-this.onUndo(value);
-this.onSave(value, curValue, this.name);
-}
-},
-
-checkForValueChange: function(){
-var ee = this[this.mode.toLowerCase()];
-if((this.textValue != ee.value)&&
-(dojo.string.trim(ee.value) != "")){
-this.submitButton.disabled = false;
-}
-},
-
-disable: function(){
-this.submitButton.disabled = true;
-this.cancelButton.disabled = true;
-var ee = this[this.mode.toLowerCase()];
-ee.disabled = true;
-
-dojo.widget.Widget.prototype.disable.call(this);
-},
-
-enable: function(){
-this.checkForValueChange();
-this.cancelButton.disabled = false;
-var ee = this[this.mode.toLowerCase()];
-ee.disabled = false;
+       templatePath: 
dojo.uri.dojoUri("src/widget/templates/InlineEditBox.html"),
+       templateCssPath: 
dojo.uri.dojoUri("src/widget/templates/InlineEditBox.css"),
 
-dojo.widget.Widget.prototype.enable.call(this);
-}
+       form: null,
+       editBox: null,
+       edit: null,
+       text: null,
+       textarea: null,
+       submitButton: null,
+       cancelButton: null,
+       mode: "text",
+       name: "",
+       
+       minWidth: 100, //px. minimum width of edit box
+       minHeight: 200, //px. minimum width of edit box, if it's a TA
+
+       editing: false,
+       textValue: "",
+       defaultText: "",
+       doFade: false,
+       
+       onSave: function(newValue, oldValue, name){},
+       onUndo: function(value){},
+
+       postCreate: function(args, frag){
+               // put original node back in the document, and attach handlers
+               // which hide it and display the editor
+               this.editable = this.getFragNodeRef(frag);
+               dojo.html.insertAfter(this.editable, this.form);
+               dojo.event.connect(this.editable, "onmouseover", this, 
"onMouseOver");
+               dojo.event.connect(this.editable, "onmouseout", this, 
"onMouseOut");
+               dojo.event.connect(this.editable, "onclick", this, "beginEdit");
+               
+               // first see if a textValue was provided in parameters
+               if(dojo.string.trim(this.textValue).length > 0){
+                       this.editable.innerHTML = this.textValue;
+                       return;
+               }
+               // go hunting
+               var text = dojo.string.trim(this.editable.innerHTML);
+               if(dojo.string.trim(text).length == 0){
+                       this.textValue=this.defaultText;
+                       this.editable.innerHTML = this.textValue;
+               }               
+       },
+       
+       onMouseOver: function(){
+               if(!this.editing){
+                       if (!this.isEnabled){
+                               dojo.html.addClass(this.editable, 
"editableRegionDisabled");
+                       } else {
+                               dojo.html.addClass(this.editable, 
"editableRegion");
+                               if(this.mode == "textarea"){
+                                       dojo.html.addClass(this.editable, 
"editableTextareaRegion");
+                               }
+                       }
+               }
+               
+               this.mouseover();
+       },
+       
+       mouseover: function(e){
+               // TODO: How do we deprecate a function without going into 
overkill with debug statements?
+               // dojo.deprecated("onMouseOver should be used instead of 
mouseover to listen for mouse events");
+       },
+       
+       onMouseOut: function(){
+               if(!this.editing){
+                       dojo.html.removeClass(this.editable, "editableRegion");
+                       dojo.html.removeClass(this.editable, 
"editableTextareaRegion");
+                       dojo.html.removeClass(this.editable, 
"editableRegionDisabled");
+               }
+               
+               this.mouseout();
+       },
+       
+       mouseout: function(e){
+               // dojo.deprecated("onMouseOut should be used instead of 
mouseout to listen for mouse events");
+       },
+
+       // When user clicks the text, then start editing.
+       // Hide the text and display the form instead.
+       beginEdit: function(e){
+               if(this.editing || !this.isEnabled){ return; }
+               this.onMouseOut();
+               this.editing = true;
+
+               // setup the form's <input> or <textarea> field, as specified 
by mode
+               var ee = this[this.mode.toLowerCase()];
+               ee.value = dojo.string.trim(this.textValue);
+               ee.style.fontSize = dojo.html.getStyle(this.editable, 
"font-size");
+               ee.style.fontWeight = dojo.html.getStyle(this.editable, 
"font-weight");
+               ee.style.fontStyle = dojo.html.getStyle(this.editable, 
"font-style");
+               var bb = dojo.html.getBorderBox(this.editable);
+               ee.style.width = Math.max(bb.width, this.minWidth) + "px";
+               if(this.mode.toLowerCase()=="textarea"){
+                       ee.style.display = "block";
+                       ee.style.height = Math.max(bb.height, this.minHeight) + 
"px";
+               } else {
+                       ee.style.display = "";
+               }
+
+               // show the edit form and hide the read only version of the text
+               this.form.style.display = "";
+               this.editable.style.display = "none";
+
+               ee.focus();
+               ee.select();
+               this.submitButton.disabled = true;
+       },
+
+       saveEdit: function(e){
+               e.preventDefault();
+               e.stopPropagation();
+               var ee = this[this.mode.toLowerCase()];
+               if((this.textValue != ee.value)&&
+                       (dojo.string.trim(ee.value) != "")){
+                       this.doFade = true;
+                       this.history.push(this.textValue);
+                       this.onSave(ee.value, this.textValue, this.name);
+                       this.textValue = ee.value;
+                       this.editable.innerHTML = "";
+                       var textNode = document.createTextNode( this.textValue 
);
+                       this.editable.appendChild( textNode );
+               }else{
+                       this.doFade = false;
+               }
+               this.finishEdit(e);
+       },
+
+       cancelEdit: function(e){
+               if(!this.editing){ return false; }
+               this.editing = false;
+               this.form.style.display="none";
+               this.editable.style.display = "";
+               return true;
+       },
+
+       finishEdit: function(e){
+               if(!this.cancelEdit(e)){ return; }
+               if(this.doFade) {
+                       dojo.lfx.highlight(this.editable, 
dojo.gfx.color.hex2rgb("#ffc"), 700).play(300);
+               }
+               this.doFade = false;
+       },
+       
+       setText: function(txt){
+               // sets the text without informing the server
+               txt = "" + txt;
+               var tt = dojo.string.trim(txt);
+               this.textValue = tt
+               this.editable.innerHTML = tt;
+       },
+
+       undo: function(){
+               if(this.history.length > 0){
+                       var curValue = this.textValue;
+                       var value = this.history.pop();
+                       this.editable.innerHTML = value;
+                       this.textValue = value;
+                       this.onUndo(value);
+                       this.onSave(value, curValue, this.name);
+               }
+       },
+
+       checkForValueChange: function(){
+               var ee = this[this.mode.toLowerCase()];
+               if((this.textValue != ee.value)&&
+                       (dojo.string.trim(ee.value) != "")){
+                       this.submitButton.disabled = false;
+               }
+       },
+       
+       disable: function(){
+               this.submitButton.disabled = true;
+               this.cancelButton.disabled = true;
+               var ee = this[this.mode.toLowerCase()];
+               ee.disabled = true;
+               
+               dojo.widget.Widget.prototype.disable.call(this);
+       },
+       
+       enable: function(){
+               this.checkForValueChange();
+               this.cancelButton.disabled = false;
+               var ee = this[this.mode.toLowerCase()];
+               ee.disabled = false;
+               
+               dojo.widget.Widget.prototype.enable.call(this);
+       }
 });

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js?view=diff&rev=467005&r1=467004&r2=467005
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js 
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js Mon Oct 
23 07:42:12 2006
@@ -92,7 +92,7 @@
        load:function(type, data, http, kwArgs){
                dojo.log.debug("Response recieved.");
                if (!data) {
-                       dojo.log.err("No data received in response.");
+                       dojo.log.warn("No data received in response.");
                        return;
                }
                
@@ -236,6 +236,7 @@
                
         for (var i=0; i<scripts.length; i++) {
             var scr = scripts[i].match(match)[1];
+            if(!scr || scr.length <= 0){continue;}
             try {
                 dojo.log.debug("evaluating script:", scr);
                 eval(scr);


Reply via email to