Patrick Casey wrote:
            I'm looking to add a little chrome to my forms and wanted to put
rollovers on my various submit buttons. Right now I'm generating them with
the out of box ImageSubmit component (and they work fine), but as far as I
can tell that component doesn't support rollovers and the Rollover button
doesn't support form submission, so I'm in a bit of a catch-22.



            Before I bite the bullet and start using my old javascript
techniques on this, does anybody know if there's a canned tapestry component
that does rollovers on submit buttons?



            --- Pat



Paul Ferraro posted such a component a while back. Here are the files.

Regards,
Sohail Aslam
sohail AT techlogix.com


====== RolloverSubmit.java ==============

package com.arabiandreams.tapestry.component;

import org.apache.tapestry.form.ImageSubmit;
import org.apache.tapestry.html.Body;
import org.apache.tapestry.IAsset;
import org.apache.tapestry.IScript;
import org.apache.tapestry.IMarkupWriter;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.components.LinkEventType;
import org.apache.tapestry.IResourceLocation;

/**
 *  @author  Paul Ferraro
 */
public abstract class RolloverSubmit
    extends ImageSubmit
{
  public abstract IAsset getFocusImage();

  public abstract IAsset getBlurImage();

  private IScript script;
  protected void renderInformalParameters(IMarkupWriter writer,
                                          IRequestCycle requestCycle)
  {
    IAsset focusImage = this.getFocusImage();
    IAsset blurImage = this.getBlurImage();
    if (!this.isDisabled())
    {
      String focusImageReference = getImageReference(focusImage,
          requestCycle);
      String blurImageReference = getImageReference( (blurImage ==
          null) ? this.getImage() : blurImage, requestCycle);

writer.attribute(LinkEventType.MOUSE_OVER.getAttributeName(),
"setImageSrc(this, " + focusImageReference + ")");
writer.attribute(LinkEventType.MOUSE_OUT.getAttributeName(),
"setImageSrc(this, " + blurImageReference + ")");
this.script.execute(requestCycle,
Body.get(requestCycle), java.util.Collections.EMPTY_MAP);
}
super.renderInformalParameters(writer, requestCycle);
}


  private String getImageReference(IAsset asset, IRequestCycle
                                   requestCycle)
  {
    String imageURL = asset.buildURL(requestCycle);
    Body body = Body.get(requestCycle);
    String imageReference = body.getPreloadedImageReference(imageURL);

    return imageReference.split("\\.")[0];
  }

  protected void finishLoad()
  {
    IResourceLocation location =


this.getSpecification().getSpecificationLocation().getRelativeLocation( "RolloverSubmit.script");

    this.script =
        this.getPage().getEngine().getScriptSource().getScript(location);
  }
}


========= RolloverSubmit.jwc =================== <?xml version="1.0"?> <!DOCTYPE component-specification PUBLIC "-//Apache Software Foundation//Tapestry Specification 3.0//EN" "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd";>

<component-specification class="com.arabiandreams.tapestry.component.RolloverSubmit" allow-body="no" allow-informal-parameters="yes">

<parameter name="name" property-name="nameOverride" type="java.lang.String" direction="in"> </parameter>
<parameter name="disabled" type="boolean" direction="in"> </parameter>
<parameter name="image" type="org.apache.tapestry.IAsset" direction="in" required="yes"> </parameter>
<parameter name="disabledImage" type="org.apache.tapestry.IAsset" direction="in"> </parameter>
<parameter name="focusImage" type="org.apache.tapestry.IAsset" direction="in" required="yes"> </parameter>
<parameter name="blurImage" type="org.apache.tapestry.IAsset" direction="in"> </parameter>
<parameter name="point" type="java.awt.Point"> </parameter>
<parameter name="selected" type="java.lang.Object"> </parameter>
<parameter name="tag" type="java.lang.Object" direction="in"> </parameter>
<parameter name="listener" type="org.apache.tapestry.IActionListener" direction="in"> </parameter>


  <reserved-parameter name="type"/>
  <reserved-parameter name="src"/>
  <reserved-parameter name="border"/>
  <reserved-parameter name="onmouseover"/>
  <reserved-parameter name="onmouseout"/>

  <property-specification name="name" type="java.lang.String"/>
  <property-specification name="form" type="org.apache.tapestry.IForm"/>
</component-specification>

======= RolloverSubmit.script =================================
<?xml version="1.0"?>
<!DOCTYPE script PUBLIC
"-//Apache Software Foundation//Tapestry Script Specification 3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Script_3_0.dtd";>

<script>

<body>
<![CDATA[
function setImageSrc(image1, image2) {
    if (image1 && image2 && image1.src && image2.src) {
        image1.src = image2.src
    }
}
]]>
</body>

<initialization>
 <!-- nothing -->
</initialization>

<!-- include-script resource-path="script/RolloverSubmit.js"/ -->
</script>


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to