How do I get the category filter to work with Xpages cloud tag - xpages

I have set up a tagcloud from the extension library in Xpages. But what I cannot get to work is when the user clicks on a cloud tag entry, they go to the categorized view but it doesn't position to that category or subset to only that category.
I checked the Xpages Extension Library demo and can't figure out how it is supposed to work.
Any help would be greatly appreciated.
Bryan

You can show all entries from view for a clicked tag:
(1) Create a categorized view in which the tags you want to show are in first categorized column. Add in following columns the values you want to show for a tag.
(2) Put in dominoViewCloudData this view name, the XPage which has to be called when a tag is selected and the parameter name for url where the selected tag will be provided
<xe:dominoViewCloudData
...
viewName="yourViewName"
linkTargetPage="/TagViewEntryList.xsp"
linkRequestParam="tag">
</xe:dominoViewCloudData>
(3) Create the target XPage with a view control and set the categoryFilter to selected tag. You can read the tag from url with param['tag']. If your tag can contain space characters then you have to replace the "+" from url back to space with replace()
<xp:viewPanel
...
<xp:this.data>
<xp:dominoView
var="view1"
viewName="yourViewName">
<xp:this.categoryFilter><![CDATA[#{javascript:
var tag = param['tag'];
if(tag) {
return tag.replace("+", " ");
} return null}]]>
</xp:this.categoryFilter>
</xp:dominoView>
</xp:this.data>
<xp:viewColumn
...
</xp:viewColumn>
</xp:viewPanel>

Related

xpages: how to simulate form's auto launch properties

Is there a quick and easy way to convert forms that have auto launch first attachment and/or launch URL?
I know it can be coded in SSJS but I was just wandering if someone had a quick way of doing this.
Thanks
The following Domino URL command will open an attachment ...
http://Host/DatabaseName/View/DocumentName/$File/fileattachmentname
... where the DocumentName is effectively the lookup value shown in the first column which is sorted.
Add an xp:link control and code it open the attachment (in this example in a new window). For example, the following is an xp:link that could be added in an xp:viewColumn or xp:repeat or any iterator control. In this example the var for the iterator is set to "rowData" and the name for the link is returned from the ListName column and the url to launch the attachment is in the cLinkUrl column.
<xp:link escape="true" id="link1" target="_blank">
<xp:this.text><![CDATA[#{javascript:rowData.getColumnValue("ListName");}]]></xp:this.text>
<xp:this.value><![CDATA[#{javascript:rowData.getColumnValue("cLinkUrl")}]]></xp:this.value>
</xp:link>
Since I wanted the code to be in the xpage, as it opens up either the document or the attachment depending on roles, I ended up adding this to the beforepageload event of the xpage (still need to add the role check to this though):
<xp:this.beforePageLoad>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:var url = currentDocument.getDocument().getHttpURL();
var attachmentName = #AttachmentNames();
facesContext.getExternalContext().redirect(url.replace("?OpenDocument","/$File/"+attachmentName+"?OpenElement&target=_new"));}]]></xp:this.script>
</xp:executeScript>
</xp:this.beforePageLoad>

Customize Summary Detail Link in xPages Dataview

I'm using the DataView control from the xPages Extension Library and I would like to use the summary column link to expand rather than open a separate xpage with the current document. What is the best way to achieve this? I thought of using jQuery to click/trigger the expand link but I can't figure out how to pass the current row of the view into a javascript function in the summary column href property. Another option would be to call the same JS that the expand link is calling but that AJAX code seems to be sufficiently abstracted so as to not show up in a cursory analysis of the HTML code generated.
Update: added screen shot
Add CSJS code to viewSummaryColumn's href property to "click" on show/hide details image instead of opening the document.
Find the id of the details element
var id = '#{id:details}'
calculate the image id
id = id.replace(':details', '_shimg')
get parent's link element
var link = document.getElementById(id).parentElement
"click" the link
link.click()
"details" is the id of detail facet's panel. Your code should look like this:
<xe:dataView
...
collapsibleDetail="true">
<xp:this.facets>
<xp:panel
id="details"
xp:key="detail">
...
</xp:panel>
</xp:this.facets>
...
<xe:this.summaryColumn>
<xe:viewSummaryColumn
...
href="javascript:document.getElementById('#{id:details}'.replace(':details', '_shimg')).parentElement.click()">
</xe:viewSummaryColumn>
</xe:this.summaryColumn>
</xe:dataView>

xpages display a new doc. inside a dialog

i have an issue that it gives me some headache lately.
In my XPage there is a view displaying some docs ( let say Pdoc as datasource ) and I open/create them inside a <xe:dialog>. This dialog has only Pdoc declared as datasource, and it inherits some values from the Xpage datasrouce. My clickable column formula is:
// some var declarations
var formName = rowData.getDocument().getItemValueString("Form");
if ( formName == "fmP" )
{ viewScope.put("dlgDocUnid", pe.getUniversalID())
getComponent("exampleDialog").show(); }
On the same XPage, I can create a new Pdoc using the same dialog via a button, New Pdoc.
The problem is: when I opened an existing Pdoc and then just save it or close it, and after I use the button to create a newNote => the old / previous ( already saved Pdoc ) is showed...
If firstly I just created a new note Pdoc, it works, and it is showing a new empty Pdoc.
My dialog data code:
<xp:this.data>
<xp:dominoDocument var="Pdoc" formName="fmPersContact"
ignoreRequestParams="true" scope="request" action="editDocument">
<xp:this.documentId><![CDATA[#{javascript:viewScope.get("dlgDocUnid");}]]></xp:this.documentId>
</xp:dominoDocument>
</xp:this.data>
I use the .documentId for the open method from the viewPanel. I think here is the problem. I think ,( I'm not sure), I should compute this documentId in such way that when I create a newNote this documentID shouldn't be anymore the viewScope.get("dlgDocUnid").
Thanks for your time.
If I understood correctly, you have defined two data sources within the XPage and you try to consume them in the dialog, right? Instead I suggest defining a single data source within a panel inside the xe:dialog.
I have blogged about a similar example. In this example, tooltip dialog has been used but it's the same logic, you might replace xe:tooltipDialog with xe:dialog.
http://lotusnotus.com/lotusnotus_en.nsf/dx/mini-patterns-for-xpages-parameter-editing-with-dialogs-1.htm
The idea here is that you use a viewScope variable named noteId. To open an existing document, set this variable to the note id of the existing document. To create a new document, the value will be set as NEW. Then you define the data source within the dialog according to this variable:
<xe:dialog>
<xp:panel style="width:500.0px">
<xp:this.data>
<xp:dominoDocument
var="document1"
formName="Parameter"
action="#{viewScope.noteId eq 'NEW'?'createDocument':'editDocument'}"
documentId="#{viewScope.noteId eq 'NEW'?'':viewScope.noteId}"
ignoreRequestParams="true">
</xp:dominoDocument>
</xp:this.data>
..... Dialog content ....
</xp:panel>
</xe:dialog>
When you put the data source inside the dialog, you don't refresh the page to load or prepare data sources before launching the dialog which is your current problem I guess.
Could it be that you forgot to deactivate the flag to ignore request parameters.
Sounds like the dialog is always associated with the current document instead of the parameters from the docid

Can I prevent embedded view from putting a database on the workspace?

I have two databases, A and B. I want to surface a view from B into A. I can do this using an embedded view in an outline or a form and it works fine.
But I do not want database B put on a user's workspace. If I add it and the user opens a doc or opens the view, then it puts that db on the workspace.
Is there a way around this? What if I embed an Xpage?
That's a built-in behavior of Lotus Notes and unfortunately there's no way to turn that behavior off.
As an alternative you could write an Agent that pulls the data in from Database B into Database A, and then just display that data within a Database A view.
As Ken already said that it is a built-in behavior. You can try to programmatically remove the database icon. This Technote describes it.
#Command([AddDatabase]; "Server Name":"DatabaseB.nsf");
#Command([WindowWorkspace]);
#Command([FileDatabaseRemove]);
I haven't tried it myself, but you can put this code on close of form of embedded view. Also, its not possible to remove a database icon from the Notes client workspace using LotusScript, JavaScript, or Notes API.
It works as Naveen describes it. However, even if you manage to clean up the icon, in Notes there is a built-in fault when using an embedded view from another database.
The problem is -- you cannot use the traditional Notes templates because the link to the source database of the embedded view is hard-coded using the replicaid. So if you pull a template from your design and create a new database for production, the embedded view will still point to your test database.
I have used this configuration, but then each time you deploy a new template you need to modify design, so that it points to the correct database. It can be programmed for example by using DXL export/import but is not a trivial Notes deployment any more.
Multiple options here: computed text to display the contents of the view using HTML, creating an Xpage that displays the view, or some AJAX to get the data and display in HTML.
Computed text to display the view
This is relatively simple. Add computed text, set to use pass-through HTML, that does a DbColumn on a new view in the source database. Either add a hidden column at the end of the existing view or create a new, single column view that has the HTML for a single row in the view.
For the computed text, just a simple formula:
"<table>" + #DbColumn( "Notes" : "NoCache" ; "MyServer/Company" : "SourceDatabase.nsf" ; "HTMLview" ; 1) + "</table>"
Then, for the column formula, use something like this:
"<tr><td>" + PartName + "</td><td>" + PartNumber + "</td><td>" + Price + "</td></tr>"
XPage for view
Just create the XPage with a simple view, like this:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:viewPanel rows="30" id="viewPanel1">
<xp:this.facets>
<xp:pager partialRefresh="true" layout="Previous Group Next" xp:key="headerPager" id="pager1">
</xp:pager>
</xp:this.facets>
<xp:this data>
<xp:dominoView var="view1" viewName="COPApprovals"></xp:dominoView>
</xp:this.data>
<xp:viewColumn columnName="$11" id="viewColumn1" style="font-weight:bold;color:rgb(0,0,160)">
</xp:viewColumn>
<xp:viewColumn columnName="$10" id="viewColumn2" style="font-weight:bold;color:rgb(0,64,0)">
</xp:viewColumn>
<xp:viewcolumn columnName="$12" id="viewColumn3">
</xp:viewColumn>
</xp:viewPanel>
</xp:view>
AJAX
A good intro to using AJAX to display Notes data can be found in Scott Good's AJAX name-picker. I've built a number of views and picklists using that format. The laptop that has the modified designs is on the fritz right now. If I get access again, I will post samples.
Hope you get some ideas there.

Show custom controls on webpage in other order than layed out in DDE - Xpages

I have a number of custom controls layed out on an xpage. I want these controls to be displayed in the order of a setting in a notes document
So my xpage might look like this in DDE
CustomControl1
CustomControl2
CustomControl3
CustomControl4
but when the custom control is displyed on the webpage the custom controls should be displayed in the following order (based on the setting document)
CustomControl4
CustomControl1
CustomControl2
CustomControl3
anyone have any ideas how to accomplish this (server side)
You can use the xp:switchFacet in combination with a xp:repeat to calculate the order at runtime like this:
<xp:repeat
id="repeat1"
rows="30"
var="rowEntry">
<xp:this.value><![CDATA[#{javascript:var arr = ["Control1","Control3","Control2"];return arr;}]]></xp:this.value>
<xe:switchFacet
id="switchFacet1"
selectedFacet="#{javascript:rowEntry}">
<xp:this.facets>
<xp:panel xp:key="Control1">Control1</xp:panel>
<xp:panel xp:key="Control2">Control2</xp:panel>
<xp:panel xp:key="Control3">Control3</xp:panel>
</xp:this.facets>
</xe:switchFacet>
</xp:repeat>
Instead of the Array arr you can use data based on a document or xsp.propertie. The Output of this code is Control1 Control3 Control2 and in your Designer you have your controls inside switchFacet in following order: Control1 Control2 Control3.
Without knowing the real pain of your project I can only assume that the individual position needs to be defined at runtime, or something like that.
In general: controlling a page's layout is a pure CSS job. On the resulting page almost anything can be positioned almost anywhere within the page's range, and it doesn't matter where it was placed at design time. So, if you enclose your custom controls within their own containers (panels / divs) then you should be all set. You might define positioning classes in CSS and then have some SSJS code decide which class is assigned to what div.
If for example you have a custom control for each day of the week, and you always want to have the current day at the top-most position, then you could define 7 css classes as in ".today", ".todayPlus1", ".todayPlus2" ... ".todayPlus6". Write your positioning rules for each class. And finally compute each panel's styleClass property based on the current week day.

Resources