0 Replies Latest reply on Jan 27, 2012 4:33 AM by blebleskeble

    rich:tooltip mode and delay

    blebleskeble

      HI all,

      I have two questions about rich tooltip component:

      1)

      I tried to create page with tooltip that has mode set to 'ajax' for the first time and than to 'client' if data are loaded.

      Here is my page:

       

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:rich="http://richfaces.org/rich"
            xmlns:a4j="http://richfaces.org/a4j">
          <h:head>
            <title>ToolTip</title>
          </h:head>
          
          <h:body>
              
              <h:form id="form">
                  
                  <a4j:commandLink id="link">
                      <rich:tooltip id="linkToolTip" mode="#{tip.getMode('link')}" execute="@this" render="linkToolTip">
                          <h:outputText value="#{tip.getText('link')}"/>
                      </rich:tooltip>
                      <h:outputText value="link" />
                  </a4j:commandLink>
                  
                  <br /><br />
                  <a4j:log id="log" />
              </h:form>
          
          </h:body>
      </html>
      

       

      and here is my managed bean:

       

      package cz.blebleskeble.controller;
      
      import java.io.Serializable;
      import java.util.HashMap;
      import java.util.Map;
      import java.util.Random;
      
      import javax.faces.bean.ManagedBean;
      import javax.faces.bean.ViewScoped;
      
      import org.richfaces.TooltipMode;
      
      @SuppressWarnings("serial")
      @ManagedBean(name = "tip")
      @ViewScoped
      public class ToolTipController implements Serializable {
          
          private Map<String, String> bank;
          
          public ToolTipController() {
              bank = new HashMap<String, String>();
          }
          
          public TooltipMode getMode(String key) {
              System.out.println("getMode(" + key + ")");
              TooltipMode result = TooltipMode.ajax;
              if (bank.containsKey(key)) {
                  result = TooltipMode.client;
              }    
              return result;
          }
          
          public String getText(String key) {
              System.out.println("getText(" + key + ")");
              String result = null;
              if (bank.containsKey(key)) {
                  result = bank.get(key);
              } else {
                  result = createAndStoreText(key);
              }
              return result;
          }
          
          private String createAndStoreText(String key) {
              System.out.println("createAndStoreText(" + key + ")");
              String result = key + " " + new Random(System.nanoTime()).nextInt();
              bank.put(key, result);
              return result;
          }
      }
      

       

      As you can see, mode is set to 'ajax' if there is no object of given key in map, else it is set to 'client'.

       

      Problem is that tooltip is not rerendered properly and mode is still set to ajax.

      Do you have nay idea how to solve my problem?

       

      2)

      showDelay attribute

      As i saw, this attribute delay showing of tooltip, but is there any way to delay calling of request?

      basically i need to call request only if i am with mouse on link for x ms.

       

      I have page with many links and if i move mouse from top to bottom than about 30 requests are called just with this single move.

       

       

      Thanks for any advice