*
The moose likes JSF and the fly likes Any solution for h:graphicImage using rich:toolTip Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Any solution for h:graphicImage using rich:toolTip" Watch "Any solution for h:graphicImage using rich:toolTip" New topic
Author

Any solution for h:graphicImage using rich:toolTip

ya ji
Ranch Hand

Joined: Jul 14, 2008
Posts: 40
In the page, there is a rich:datalist, loop this datalist, each row has a h:graphicImage component, when user move mouse over this image, show a rich:toolTip.

Following code works fine:
<h:graphicImage id ="Test" value="a.gif" width="12" height="12">
<rich:toolTip for="Test">
<span>error message</span>
</rich:toolTip>
</h:graphicImage>

As you know, h:graphicImage can't have a dynamic id, so in datalist, I can't give each h:graphicImage a unique id which can be use by "for" attribute in rich:toolTip

If h:graphicImage without id, rich:toolTip doesn't work.

I want to make toolTip for each image in datalist work, who has solution for this issue?

thanks in advance!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15951
    
  19

ya ji wrote:In the page, there is a rich:datalist, loop this datalist, each row has a h:graphicImage component, when user move mouse over this image, show a rich:toolTip.

Following code works fine:
<h:graphicImage id ="Test" value="a.gif" width="12" height="12">
<rich:toolTip for="Test">
<span>error message</span>
</rich:toolTip>
</h:graphicImage>

As you know, h:graphicImage can't have a dynamic id, so in datalist, I can't give each h:graphicImage a unique id which can be use by "for" attribute in rich:toolTip

If h:graphicImage without id, rich:toolTip doesn't work.

I want to make toolTip for each image in datalist work, who has solution for this issue?

thanks in advance!


I think the key indicator of what you're doing wrong is when you say "loop this datalist".

JSF is not designed for putting Controller logic in the View.

Just because other JSP frameworks allow you to program the display doesn't mean JSF was intended to do likewise. It's actually NOT a good practice, any more than putting excessive amounts of business logic in a database stored procedure is. If you splatter logic all over the landscape, you're probably going to end up warping it as each subsystem makes its own particular types of deformities on the process. And you'll make the app harder to maintain, since the first thing s maintainer has to do when something needs changing is figure out which component(s) the changes apply to and how they interact. Unanticipated interactions are a major source of error.

OK. End of rant.

If you use the JSF datatable, the ID will be unique. Therefore you will be able to give each item its own independent tooltip.

The low-level ID will be a composite of the datatable's ID plus an unpredictable generated value that will probably be something like an index number, but whose exact value will depend on which JSF implementation you use. You shouldn't care about that, however, since you only need the ID you code and JSF will handle the rest.

Here's something I just happened to have laying around. It uses the dataGrid instead of the dataTable, but the general effect is the same:


Customer surveys are for companies who didn't pay proper attention to begin with.
ya ji
Ranch Hand

Joined: Jul 14, 2008
Posts: 40
Fixed!
Inclose toolTip to h:graphicImage and give h:graphicImage an id, but don't give toolTip id.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15951
    
  19

ya ji wrote:Fixed!
Inclose toolTip to h:graphicImage and give h:graphicImage an id, but don't give toolTip id.


Well, actually, it should be OK to give the tooltip an ID - just not the same ID as any other element on the page.

in XML, the "id=" attribute MUST be unique within its context. Which is why things like the message tag uses the "for=" attribute to indicate what its aimed at. It can't simply specify the same id attribute as its target.
 
 
subject: Any solution for h:graphicImage using rich:toolTip
 
Similar Threads
I need help with ajaxSingle, reRender and immediate.
Display the content of a variable without <h:outputText>?
rich:contextMenu HOW TO RERENDER some sections!!
rich:tooltip is not showing mentioned color
Not able to use action attribute in JSF graphicImage