Page 1 of 1

Tooltip for MenuItems?

Posted: 27 Mar 2012, 14:19
by jmrunge
Hi,
Does your implementation of tooltip support showing tooltips when user moves his mouse over some menuitem or submenu? Have been searching at forums and at google and could not find it, nor in the showcase or documentation.

Thanks in advance!

Re: Tooltip for MenuItems?

Posted: 27 Mar 2012, 14:30
by Oleg
Hi. Sure, it should support events for menuitems. Why not. Have you tried this?

Re: Tooltip for MenuItems?

Posted: 27 Mar 2012, 15:29
by jmrunge
Hi Oleg,
Thanks for your response. PF tooltip implementation didnt worked on MenuItems, thats why I asked. Or I didnt get how to do it! I'm using MenuBar component with MenuItems. Here is a piece of code of mine:

Code: Select all

<p:menuitem id="menu1" url="/faces/configuracion/localidades.xhtml" value="Localidades" />
and:

Code: Select all

<p:tooltip for='menu1' value='ABM de Localidades' />
Is this correct with PF? Or will this work with PF Extensions?

Thanks in advance!

Re: Tooltip for MenuItems?

Posted: 27 Mar 2012, 15:35
by Oleg
Simple try this with pe:tooltip. I haven't faced any problems with pe:tooltip so far. We tested it with various components.

Re: Tooltip for MenuItems?

Posted: 27 Mar 2012, 16:27
by jmrunge
Oleg,
Didnt worked either, with the code snippets detailed before... Am I using correct syntax?

Regards,

Re: Tooltip for MenuItems?

Posted: 27 Mar 2012, 16:45
by Oleg
Syntax is correct. "for" in pe:tooltip should match "id" in p:menuitem. This is a search expression for findComponent(). Can you post the client id of your menuitem please? (look in Firebug).

What you can try yet, is this construct

Code: Select all

<p:menuitem id="menu1" url="/faces/configuracion/localidades.xhtml" value="Localidades">
    <pe:tooltip value="ABM ..."/>
</p:menuitem>

Re: Tooltip for MenuItems?

Posted: 27 Mar 2012, 17:05
by jmrunge
Oleg,
Here is the code I copied from firebug:

Code: Select all

<a id="menu2" class="ui-menuitem-link ui-corner-all" href="/milonga-war/faces/configuracion/paises.xhtml">
<span class="ui-menuitem-text">Países</span>
</a>
and:

Code: Select all

<pe:tooltip value="Configuración General" for="menu2"/>
Cannot try the other approach because Im using dynamic menu with MenuModel... Could this be an issue?

Regards,

Re: Tooltip for MenuItems?

Posted: 28 Mar 2012, 10:27
by Oleg
Cannot try the other approach because Im using dynamic menu with MenuModel... Could this be an issue?
No, this is not an issue. I think the problem is <a href="..." element. Try to attach pe:tooltip to span element with:

Code: Select all

<pe:tooltip value="Configuración General" forSelector="#menu2 span"/>
This should work.

Re: Tooltip for MenuItems?

Posted: 28 Mar 2012, 15:35
by jmrunge
Oleg,
Thanks for your time! Finally got it working. What I was doing wrong is the way of inserting the "<pe:tooltip>" tag inside the xhtml page. I was reading a string from my backing bean, which conformed the tag with this atributte and inserting this on the page:

jsf:

Code: Select all

#{appBean.toolTips}
AppBean:

Code: Select all

public String getToolTips() {
    int i = 0;
    String tooltips = "";
    for (SystemOption so : getSystemOptions()) {
        i++:
        tooltips = tooltips + "<pe:tooltip forSelector='#menu" + i + " span' value='" + so.getTooltip() + "' />\n";
    }
    return tooltips;
And changed for:

jsf:

Code: Select all

<c:forEach items="#{appBean.toolTips}" var="tt" >
    <pe:tooltip forSelector="##{tt.key} span" value="#{tt.value}" />
</c:forEach>
AppBean:

Code: Select all

public Map<String, String> getToolTips() {
    if (tooltips == null) {
        tooltips = new HashMap<>();
        int i = 0;
        for (SystemOption so : getSystemOptions()) {
            i++;
            tooltips.put(i, so.getTooltip());
        }
    }
    return tooltips;
}
Thanks again for your time and for pointing me on the right direction!!!

PS: Love PF Extensions, will use it more in my code!