DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Building Scalable Real-Time Apps with AstraDB and Vaadin
Register Now

Trending

  • Microservices With Apache Camel and Quarkus
  • Implementing a Serverless DevOps Pipeline With AWS Lambda and CodePipeline
  • Automating the Migration From JS to TS for the ZK Framework
  • How To Integrate Microsoft Team With Cypress Cloud

Trending

  • Microservices With Apache Camel and Quarkus
  • Implementing a Serverless DevOps Pipeline With AWS Lambda and CodePipeline
  • Automating the Migration From JS to TS for the ZK Framework
  • How To Integrate Microsoft Team With Cypress Cloud
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. A Tooltip component for Tapestry

A Tooltip component for Tapestry

Taha Siddiqi user avatar by
Taha Siddiqi
·
Jul. 15, 11 · Interview
Like (0)
Save
Tweet
Share
5.25K Views

Join the DZone community and get the full member experience.

Join For Free

i was thinking of adding tooltips using prototip but found a very good free solution in opentip . this is a very nice library and very easy to integrate. i was able to integrate it with only a single modification to the script and that was to replace the default ajax support with the tapestry’s own ajax support.

the component takes three arguments

  • tip: the tool tip to display.
  • tiptitle: the title of the tool tip
  • tipevent: in case you want the tool tip to be retrieved using ajax then you can specify the event to respond to on a onmouseover event

the component is very simple as all the hard work has already been done by the authors of the script.

@supportsinformalparameters
@import(library = {"opentip/opentip.js", "opentip/opentip_init.js"}, stylesheet = "opentip/opentip.css")
public class tooltip
{
   @parameter(defaultprefix = bindingconstants.literal)
   private string tip;

   @parameter(defaultprefix = bindingconstants.literal)
   private string tiptitle;

   @parameter(defaultprefix = bindingconstants.literal)
   private string tipevent;

   @injectcontainer
   private clientelement element;

   @inject
   private javascriptsupport javascriptsupport;

   @inject
   private componentresources resources;

   @afterrender
   void addjavascript()
   {
      jsonobject params = new jsonobject();

      params.put("elementid", element.getclientid());
      params.put("tiptitle", tiptitle);
      params.put("tip", tip);

      if(tipevent != null)
      {
         params.put("url", createajaxtipevent());
      }

      params.put("options", createoptionsfrominformalparameters());

      javascriptsupport.addinitializercall("setupopentip", params);
   }

   private string createajaxtipevent()
   {
      return resources.createeventlink(tipevent).touri();
   }

   private jsonobject createoptionsfrominformalparameters()
   {
      jsonobject options = new jsonobject();

      for(string parametername: resources.getinformalparameternames())
      {
         options.put(parametername,
            resources.getinformalparameter(parametername, string.class));
      }

      return options;
   }

}

the initialization script is

tapestry.initializer.setupopentip = function(params)
{
   if(params.url)
   {
      params.options.ajax = {};
      params.options.ajax.url = params.url;
   }

   $(params.elementid).addtip(params.tip, params.tiptitle, params.options);
};

a typical usage for an inline tooltip will be

<div t:mixins='tawus/tooltip' t:type='any' t:tip='my tip'
     t:tiptitle='my ajax tooltip'>
</div>

a ajax usage will be

<html xmlns:t='http://tapestry.apache.org/schema/tapestry_5_1_0.xsd' xmlns:p='tapestry:parameter'>

   <body>
      <div t:mixins='tawus/tooltip' t:type='any'
           t:tipevent='tooltip' t:tiptitle='my ajax tooltip'>
      this is text, hover over it to see the tooltip
      </div>

      <t:block t:id='tooltip'>
         this content is extracted using ajax
      </t:block>
   </body>
</html>

public class tooltipdemo
{
   @inject
   private block tooltip;

   object ontooltip()
   {
      return tooltip;
   }
}

note if both tip and tipevent are specified, the tipevent takes precedence and ajax content is only shown

from http://tawus.wordpress.com/2011/07/12/a-tooltip-component-for-tapestry/

Integration Event Library

Opinions expressed by DZone contributors are their own.

Trending

  • Microservices With Apache Camel and Quarkus
  • Implementing a Serverless DevOps Pipeline With AWS Lambda and CodePipeline
  • Automating the Migration From JS to TS for the ZK Framework
  • How To Integrate Microsoft Team With Cypress Cloud

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: