tapestry-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Solis" <dso...@legosoft.com.mx>
Subject RE: Anybody have an ismap example using a DirectLink?
Date Tue, 05 Aug 2003 15:14:04 GMT
Here is another solution (used for implementing a photorealistic
calculator):

Put your map in the template, e.g.

<map name="buttons">
  <area jwcid="clearDirect" shape="rect" coords="324,124,371,204"
alt="Clear"/>
  <area jwcid="plusDirect" shape="rect" coords="262,124,308,203"
alt="Plus"/>
 ..........
 ..........
 </map>

Now declare your "area" components in the page spec, i.e.:

    <component id="clearDirect" type="DirectLink">
        <binding name="renderer"
expression="@spoc.link.AreaLinkRenderer@SHARED_INSTANCE"/>
        <binding name="stateful" expression="false"/>
        <binding name="listener" expression='listeners.processButton'/>
        <binding name="parameters"
expression="@spoc.pages.Calculator@CLEAR_BUTTON"/>
    </component>

    <component id="plusDirect" type="DirectLink">
        <binding name="renderer"
expression="@spoc.link.AreaLinkRenderer@SHARED_INSTANCE"/>
        <binding name="stateful" expression="false"/>
        <binding name="listener" expression='listeners.processButton'/>
        <binding name="parameters"
expression="@spoc.pages.Calculator@PLUS_BUTTON"/>
    </component>

As you can see, the "area" components are DirectLinks with a custom
renderer: AreaLinkRenderer.

AreaLinkRenderer source is:

package spoc.link; 

import org.apache.tapestry.link.DefaultLinkRenderer;
import org.apache.tapestry.link.ILinkRenderer; 

public class AreaLinkRenderer extends DefaultLinkRenderer {
    /**
     *  A singleton for the area link.
     **/

     public static final ILinkRenderer SHARED_INSTANCE = new
AreaLinkRenderer();

    public String getElement()
    {
        return "area";
    }

    public boolean getHasBody()
    {
        return false;
    }
}

You can use AreaLinkRenderer with any Link component.

Regards

David

> -----Original Message-----
> From: Howard M. Lewis Ship [mailto:hlship@comcast.net]
> Sent: Tuesday, August 05, 2003 7:41 AM
> To: 'Tapestry users'
> Subject: RE: Anybody have an ismap example using a DirectLink?
> 
> <?xml version="1.0"?>
> <!-- $Id: DirectArea.jwc,v 1.1 2003/07/12 04:16:44 hship Exp $ -->
> <!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="examples.DirectArea"
> 	allow-body="no" allow-informal-parameters="yes">
> 
>   <parameter name="listener" required="yes" direction="auto"
>   		type="org.apache.tapestry.IActionListener"/>
>   <parameter name="parameters" type="java.lang.Object"
direction="in"/>
> 
> </component-specification>
> 
> 
> 
> 
> 
> package examples;
> 
> import org.apache.tapestry.AbstractComponent;
> import org.apache.tapestry.IActionListener;
> import org.apache.tapestry.IDirect;
> import org.apache.tapestry.IMarkupWriter;
> import org.apache.tapestry.IRequestCycle;
> import org.apache.tapestry.Tapestry;
> import org.apache.tapestry.engine.IEngineService;
> import org.apache.tapestry.engine.ILink;
> import org.apache.tapestry.link.DirectLink;
> 
> public abstract class DirectArea extends AbstractComponent implements
> IDirect
> {
>     public abstract IActionListener getListener();
>     public abstract Object getParameters();
> 
>     protected void renderComponent(IMarkupWriter writer, IRequestCycle
> cycle)
>     {
>         if (cycle.isRewinding())
>             return;
> 
>         Object[] parameters =
> DirectLink.constructServiceParameters(getParameters());
> 
>         IEngineService service =
> cycle.getEngine().getService(Tapestry.DIRECT_SERVICE);
>         ILink link = service.getLink(cycle, this, parameters);
> 
>         writer.beginEmpty("area");
>         writer.attribute("href", link.getURL());
> 
>         renderInformalParameters(writer, cycle);
>     }
> 
>     public void trigger(IRequestCycle cycle)
>     {
>         IActionListener listener = getListener();
> 
>         if (listener == null)
>             throw Tapestry.createRequiredParameterException(this,
> "listener");
> 
>         listener.actionTriggered(this, cycle);
>     }
> 
>     public boolean isStateful()
>     {
>         return false;
>     }
> 
> }
> 
> 
> 
> --
> Howard M. Lewis Ship
> Creator, Tapestry: Java Web Components
> http://jakarta.apache.org/tapestry
> 
> 
> 
> > -----Original Message-----
> > From: Howard M. Lewis Ship [mailto:hlship@comcast.net]
> > Sent: Tuesday, August 05, 2003 8:35 AM
> > To: 'Tapestry users'
> > Subject: RE: Anybody have an ismap example using a DirectLink?
> >
> >
> > Didn't mean to tease, ezmlm must be stripping out enclosures.
> >
> > --
> > Howard M. Lewis Ship
> > Creator, Tapestry: Java Web Components
> > http://jakarta.apache.org/tapestry
> >
> >
> >
> > > -----Original Message-----
> > > From: Howard M. Lewis Ship [mailto:hlship@comcast.net]
> > > Sent: Tuesday, August 05, 2003 7:22 AM
> > > To: 'Tapestry users'
> > > Subject: RE: Anybody have an ismap example using a DirectLink?
> > >
> > >
> > > This is an example component from the book that does what you
> > > want.  You don't use the DirectLink component, you re-use the
> > > direct service in a new component.
> > >
> > > --
> > > Howard M. Lewis Ship
> > > Creator, Tapestry: Java Web Components
> > > http://jakarta.apache.org/tapestry
> > >
> > >
> > >
> > > > -----Original
> > > Message-----
> > > > From: Vince Marco [mailto:vmarco@mac.com]
> > > > Sent: Monday, August 04, 2003 11:30 PM
> > > > To: tapestry-user@jakarta.apache.org
> > > > Subject: Anybody have an ismap example using a DirectLink?
> > > >
> > > >
> > > > I am converting a bunch of mapped images from Struts to
> > > Tapestry, and
> > > > time is of the essence (as if it ever isn't).
> > > >
> > > > I would very much appreciate any examples anybody has in
> > doing this.
> > > > Is there one in the examples that I missed?
> > > >
> > > > Thanks,
> > > >
> > > > Vince
> > > >
> > > > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> > > > Vince Marco
> > > > Enterprise Frameworks, Inc.
> > > > vmarco@mac.com
> > > >
> > >
> > >
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
tapestry-user-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Mime
View raw message