Retrieve a Page With Ajax Request
The key to integrating the tooltip dialog with WPF is to leverage the href attribute available for the widget. This provides the widget with a mechanism to retrieve the HTML we'd like to display in the dialog, in our case we want the URL to a page. Here's the java that we can use to generate that URL (see this entry for more):
JSPSupport.getActionURL(webAppAccess, webAppAccess.getBackchannelURLMapper(false), "keep_page:lm.page1")
Now let's throw together some HTML for the page builder that will display the dialog:
<html> <head><title>Default Test Page</title></head> <body> <div id="tooltipDialog" dojoType="dijit.TooltipDialog" style="display:none" onBlur='dijit.popup.close(this)'/> <div id='dialogTarget' onclick='showOrders()'>Show tooltip here</div> </body> </html>
Note that we're using declarative markup to create the tooltip instead of javascript, and then setting its style to display:none. This is easier because it enables us to use an attribute setter builder to set the href:
Note here the last parameter is the page that we want to display, in my case I'm using a linked model to one of my previous blog entries referenced as lm so I have keep_page:lm.page1.
Finally, we have to add a dojo enable builder that will bring in the required package dijit.TooltipDialog and we'll add a little bit of javascript to display the tooltip when an element is clicked:
function showOrders(){ var tooltipdialog = dijit.byId('tooltipDialog'); dijit.popup.open({ popup: tooltipdialog, around: dojo.byId("dialogTarget") }); }
The result looks like this, and unlike the dojo tooltip builder, we can interact with the contents of the dialog - in this case linked order numbers:
This example provides a good starting point for understanding how easy it is to integrate dojo with WPF.