Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

tooltip for selectItems  RSS feed

 
g amores
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

I need to provide a tooltip for individual items within a selectOneMenu. Does anyone know how to do this?

Thanks.
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can render any component way you want.
Where exactly are you stucked?
 
Ethan Gur
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I want to do the same. I have an <h:selectOneMenu... > element with string elements. Some of them are too long, and I would like to do 2 things:
1. Limit the size of the element (i.e. not to render more than n chars).
2. If the length of the string is longer than n, add a tooltip holding the full string.

Is there an example for this kind of code?
 
mani manikantan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of searching for tool tip in jsf. we can go for the below scriplet code in jsp.

//java script code for onmouseover enent.
function showHideTooltip()
{
var obj = document.getElementById("frmApplnInfo:industry");
obj.title=obj.options[obj.selectedIndex].title;
}

Value present in the arraylist will be like below.
141456,Agriculture sectors.[/b]

<select name="industry" id="frmApplnInfo:industry" size=1 onmouseover="showHideTooltip()" STYLE="width:350px">
<option value="">----Select----</option>
<%
java.util.List industry=null;
industry=(java.util.List)session.getAttribute("industry");
if(industry==null){
industry=new LOVRetrievalBackingBean().getIndustry();
session.setAttribute("industry",industry);
}
for(int i=0;i<industry.size();i++){
String lovList=(String)industry.get(i);
String lovId=(String)lovList.substring(0,lovList.indexOf(","));
String lovValue=lovList.substring(lovList.indexOf(",") +1);
%>
<option value="<%=lovId%>" title="<%=lovValue%>"><%=lovValue%></option>
<%}
%>
</select>

 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DON'T use scriptlets in JSF. They probably won't work at all, and if they do, they'll work badly. Same thing for JSTL.

You can use JavaScript, and even advanced services like jQuery in JSF. But if you want to code up something to do per-item tooltips, a better way to obtain the tooltip details is to put them in a hidden text control. Just remember that the "id=" value for JavaScript is a more complex format than the simple ID that you code on the JSF tag itself.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!