This content has been marked as final.
Show 2 replies
-
1. Re: HtmlTooltip programmatically is not displayed
niss Aug 3, 2011 8:18 AM (in response to niss)Hello everybody,
No idea ?
Couldn't someone provide me with an example that is working ?
Thank you in advance.
Nicolas.
-
2. Re: HtmlTooltip programmatically is not displayed
niss Sep 7, 2011 4:38 AM (in response to niss)Hello everybody,
Some news.
I made a little mistake in the last piece of code I gave : I forgot to give an ID to the h:outputText. If you don't give an ID, tooltip won't be displayed (that's not really intuitive).
So, this is correct (and the cleanest way to do it) :
<h:outputText value="myHtmlOutputText" id="outputTextId"> <rich:toolTip binding="#{resultPrestationBean.htmlTooltip}" /> </h:outputText>
For the first piece of code, I found a way to make it work the way I want. Not sure it is the best way to do it and if it's useful as we can use the code above, but maybe it can be useful for someone ?
public HtmlOutputText getHtmlOutputText() { htmlOutputText = new HtmlOutputText(); htmlOutputText.setId("myId"); htmlOutputText.setValue("myHtmlOutputText with tooltip"); htmlOutputText.getChildren().add(getHtmlTooltip()); try { htmlOutputText.encodeChildren(getFacesContext()); htmlOutputText.encodeEnd(getFacesContext()); } catch (IOException e) { e.printStackTrace(); } // Set value to null otherwise the text value that you set before will be displayed twice. htmlOutputText.setValue(null); return this.htmlOutputText; }
Nicolas.