tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkuhn...@apache.org
Subject svn commit: r568664 - in /tapestry/tapestry4/trunk: tapestry-examples/Workbench/src/context/ tapestry-examples/Workbench/src/context/WEB-INF/ tapestry-examples/Workbench/src/context/images/ tapestry-framework/src/java/org/apache/tapestry/components/ ta...
Date Wed, 22 Aug 2007 15:50:19 GMT
Author: jkuhnert
Date: Wed Aug 22 08:50:16 2007
New Revision: 568664

URL: http://svn.apache.org/viewvc?rev=568664&view=rev
Log:
-) Made Rollover work with LinkSubmit.  Fixes TAPESTRY-400. 
-) Updated workbench palette page to use rollover with LinkSubmit.

Added:
    tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/images/Continue-focus.gif
  (with props)
Modified:
    tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/Palette.html
    tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/Palette.page
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/ILinkComponent.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/AbstractFormComponent.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/AbstractSubmit.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/LinkSubmit.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Rollover.java

Modified: tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/Palette.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/Palette.html?rev=568664&r1=568663&r2=568664&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/Palette.html (original)
+++ tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/Palette.html Wed Aug
22 08:50:16 2007
@@ -28,7 +28,8 @@
 	<tr>
 		<td></td>
 		<td><input jwcid="update"/>
-			<input jwcid="continue"/></td>
+			<a jwcid="continue"><image jwcid="continueRollover" /></a>
+            </td>
 	</tr>
 </table>
 

Modified: tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/Palette.page
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/Palette.page?rev=568664&r1=568663&r2=568664&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/Palette.page
(original)
+++ tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/Palette.page
Wed Aug 22 08:50:16 2007
@@ -15,55 +15,59 @@
    limitations under the License.
 -->
 
-<!DOCTYPE page-specification PUBLIC 
-  "-//Apache Software Foundation//Tapestry Specification 4.0//EN" 
-  "http://tapestry.apache.org/dtd/Tapestry_4_0.dtd">
-	
+<!DOCTYPE page-specification PUBLIC
+        "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
+        "http://tapestry.apache.org/dtd/Tapestry_4_0.dtd">
+
 <page-specification class="org.apache.tapestry.workbench.palette.Palette">
-  
-  <property name="clientValidationEnabled" persist="client" initial-value="true"/>
- 
-  <bean name="delegate" class="org.apache.tapestry.workbench.WorkbenchValidationDelegate"
property="delegate"/>
-  
-  <component id="form" type="Form">
-    <binding name="delegate" value="bean:delegate"/>
-    <binding name="clientValidationEnabled" value="clientValidationEnabled"/>
-    <binding name="refresh" value="listener:doRefresh"/>
-    <binding name="success" value="listener:doAdvance"/>    
-  </component>
-  
-  <component id="inputEnabled" type="Checkbox">
-    <binding name="value" value="clientValidationEnabled"/> 
-    <binding name="onchange" value="literal:tapestry.form.submit(this.form);"/>
-  </component>
-
-  <component id="inputColorSort" type="PropertySelection">
-  	<binding name="value" value="sort"/>
-  	<binding name="model" value="literal:None=NONE,Label=LABEL,Value=VALUE,Manual=USER"/>
-    <binding name="onchange">
-      literal:tapestry.form.refresh(this.form);
-    </binding>
-  </component>
-  
-  <component id="inputColor" type="contrib:Palette">
-    <binding name="model" value="colorModel"/>
-    <binding name="selected" value="selectedColors"/>
-    <binding name="sort" value="sort"/>
-    <binding name="tableClass" value="literal:palette"/>
-    <binding name="displayName" value="literal:Colors"/>
-    <binding name="validators" value="validators:required"/>
-  </component>
-  
-  <component id="update" type="ImageSubmit">
-    <binding name="image" value="asset:update"/>
-  </component>
-  
-  <component id="continue" type="ImageSubmit">
-  	<binding name="image" value="asset:continue"/>
-  </component>
- 
-  <asset name="continue" path="images/Continue.gif"/>
-  <asset name="update" path="images/Update.gif"/>
-  
+
+    <property name="clientValidationEnabled" persist="client" initial-value="true"/>
+
+    <bean name="delegate" class="org.apache.tapestry.workbench.WorkbenchValidationDelegate"
property="delegate"/>
+
+    <component id="form" type="Form">
+        <binding name="delegate" value="bean:delegate"/>
+        <binding name="clientValidationEnabled" value="clientValidationEnabled"/>
+        <binding name="refresh" value="listener:doRefresh"/>
+        <binding name="success" value="listener:doAdvance"/>
+    </component>
+
+    <component id="inputEnabled" type="Checkbox">
+        <binding name="value" value="clientValidationEnabled"/>
+        <binding name="onchange" value="literal:tapestry.form.submit(this.form);"/>
+    </component>
+
+    <component id="inputColorSort" type="PropertySelection">
+        <binding name="value" value="sort"/>
+        <binding name="model" value="literal:None=NONE,Label=LABEL,Value=VALUE,Manual=USER"/>
+        <binding name="onchange">
+            literal:tapestry.form.refresh(this.form);
+        </binding>
+    </component>
+
+    <component id="inputColor" type="contrib:Palette">
+        <binding name="model" value="colorModel"/>
+        <binding name="selected" value="selectedColors"/>
+        <binding name="sort" value="sort"/>
+        <binding name="tableClass" value="literal:palette"/>
+        <binding name="displayName" value="literal:Colors"/>
+        <binding name="validators" value="validators:required"/>
+    </component>
+
+    <component id="update" type="ImageSubmit">
+        <binding name="image" value="asset:update"/>
+    </component>
+
+    <component id="continue" type="LinkSubmit" />
+
+    <component id="continueRollover" type="Rollover">
+        <binding name="image" value="asset:continue" />
+        <binding name="mouseOver" value="asset:continueFocus" />
+    </component>
+
+    <asset name="continue" path="images/Continue.gif"/>
+    <asset name="continueFocus" path="images/Continue-focus.gif"/>
+    <asset name="update" path="images/Update.gif"/>
+
 </page-specification>
 

Added: tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/images/Continue-focus.gif
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/images/Continue-focus.gif?rev=568664&view=auto
==============================================================================
Binary file - no diff available.

Propchange: tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/images/Continue-focus.gif
------------------------------------------------------------------------------
    svn:mime-type = image/gif

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/ILinkComponent.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/ILinkComponent.java?rev=568664&r1=568663&r2=568664&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/ILinkComponent.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/ILinkComponent.java
Wed Aug 22 08:50:16 2007
@@ -34,7 +34,8 @@
      * Returns the desired scheme (i.e., "http" or "https") for the link, or
      * null to not output a specific scheme (in which case the URL will fall
      * under the incoming request's scheme).
-     * 
+     *
+     * @return The scheme portion of the url to be generated. 
      * @since 4.0
      */
 
@@ -44,7 +45,8 @@
      * Returns the desired port (i.e., "80" or "443") for the link, or null to
      * not output a specific port (in which case the URL will fall under the
      * incoming request's port).
-     * 
+     *
+     * @return The http port to use.
      * @since 4.1
      */
 
@@ -52,7 +54,8 @@
 
     /**
      * Returns whether this service link component is enabled or disabled.
-     * 
+     *
+     * @return True if disabled, false otherwise.
      * @since 0.2.9
      */
 
@@ -60,7 +63,8 @@
 
     /**
      * Returns the anchor defined for this link, or null for no anchor.
-     * 
+     *
+     * @return The <code>#anchorid</code> portion of the url to be generated
- if any.
      * @since 3.0
      */
 
@@ -69,7 +73,8 @@
     /**
      * Returns the name of the target window or frame for this link, or null if
      * current window or frame is to be used.
-     * 
+     *
+     * @return The <code>target="_this"</code> portion of the link to be generated
- if any.
      * @since 4.0
      */
     String getTarget();
@@ -82,8 +87,14 @@
      * This was created for use by {@link org.apache.tapestry.html.Rollover} to
      * set mouse over and mouse out handlers on the {@link ILinkComponent} that
      * wraps it, but can be used for many other things as well.
-     * 
+     *
+     * @param type
+     *          The type of event to add.
+     * @param functionName
+     *          The name of the client side javascript function to generate.
+     *
      * @since 0.2.9
+     * @deprecated To be removed in Tapestry 4.1.4. 
      */
 
     void addEventHandler(LinkEventType type, String functionName);
@@ -93,6 +104,10 @@
      * link is not disabled) to provide a
      * {@link org.apache.tapestry.engine.EngineServiceLink} that the renderer
      * can convert into a URL.
+     *
+     * @param cycle
+     *          The current request.
+     * @return A {@link ILink} instance representing the link information for this component.
      */
 
     ILink getLink(IRequestCycle cycle);
@@ -102,10 +117,13 @@
      * the link render any additional attributes. These are informal parameters,
      * plus any attributes related to events. This is only invoked for
      * non-disabled links.
-     * 
+     *
+     * @param writer
+     *          Markup writer to write content to.
+     * @param cycle
+     *          The current request.
      * @since 3.0
      */
 
-    void renderAdditionalAttributes(IMarkupWriter writer,
-            IRequestCycle cycle);
+    void renderAdditionalAttributes(IMarkupWriter writer, IRequestCycle cycle);
 }

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/AbstractFormComponent.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/AbstractFormComponent.java?rev=568664&r1=568663&r2=568664&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/AbstractFormComponent.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/AbstractFormComponent.java
Wed Aug 22 08:50:16 2007
@@ -22,14 +22,14 @@
 /**
  * A base class for building components that correspond to HTML form elements. All such components
  * must be wrapped (directly or indirectly) by a {@link Form} component.
- * 
+ *
  * @author Howard Lewis Ship
  * @author Paul Ferraro
  * @since 1.0.3
  */
 public abstract class AbstractFormComponent extends AbstractComponent implements IFormComponent
 {
-    
+
     public abstract IForm getForm();
 
     public abstract void setForm(IForm form);
@@ -55,7 +55,7 @@
      */
 
     public abstract String getIdParameter();
-    
+
     /**
      * Invoked by {@link AbstractComponent#render(IMarkupWriter, IRequestCycle)} to actually

      * render the component (with any parameter values already set). 
@@ -64,7 +64,7 @@
      * {@link #renderFormComponent(IMarkupWriter, IRequestCycle)} or 
      * {@link #rewindFormComponent(IMarkupWriter, IRequestCycle)}. 
      * Those two are the methods that subclasses should implement. 
-     *  
+     *
      * @see org.apache.tapestry.AbstractComponent#renderComponent(org.apache.tapestry.IMarkupWriter,
      *      org.apache.tapestry.IRequestCycle)
      */
@@ -73,26 +73,26 @@
         IForm form = TapestryUtils.getForm(cycle, this);
 
         setForm(form);
-        
+
         if (form.wasPrerendered(writer, this))
             return;
-        
+
         IValidationDelegate delegate = form.getDelegate();
-        
+
         delegate.setFormComponent(this);
-        
+
         setName(form);
-        
+
         if (form.isRewinding())
         {
             if (!isDisabled())
             {
                 rewindFormComponent(writer, cycle);
             }
-            
+
             // This is for the benefit of the couple of components (LinkSubmit) that allow
a body.
             // The body should render when the component rewinds.
-            
+
             if (getRenderBodyOnRewind())
                 renderBody(writer, cycle);
         }
@@ -100,15 +100,15 @@
         {
             if (!NullWriter.class.isInstance(writer))
                 form.setFormFieldUpdating(true);
-            
+
             renderFormComponent(writer, cycle);
-            
+
             if (getCanTakeFocus() && !isDisabled())
             {
-                delegate.registerForFocus(
-                        this,
-                        delegate.isInError() ? ValidationConstants.ERROR_FIELD
-                                : ValidationConstants.NORMAL_FIELD);
+                delegate.registerForFocus(this,
+                                          delegate.isInError()
+                                          ? ValidationConstants.ERROR_FIELD
+                                          : ValidationConstants.NORMAL_FIELD);
             }
 
         }
@@ -121,7 +121,7 @@
      * {@link #rewindFormComponent(IMarkupWriter, IRequestCycle)} should leave this method
returning
      * false. Remember that if the component is {@link IFormComponent#isDisabled() disabled}
then
      * {@link #rewindFormComponent(IMarkupWriter, IRequestCycle)} won't be invoked.
-     * 
+     *
      * @return false; override this method to change.
      */
     protected boolean getRenderBodyOnRewind()
@@ -143,19 +143,19 @@
     {
         getForm().getDelegate().writeSuffix(writer, cycle, this, null);
     }
-    
+
     protected void setName(IForm form)
     {
         setName(form.getElementId(this));
     }
-    
+
     /**
      * {@inheritDoc}
      */
     protected void generateClientId()
     {
     }
-    
+
     /**
      * {@inheritDoc}
      */
@@ -163,18 +163,18 @@
     {
         if (getPage() == null)
             return null;
-        
+
         IForm form = (IForm) getPage().getRequestCycle().getAttribute(TapestryUtils.FORM_ATTRIBUTE);
         if (form == null)
             return null;
 
         return form.peekClientId(this);
     }
-    
+
     /**
      * Returns false. Subclasses that might be required must override this method. Typically,
this
      * involves checking against the component's validators.
-     * 
+     *
      * @since 4.0
      */
     public boolean isRequired()
@@ -185,7 +185,7 @@
     /**
      * Invoked from {@link #renderComponent(IMarkupWriter, IRequestCycle)} 
      * to render the component. 
-     *  
+     *
      * @param writer
      * @param cycle
      */
@@ -195,7 +195,7 @@
      * Invoked from {@link #renderComponent(IMarkupWriter, IRequestCycle)} to rewind the

      * component. If the component is {@link IFormComponent#isDisabled() disabled} 
      * this will not be invoked. 
-     * 
+     *
      * @param writer
      * @param cycle
      */

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/AbstractSubmit.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/AbstractSubmit.java?rev=568664&r1=568663&r2=568664&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/AbstractSubmit.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/AbstractSubmit.java
Wed Aug 22 08:50:16 2007
@@ -40,7 +40,9 @@
      * Determine if this submit component was clicked.
      * 
      * @param cycle
+     *          The current request.
      * @param name
+     *          The name of this form element.
      * @return true if this submit was clicked
      */
     protected abstract boolean isClicked(IRequestCycle cycle, String name);

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/LinkSubmit.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/LinkSubmit.java?rev=568664&r1=568663&r2=568664&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/LinkSubmit.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/LinkSubmit.java
Wed Aug 22 08:50:16 2007
@@ -87,8 +87,9 @@
 
                 writer.attribute("href", getDirectService().getLink(true, dsp).getURL());
                 writer.attribute("onClick", js + "," + json.toString() + "); return false;");
                       
-            } else {
-
+            }
+            else
+            {
                 writer.attribute("href", "javascript:" + js + ");");
             }
 

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Rollover.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Rollover.java?rev=568664&r1=568663&r2=568664&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Rollover.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Rollover.java
Wed Aug 22 08:50:16 2007
@@ -14,19 +14,14 @@
 
 package org.apache.tapestry.html;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.hivemind.ApplicationRuntimeException;
-import org.apache.tapestry.AbstractComponent;
-import org.apache.tapestry.IAsset;
-import org.apache.tapestry.IMarkupWriter;
-import org.apache.tapestry.IRequestCycle;
-import org.apache.tapestry.IScript;
-import org.apache.tapestry.PageRenderSupport;
-import org.apache.tapestry.Tapestry;
-import org.apache.tapestry.TapestryUtils;
+import org.apache.tapestry.*;
 import org.apache.tapestry.components.ILinkComponent;
+import org.apache.tapestry.form.IFormComponent;
+import org.apache.tapestry.form.LinkSubmit;
+
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Combines a link component (such as
@@ -35,7 +30,7 @@
  * Navigator and Internet Explorer. [ <a
  * href="../../../../../ComponentReference/Rollover.html">Component Reference
  * </a>]
- * 
+ *
  * @author Howard Lewis Ship
  */
 
@@ -45,45 +40,58 @@
     /**
      * Converts an {@link IAsset}binding into a usable URL. Returns null if the
      * binding does not exist or the binding's value is null.
+     *
+     * @param asset
+     *          The asset to generate a url for.
+     * @return The url to the asset resource, or null if it couldn't be generated.
      */
 
     protected String getAssetURL(IAsset asset)
     {
-        if (asset == null) return null;
+        if (asset == null)
+            return null;
 
         return asset.buildURL();
     }
 
     protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
     {
-        // No body, so we skip it all if not rewinding (assumes no side effects
-        // on
-        // accessors).
+        // No body, so we skip it all if not rewinding
+        // (assumes no side effects on accessors).
 
-        if (cycle.isRewinding()) 
+        if (cycle.isRewinding())
             return;
 
         String imageURL = null;
         String mouseOverURL = null;
         String mouseOutURL = null;
         boolean dynamic = false;
-        String imageId = null;
+        String imageId;
+        boolean linkDisabled = false;
 
         PageRenderSupport pageRenderSupport = TapestryUtils.getPageRenderSupport(cycle, this);
 
-        ILinkComponent serviceLink = (ILinkComponent) cycle.getAttribute(Tapestry.LINK_COMPONENT_ATTRIBUTE_NAME);
-        
+        Object serviceLink = cycle.getAttribute(Tapestry.LINK_COMPONENT_ATTRIBUTE_NAME);
         if (serviceLink == null)
-            throw new ApplicationRuntimeException(Tapestry
-                    .getMessage("Rollover.must-be-contained-by-link"), this, null, null);
+        {
+            serviceLink = cycle.getAttribute(LinkSubmit.ATTRIBUTE_NAME);
+
+            if (serviceLink != null)
+                linkDisabled = ((IFormComponent) serviceLink).isDisabled();
+        } else
+        {
+            linkDisabled = ((ILinkComponent) serviceLink).isDisabled();
+        }
 
-        boolean linkDisabled = serviceLink.isDisabled();
+        if (serviceLink == null)
+            throw new ApplicationRuntimeException(Tapestry.getMessage("Rollover.must-be-contained-by-link"),
this, null, null);
 
         if (linkDisabled)
         {
             imageURL = getAssetURL(getDisabled());
 
-            if (imageURL == null) imageURL = getAssetURL(getImage());
+            if (imageURL == null)
+                imageURL = getAssetURL(getImage());
         }
         else
         {
@@ -103,17 +111,17 @@
 
         if (dynamic)
         {
-            if (mouseOverURL == null) 
+            if (mouseOverURL == null)
                 mouseOverURL = imageURL;
 
-            if (mouseOutURL == null) 
+            if (mouseOutURL == null)
                 mouseOutURL = imageURL;
 
             imageId = writeScript(cycle, pageRenderSupport, serviceLink, mouseOverURL, mouseOutURL);
-            
+
             writer.attribute("id", imageId);
         }
-        
+
         renderInformalParameters(writer, cycle);
 
         writer.closeTag();
@@ -124,23 +132,23 @@
 
     public abstract IScript getScript();
 
-    private String writeScript(IRequestCycle cycle, PageRenderSupport pageRenderSupport,
ILinkComponent link,
-            String mouseOverImageURL, String mouseOutImageURL)
+    private String writeScript(IRequestCycle cycle, PageRenderSupport pageRenderSupport,
+                               Object link, String mouseOverImageURL, String mouseOutImageURL)
     {
         String imageId = pageRenderSupport.getUniqueString(getId());
-        
+
         String preloadedMouseOverImageURL = pageRenderSupport.getPreloadedImageReference(this,
mouseOverImageURL);
         String preloadedMouseOutImageURL = pageRenderSupport.getPreloadedImageReference(this,
mouseOutImageURL);
-        
+
         Map symbols = new HashMap();
-        
+
         symbols.put("link", link);
         symbols.put("imageId", imageId);
         symbols.put("mouseOverImageURL", preloadedMouseOverImageURL);
         symbols.put("mouseOutImageURL", preloadedMouseOutImageURL);
-        
+
         getScript().execute(this, cycle, pageRenderSupport, symbols);
-        
+
         return imageId;
     }
 



Mime
View raw message