Xpages can't get dojo tooltip dialog box to pop up - dojo

I have a dojoFilteringSelect field which I want to put a dojo tootltip for. If the user hovers over the field (or I could put an icon next to the field) I want the contents of a computed field to show up.
Looked around and saw various examples but what I cannot find is how to connect the tool tip to the hover action? I am running this in the Lotus client.
My code is below.
<xe:djFilteringSelect id="djFilteringSelect3"
rendered="true" value="#{document1.loc}" tabIndex="1">
<xe:this.defaultValue><![CDATA[""]]></xe:this.defaultValue>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:getComponent("lookupLocs").getValue();}]]></xp:this.value>
</xp:selectItems>
<xp:eventHandler event="onClick" submit="false">
<xe:this.script><![CDATA[XSP.openTooltipDialog("#{id:tooltipDialog1}", "#{id:label1}")]]></xe:this.script>
</xp:eventHandler></xe:djFilteringSelect>
  
<xe:valuePicker dialogTitle="Locs with Loc Manager"
for="djFilteringSelect1">
<xe:this.dataProvider>
<xe:simpleValuePicker>
<xe:this.valueList><![CDATA[#{javascript:getComponent("lookupLocs2").getValue();}]]></xe:this.valueList>
</xe:simpleValuePicker>
</xe:this.dataProvider>
</xe:valuePicker>
<xe:tooltipDialog id="tooltipDialog1"></xe:tooltipDialog></xp:td>
<xp:scriptBlock id="scriptBlock1">
<xp:this.value><![CDATA[XSP.addOnLoad(function(){
XSP.getElementById("#{id:djFilteringSelect1}").focus();
});]]></xp:this.value>
</xp:scriptBlock>
<xp:td style="width:229.0px">
<xp:message id="message1" for="loc"></xp:message>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:label id="label3" value="Work Category" style="font-weight:bold"></xp:label>
</xp:td>
<xp:td>
<xe:djFilteringSelect id="djFilteringSelect2"
rendered="true" value="#{document1.workCategory}" tabIndex="2">
<xe:this.defaultValue><![CDATA[""]]></xe:this.defaultValue>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:var db = new Array(#DbName()[0], 'TSCTT.nsf');
#DbColumn(db, "workCategoryView", 1)
}]]></xp:this.value>
</xp:selectItems>
</xe:djFilteringSelect>

You are very close to the solution you are looking for.
It is not really useful to set the hover tooltip function on dojoFilteringSelect field itself as it is then impossible to select a value there. Instead, like you suggested already, let the tooltip work on an icon or the field's label.
This is an example for a tooltip dialog appearing on hovering over label:
<xp:label value="Label" id="label1">
<xp:eventHandler event="onmouseover" submit="false">
<xp:this.script><![CDATA[
XSP.openTooltipDialog("#{id:tooltipDialog1}", "#{id:label1}")
]]></xp:this.script>
</xp:eventHandler>
<xp:eventHandler event="onmouseout" submit="false">
<xp:this.script><![CDATA[
XSP.closeTooltipDialog("#{id:tooltipDialog1}")
]]></xp:this.script>
</xp:eventHandler>
</xp:label>
<xe:djFilteringSelect id="djFilteringSelect1" rendered="true"
value="#{document1.loc}">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:
["abc","def","xyz"]
}]]></xp:this.value>
</xp:selectItems>
</xe:djFilteringSelect>
<xe:tooltipDialog id="tooltipDialog1" title="This is the dialog title">
<xp:text escape="true" id="computedField1">
<xp:this.value><![CDATA[#{javascript:
"This is the computed value"
}]]></xp:this.value>
</xp:text>
</xe:tooltipDialog>
Label's event "onmouseover" (not "onMouseOver"!) opens the tooltip dialog box. This event works only if you don't use the parameter for="djFilteringSelect1" ( I don't know why).
I added an event "onmouseout" which closes the tooltip dialog when mouse no longer hovering over label.
Instead of event "onmouseout", you can add same CSJS code to a close button inside tooltip dialog box. This is useful if you have things on tooltip dialog box you want to click on like links or editable fields.

If you use the tooltip and not the tooltipdialog than just use the for property and it will happen automatically, no code needed. Very simple.
In your code above you are using the onclick event, that will not work onMouseOver (which would be the event you need?)
Howard

Related

XPages - Bootstrap popover

I have an icon, which when you hover, pops up some extra information in a bootstrap popover
This works as expected, however, if I then click on any field on the page, which then does a partial refresh of a div containing the icon, it then loses the hover functionality.
Icon code:
<!--INFO BUTTON START-->
<xp:text escape="false" id="computedField4">
<xp:this.value><![CDATA[#{javascript:try{
var text = #DbLookup(#DbName(), "LookupKeywordLists", "Info"+compositeData.fieldName, "Members");
return " <i class='fa fa-info-circle' data-container='body' data-toggle='popover' data-trigger='hover' data-placement='right' data-content='"+text+"'></i>"
}catch(e){
openLogBean.addError(e,this.getParent());
}
}]]></xp:this.value>
<xp:this.rendered><![CDATA[#{javascript:try{
return compositeData.showInfoIcon;
}catch(e){
openLogBean.addError(e,this.getParent());
}}]]></xp:this.rendered>
</xp:text>
<!--INFO BUTTON END-->
Script block on the page:
<xp:scriptBlock id="scriptBlock1">
<xp:this.value><![CDATA[$(document).ready(function(){
$('[data-toggle="popover"]').popover({
trigger: 'hover',
title: 'Information'
});
});]]></xp:this.value>
</xp:scriptBlock>
The script block is currently outside the div that the partial refresh "refreshes" however I tried putting it within the div, which didn't resolve the issue. Any ideas? Thanks
You need to add the popover when the partial refresh occurs. In order to do so you use Dojo to subscribe to the partialrefresh-complete event.
This answer can help you: https://stackoverflow.com/a/49014247/785061.

Calling a Bootstrap modal dialog from xp:button and pass a scoped variable

I have a button (code below) that sits in a repeat control. When I click the button it sets viewScope.vsRLinkKey with a value from the viewEntry of the repeat and calls the bootstrap modal. The button needs to be set to norefresh because with a full refresh the Modal flashes on the screen, on a partial refresh the screen greys out but the modal does not appear. In my modal I set a computed field to display the vontens of viewScope.vsRLinkKey and it is always null. USing the Debug ToolBar I can see that the value of vsRLinkKey is set correctly but the modal does not pick up the value. So I believe that I have either a refresh issue or a scope issue, but in either case I need to pass the value of the field to the modal. None of my efforts have worked so far.
The question is how can I pass a context variable to the bootstrap modal control?
<xp:button value="Respond" id="button3" styleClass="btn btn-info btn-xs">
<span class="glyphicon glyphicon-send"></span>
<xp:this.attrs>
<xp:attr name="data-toggle" value="modal"></xp:attr>
<xp:attr name="data-target" value="#respModal">
</xp:attr>
</xp:this.attrs>
<xp:eventHandler event="onclick" submit="true"
refreshMode="norefresh">
<xp:this.action>
<![CDATA[#{javascript:viewScope.vsRLinkKey = reqEntry.getColumnValue("rLinkKey")}]]>
</xp:this.action>
</xp:eventHandler>
</xp:button>

xpages dojo filteringselect partial update onChange

I'm trying to do a partial update on an Edit Box ("Room") on the server onChange event of a dojo filteringselect control ("From_Name") on an xpage.
So, I use a simple Modify Field action with the computed value:
nm = getComponent("From_Name").value;
#DbLookup("names.nsf", "Full Name", nm, 10);
The onChange event also does a Partial Update to the "Room" element.
The problem is that there are a couple of more filteringselect controls on the form, and as I try to do the partial update to do the lookup into the address book to get the person's room number, it gives me the yellow exclamation point error for the other filteringselects on the xpage. If all the other filteringselect controls on the page are filled out first, then the partial update works. How do I get around this and update the Room field when, the From_Name is changed?
The code for my control:
<xe:djFilteringSelect id="From_Name" value="#{document1.From_Name}"
readOnly="# {javascript:!document1.isNewNote()}">
<xe:this.defaultValue><![CDATA[#{javascript:
#Name("[CN]", #UserName())}]]>
</xe:this.defaultValue>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:
db = new Array("SERVER", "names.nsf");
#Unique(#DbColumn(db, "Full Name", 1))
}]]></xp:this.value>
</xp:selectItems>
<xp:eventHandler event="onChange" submit="true"
refreshMode="partial" refreshId="Room">
<xe:this.action>
<xp:modifyField name="Room">
<xp:this.value><![CDATA[#{javascript:
nm = getComponent("From_Name").value;
#DbLookup("names.nsf", "Full Name", nm, 10);
}]]></xp:this.value>
</xp:modifyField>
</xe:this.action>
</xp:eventHandler>
</xe:djFilteringSelect>
Add a Dojo attribute required with value false to the other djFilteringSelect controls:
<xe:this.dojoAttributes>
<xp:dojoAttribute
name="required"
value="false">
</xp:dojoAttribute>
</xe:this.dojoAttributes>
With this additional client side attribute you won't get the yellow exclamation point errors anymore.

Image not displayed in xe:basicContainerNode from Extension Library in XPages

I have the following code for a popupmenu from Extension library
<xe:popupMenu id="pop">
<xe:this.treeNodes>
<xe:basicContainerNode image="/vwicn148.gif" label="Container">
<xe:this.children>
<xe:basicLeafNode label="Child" image="/vwicn148.gif"></xe:basicLeafNode>
</xe:this.children>
</xe:basicContainerNode>
</xe:this.treeNodes></xe:popupMenu>
<xp:link escape="true" text="Open popup" id="link1">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[XSP.openMenu(thisEvent,#{javascript:getComponent('pop').getMenuCtor()})]]></xp:this.script>
</xp:eventHandler>
</xp:link>
The result looks like this
As you can see the image for the basic containerNode is not displayed but the image for the basicLeafNode is displayed.
I want to add an arrow to the container node so that users know it has sub items, how can I do that?
Using firebug I can see that the image icon for the basicContainerNode has the class "dijitNoIcon" added to it, which sets "display:none" for the icon image. Whereas the leaf node does not have that dijiNoIcon class added. (I might need to look into that further as a possible defect)
But, as a workaround you could use some custom CSS to override what dijitNoIcon is doing.
<xe:basicContainerNode image="/vwicn148.gif" label="Container" styleClass="showIcon">
And add a custom css file to your application with the following:
.showIcon .dijitNoIcon{
display: block;
}

Dojo: click on the tab

I need to attach onClick event to tab, not to its content. For example, viewing the example, I want the event firing when I click "Drinks" tab.
The following code results in firing event when I click on tab's content, so it is not what I need:
<div
dojoType="dijit.layout.ContentPane"
href="test.php"
onClick="alert(1);"
>
</div>
Attaching event to tab container results in firing event when click both tabs and tab content.
You want to connect to the event onShow. Take a look at the "Event Summary" heading in the reference documentation:
http://dojotoolkit.org/api/dijit/layout/ContentPane
<div dojoType="dijit.layout.ContentPane" href="test.php" onShow="console.log('I'm being shown')"></div>
maybe you can write a something like this :
dojo.connect(
dojo.byId("myTab"),
"onclick",
function(){
alert('click');
}
);