Why can't my xpage see the views in another database? - xpages

(This is XPages app for a web browser) I created a view panel for a view from another database. The view showed up empty, even though I can clearly see about 15 documents in it using the Notes client. Here is the view source...
<xp:viewPanel rows="30" id="viewPanel3">
<xp:this.facets>
<xp:pager partialRefresh="true"
layout="Previous Group Next" xp:key="headerPager" id="pager2">
</xp:pager>
</xp:this.facets>
<xp:this.data>
<xp:dominoView var="view3"
databaseName="test\Customer\part.nsf"
viewName="LkpMscParts-55EQUIPMENT">
</xp:dominoView>
</xp:this.data>
I verified the ACL, refreshed the view index, even ran fixup on the database. The page still won't show the documents. (No readers fields, btw)
So, then I added a computed field to show me what's going on.
var filepath = database.getFilePath();
var partfile = filepath.toLowerCase().replace("ereq_main","part");
var partdb = session.getDatabase(database.getServer(),partfile,false);
print("partdb views total = "+partdb.getViews().length)
for(x=0;x<partdb.getViews.length;x++){
print("v name = "+partdb.getViews[x].getName());
}
print("partdb server = "+partdb.getServer());
print("partdb title = "+partdb.getTitle())
var vname = "LkpMscParts-55EQUIPMENT";
sessionScope.PartViewName = vname;
var pview = partdb.getView(vname);
if(pview==null){
sessionScope.PartViewError = "Nothing for LkpMscParts-55EQUIPMENT.";
print("pview is null")
return null;
}
var vecol = pview.getAllEntries();
print("partdb = "+partdb.getFilePath());
print("pview = "+pview.getName());
print("pview lines = "+pview.getRowLines());
print("vecol count = "+vecol.getCount())
return vname;
I get this on the console:
11/18/2017 08:10:48 PM HTTP JVM: partdb views total = 0
11/18/2017 08:10:48 PM HTTP JVM: partdb server = CN=domsvr3/O=abc
11/18/2017 08:10:48 PM HTTP JVM: partdb title = Inventory Parts
11/18/2017 08:10:48 PM HTTP JVM: partdb = test\Customer\part.nsf
11/18/2017 08:10:48 PM HTTP JVM: pview =
and then a crash
Script interpreter error, line=27, col=46: [TypeError] Exception occurred calling method NotesView.getRowLines() Notes error: Invalid or nonexistent document (LkpMscParts-55EQUIPMENT)
Notes error: Invalid or nonexistent document (LkpMscParts-55EQUIPMENT)
Notice the length of the views array is 0 - what gives? There's probably 200 views in the db. The database server is correct, the title is correct and the path is correct. So, it appears like it can see the correct database. But, then the view name comes out blank. So, pview isn't null (cuz I checked for that) but yet it's empty. I don't get it. Such a simple thing is driving me nuts.
Just fyi, I've been working with xpages now for about 5 years, so I'm sure I'm missing something simple, but I just can't 'see the forest for the trees'. Can someone please point me in the right direction?

Do you get that database elsewhere in code in the application? If so, are you calling .recycle() on that Database object?
One of the things I learned early in moving to Java is that if you recycle a handle to a Database, getters that return primitive values (e.g. Strings) will still return the value. Presumably it gets cached. So getTitle() and getFilePath() will still return a value, but anything getting something more complex will not work. It's a number of years since I did that, but I think it does just return nothing.
On the rare occasion I still have to recycle (I use ODA for virtually all projects), I only recycle in loops. The maximum handles per session is so high there's no risk of "PANIC: Lookup handles out of range" for the number of Domino objects outside of loops.

If you are using "No Login/Anonymous" for your web access,
then make sure that "Public Access" is setup
in your CustomerParts.nsf -- in all the following ways:
The ACL for the role "Anonymous" allows "Read Public Documents";
Each document on that view has a field "$PublicAccess" set as text "1" ;
That target view is set as "Public Access" -- via security "key" tab, on the view's "property box";
Otherwise instead, if you do login on the web, then --verify all is ok, on that view's security "key" tab.

Related

beforePageLoad failing when a view column is computed

I've got a view control which opens an xpage. When the xpage opens, the beforePageLoad event fires. It checks to see if there are any attachments in a particular field of the document being opened and if there are, it returns list of the filenames. This was working fine. Then, I was asked to change what's displayed in one of the columns of the view. I added a variable to the view control's data section to access the row. I then added some javascript to the column to display the data differently. That worked and it displayed the data as wanted. However, when I now click on the link to open the xpage, when the beforePageLoad event fires, the code that's there now fails. It fails with this error at the starred line:
Script interpreter error, line=9, col=49: 'closureField' is null at
[/Function_ReturnListOfClosureAttachmentNames.jss].ReturnListOfClosureAttachmentNames(CCEB1351591847CB85257E7C005EF68C)
function ReturnListOfClosureAttachmentNames(ltDoc ){
var closureAttachmentFileNames = "";
var thisLT = ltDoc;
var closureField:NotesRichTextItem = thisLT.getFirstItem("closeAttachments");
*>>> var eos:java.util.Vector = closureField.getEmbeddedObjects();<<<
var eosi:java.util.Iterator = eos.iterator();
while (eosi.hasNext()) {
var eo:NotesEmbeddedObject = eosi.next();
closureAttachmentFileNames = closureAttachmentFileNames +","+eo.getName();
}
return closureAttachmentFileNames;
}
I call this function from the beforePageLoad event and pass it currentDocument.getDocument(). I think I might have lost the document context after changing the column display data from 'view column' to 'computed value' but I'm not sure. Any ideas would be appreciated.
thanks!
Clem
Figured it out: When I assigned a variable to the view, when you click on a linked column in that view, it loads the current ViewEntry into the context and not a current document. So I put the unid of the doc from the selected ViewEntry in an application scope variable and returned it to the Document Id property when I open the xPage. I have to now update all my views but there aren't too many luckily. Thanks for working through this with me!
Clem –

Value not reflected on change in ItemCommand within RadGrid

I am having a RadGrid which contains MasterTableView and a DetailView. I am trying to change the value of Sub Total present in MasterTableView on deleting DetailView Row. I am able to get the control in Parent Table and am able to change the value. However value is not reflecting. I tried multiple options e.g. Rebind() method as well as e.Item.OwnerTableView.DataBind(). Here is what my ItemCommand function looks like
Private Sub dbgView_ItemCommand(ByVal source As System.Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles dbgView.ItemCommand
If e.CommandName.ToLower.Equals(GlobalConstants.Key_Delete_CommandName) And e.Item.OwnerTableView.Name = "Tax" Then
dataItem = DirectCast(e.Item.OwnerTableView.ParentItem, GridDataItem)
Dim numSubTotal As NumericBox = dataItem.FindControl("numAmount")
numSubTotal.Text = "New Value"
' e.Item.OwnerTableView.DataBind()
End If
Can someone help me understand why the new value is not reflecting? Here is how my grid looks like
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="dbgView">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="dbgView"></telerik:AjaxUpdatedControl>
</telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadGrid ID="dbgView" runat="server" AutoGenerateColumns="False" AllowPaging="True"
PageSize="5" GridLines="Horizontal" Skin="Office2010Blue" Style="border: 0 none"
AllowAutomaticInserts="True">
<PagerStyle Mode="NumericPages"></PagerStyle>
<MasterTableView Width="100%" CommandItemDisplay="Top" Name="GLLine" AllowNaturalSort="False"
PageSize="10" DataKeyNames="Key" NoDetailRecordsText="No records to display.">
<DetailTables> .....
UPDATE
On doing further digging i got to know that i need to Rebind the grid post my operation is performed. However while i am performing Rebind, i am getting exception
[HttpException (0x80004005): DataBinding: 'System.Collections.DictionaryEntry' does not contain a property with the name 'TaxID'.]
System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +384
Telerik.Web.UI.GridTableView.PopulateDataKey(Object dataItem, DataKey key, String name) +457
Telerik.Web.UI.GridTableView.PopulateDataKeys(Object dataItem) +241
However i don't get this issue during my normal operations. I am able to find out this datakey otherwise for all normal operations. What might be going wrong?
Update
As per below link from Telerik, master table would not be updated when a detail table row is deleted.
http://www.telerik.com/forums/master-grid-not-rebinding-after-detail-table-delete-command
I am trying Rebind exactly mentioned as in this website. However i am getting exception for DataKeyValues as mentioned above. Any pointers would really help.
Issue has been resolved !! I got lot of links which directed me to perform Rebind() operation. However that started creating multiple other issues. This issue was handled by writing a Javascript method handling onclick event of GridButtonColumn by Passing control ids of field from DetailView and Master Table View.

How do I access the column names of a view datasource in sortColumn?

I have a custom control that displays a view based off some configuration documents. We had been storing the sortColumn in a sessionScope variable, so that the user could retain the sort when they leave and return to the Xpage. Unfortunately, if they leave for another Xpage that has the same custom control, but for which the view doesn't have a column by the same name, it throws an error.
So, I thought I could check the columnNames of the view so that we don't try using a sortColumn that doesn't exist. I have been unable to get a handle to the view data source while also applying the sortColumn.
<xp:dominoView var="inputView" sortOrder="#javascript:sessionScope.sortedColumnDirection}">
<xp:this.sortColumn><![CDATA[#{javascript:var nameVector:java.util.Vector = inputView.getColumnNames();
var nameArray = sessionScope.curDynamicViewSettings.columnTitles;
if ( #IsMember(viewScope.sortedColumnName,nameArray)) {
return viewScope.sortedColumnName;
}
return;}]]>
</xp:this.sortColumn>
</xp:dominoView>

getColumnValues vs cycle through a NotesViewNavigator

in this post Return from first column of a categorized view when using readers fields I raised the issue that if I do getColumnValue(0) on a categorized view I just the unique category values, but because of Reader fields there could be categories that the user does not have access to the documents under it. The other option is to create a NotesViewNavigator and iterate through the navigator and build a treeMap of the values.
My concern is that the view could contain thousands of entries and it would have to cycle through all the entries to build the category list which would typically have maybe 10 -12 entries.
So my question is what is the performance hit and scalability of the NotesViewNavigator process and/or is there a better way to get the categories in a view and recognize the users Reader rights.
New Edits
Can't seem to get this to work. I have a single categorized view and use this code WFSUtils.sysOut() simply prints to the console.
vw.setAutoUpdate(false);
var nav:NotesViewNavigator = vw.createViewNav();
nav.setEntryOptions(NotesViewNavigator.VN_ENTRYOPT_NOCOUNTDATA);
nav.setBufferMaxEntries(400);
nav.setMaxLevel(0);
var rtn:java.util.TreeMap=new java.util.TreeMap();
var entry:NotesViewEntry = nav.getFirst();
try{
while (entry != null){
WFSUtils.sysOut("Entry not null");
var thisCat:String = entry.getColumnValues().firstElement().toString();
WFSUtils.sysOut("thisCat = " + thisCat);
rtn.put(thisCat,"Nothing");
WFSUtils.sysOut("did put " + thisCat)
var tEntry:NotesViewEntry = nav.getNextCategory(entry);
entry.recycle();
entry = tEntry;
tEntry.recycle();
}
viewScope.put("vsCats", rtn.keySet());
}catch(e){
WFSUtils.sysOut("Error in getCategory " + e.toString())
}
the console print out is this:
25/08/2014 11:47:36 AM HTTP JVM: Get Navigator
25/08/2014 11:47:36 AM HTTP JVM: Entry not null
25/08/2014 11:47:36 AM HTTP JVM: thisCat = Approved~Bill Fox^WFS Automated Back end Process Example
25/08/2014 11:47:36 AM HTTP JVM: did put Approved~Bill Fox^WFS Automated Back end Process Example
25/08/2014 11:47:36 AM HTTP JVM: Error in getCategory Method NotesViewNavigator.getNextCategory(lotus.domino.local.ViewEntry) not found, or illegal parameters
The view has 9 categories so I would expect it to do 9 getNextCategories. I changed it to do getNext and the console out put is:
25/08/2014 11:52:42 AM HTTP JVM: Get Navigator
25/08/2014 11:52:43 AM HTTP JVM: Entry not null
25/08/2014 11:52:43 AM HTTP JVM: thisCat = Approved~Bill Fox^WFS Automated Back end Process Example
25/08/2014 11:52:43 AM HTTP JVM: did put Approved~Bill Fox^WFS Automated Back end Process Example
25/08/2014 11:52:43 AM HTTP JVM: Entry not null
25/08/2014 11:52:43 AM HTTP JVM: Error in getCategory Exception occurred calling method NotesViewEntry.getColumnValues()
25/08/2014 11:52:43 AM HTTP JVM: null
so it fails on the getColumnValues which worked on the first time through but not the second - not sure where the JVM: null is coming from.
any ideas greatly appreciated.
It looks like the View-design-level option "Don't show empty categories" does this for you - I'd previously assumed it was just a tip-off to the client to hide them, but it looks like it affects the behavior of ViewNavigator as well (which otherwise would show the full categories as well).
Once you have that checked, something like this may do the trick:
List<String> categories = new ArrayList<String>();
View view = database.getView("Some View");
view.setAutoUpdate(false);
ViewNavigator nav = view.createViewNav();
nav.setEntryOptions(ViewNavigator.VN_ENTRYOPT_NOCOUNTDATA);
nav.setBufferMaxEntries(400);
nav.setMaxLevel(0);
ViewEntry entry = nav.getFirst();
while (entry != null) {
Vector<?> columnValues = entry.getColumnValues();
String category = String.valueOf(columnValues.get(0));
categories.add(category);
entry.recycle(columnValues);
ViewEntry tempEntry = entry;
entry = nav.getNext();
tempEntry.recycle();
}
I believe that that should be the fastest/safest way to do it at that point. setMaxLevel(0) means that the first/next operations will include only categories (or whatever is your top level), while the other ViewNavigator settings are for performance tweaking.
No, I don't think you have to cycle through all the entries. Without having Domino Designer at hand right now, this is a bit of a rough guess (usually I do a quick test drive before answering here), but I'm quite confident it should work like this:
Just get to the first entry which in your case must be a category, then use .getNextSibling or .getNextCategory (careful if the view has multiple category levels!) jumping from category to category, and skipping all the other entries.
Depending on how the view index is set up, you might also check if there are any children available.
Just to be complete: make sure you set the parent view's AutoUpdate property to false; depending on the size of the view you might also want to experiment with various cache sizes; and of course don't forget to recycle, but you know that, I guess ;)
See also here (= AutoUpdate), here (= recycle properly) and here (= performance tip).
Hope this helps

Coded UI Test SetProper issues

public HtmlComboBox NetworkSelectBox
{
get
{
HtmlComboBox networkSelectBox = new HtmlComboBox(ConfigVMPage);
networkSelectBox.SearchProperties[HtmlComboBox.PropertyNames.Id] = "vnic";
networkSelectBox.SearchProperties[HtmlComboBox.PropertyNames.Name] = "vnic";
networkSelectBox.FilterProperties[HtmlComboBox.PropertyNames.ControlDefinition] = "style=\"WIDTH: auto\" id=vnic name=vnic r";
return networkSelectBox;
}
}
Above is the code I define an UI element and I want to set the property
NetworkSelectBox.SelectedItem = "LabNetworkSwitch";
I've used this way on other elements and all success, but in this one i got the error message
Microsoft.VisualStudio.TestTools.UITest.Extension.ActionNotSupportedOnDisabledControlException: Cannot perform 'SetProperty of SelectedItem with value "LabNetwokrSwitch"' on the disabled or read-only control.
How can I change the control type?
I don't think you want to change the control type. I would suggest trying either waitforready() or find(). What is likely happening is when the control is initially found it is disabled, and find() will sync the actual control with the current networkSelectBox. WaitForReady() is probably the preferable method here though it will implicitly refresh the values of the combo box until it is available for input or the time out has expired.
I doubt you will run into this issue with HtmlComboBoxes but with a couple of WinComboBoxes I have had issues where they could not be set using SelectedItem or SelectedIndex. I ended up doing KeyBoardSendkeys(Combobox,"firstLetterOfItem") until the selected value was correct.

Resources