In a xpage, it requires user to login. After the user login, there is a view shows the information that belongs to the logged in user.
Please find the xpage code below for your review: (please note, the view in Lotus Client contains various columns e.g. UserName, UserID, etc., but in xpage, due to the user needs to login, so I do not display the user name in the xpage)
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:viewPanel rows="30" id="viewPanel1" pageName="/BookVenue.xsp" viewStyle="width:700.0px">
<xp:this.data>
<xp:dominoView var="view4" viewName="UserBookedVenueInfo">
</xp:dominoView>
</xp:this.data>
<xp:viewColumn columnName="Venue" id="viewColumn1" displayAs="link">
<xp:viewColumnHeader value="Venue" id="viewColumnHeader1" sortable="true">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:viewColumn columnName="ReturnDate" id="viewColumn2" displayAs="link">
<xp:viewColumnHeader value="Return Date" id="viewColumnHeader2" sortable="true">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:viewColumn columnName="Remarks" id="viewColumn3" displayAs="link">
<xp:viewColumnHeader value="Remark" id="viewColumnHeader3" sortable="true">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:this.facets>
<xp:pager partialRefresh="true" layout="Previous Group Next" xp:key="footerPager" id="pager1">
</xp:pager>
</xp:this.facets>
</xp:viewPanel>
</xp:view>
About the view, I use formula to get the data
tmp:=#Name([CN];#UserName);
SELECT Form = "BookVenue" & UserName =tmp
When I preview the xpage in the browser (Internet Explorer), the view can display the relevant data. However, when I close the browser, I use another account to login, the view shows the previous user's information.
Please consider the following scenario, at the first time, I use tester A account to login, the view can show information related to tester A. Then I close the browser, and reopen the xpage, it requires me to login so I use tester B account to login, the view shows the information related to tester A. I close the browser and use tester C account to login, the view still shows the information related to tester A.
Suppose I use tester C account to login and the view still shows the information related to tester A. I do not close the browser. In the view, I change the formula to this:
SELECT Form = "BookVenue" & UserName = #Name([CN];#UserName)
I refresh the browser, the view shows the data related to tester C. Then I close the browser and use tester B account to login. The view displays the data related to tester C.
The strange thing is, when I change the formula and refresh the browser, the view shows the proper data related to the logged in user.
tmp:=#Name([CN];#UserName);
SELECT Form = "BookVenue" & UserName =tmp
Why the view "remember" the previous logged in user's information?
I always think if the user login to the xpage, then when the user close the browser, the connection between the user and the xpage is closed. (maybe my concept is not correct)
If I keep change the formula in the view respectively, the view can show the proper data related to the user.(I have no idea why this approach works.)
My question is how to refresh the view when different user login? I guess the problem is in the formula:
tmp:=#Name([CN];#UserName);
SELECT Form = "BookVenue" & UserName =tmp
and
SELECT Form = "BookVenue" & UserName = #Name([CN];#UserName)
However I search on the internet #Name([CN];#UserName) is correct to get the username. I also recreate the view and the xpage again but the result is the same. I still need to the change the formula in the view to refresh the view in xpage.
Would someone let me know my mistake please? Thank you.
Reference:
http://www.ibm.com/support/knowledgecenter/SSVRGU_9.0.0/com.ibm.designer.domino.main.doc/H_USERNAME.html
You cannot use #Username in view selections (see comment above).
Nevertheless you can achieve this by the following solution design:
- Create a view with a categorized column which displays the Username
- in The View Panel, add a "Filter by category name " calculated using session.getEffectiveUserName()
The XPage below uses a view named "view" with a "cat" field which contains the username to filter.
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.data>
<xp:dominoView var="view1" viewName="view"
categoryFilter="#{javascript:session.getEffectiveUserName()}">
</xp:dominoView>
</xp:this.data>
<xp:viewPanel value="#{view1}" id="viewPanel1">
<xp:this.facets>
<xp:pager partialRefresh="true" layout="Previous Group Next"
xp:key="headerPager" id="pager1">
</xp:pager>
</xp:this.facets>
<xp:viewColumn columnName="cat" id="viewColumn1">
<xp:this.facets>
<xp:viewColumnHeader value="Cat" xp:key="header"
id="viewColumnHeader1">
</xp:viewColumnHeader>
</xp:this.facets>
</xp:viewColumn>
<xp:viewColumn columnName="subject" id="viewColumn2">
<xp:this.facets>
<xp:viewColumnHeader value="Subject" xp:key="header"
id="viewColumnHeader2">
</xp:viewColumnHeader>
</xp:this.facets>
</xp:viewColumn>
</xp:viewPanel></xp:view>
Please be aware that using this solution all users still can access and read all documents (in theory). If you want to make the documents unavailable, you should implement reader fields. More information can be found here http://www.ibm.com/developerworks/lotus/library/reader-names/
Related
I found steps to customize Notes Web search form but the submission button in the search form is not shown. In the below question, questioner also says the same thing. He seemed it was solved but did not write the cause.
http://www-10.lotus.com/ldd/nd6forum.nsf/0/cad751696e7486ef852571d300478a5c?OpenDocument
Perhaps I have a mistake something but I'm not idea how to solve this. Please advise me!
Old-style web forms are often very difficult to handle in Domino. Luckily there's something much better, really: XPages. If you have a fairly recent server, R9.0.x or better, try to make a simple XPage:
Create a new XPage
Add a Edit Box from the Core Controls (don't worry about the layout)
In the Properties, set the Data to Advanced/Use Scoped Variable, viewScope, and type a name, e.g. ftquery
Add a View from the list of Container controls
Select an existing view from the current database
In the View/Data Properties, set Search in view results to Computed, EL and viewScope.ftquery
Attach the Pager to the viewPanel...
Here's a sample, you can paste it in the Source tab of the new XPages and modify it to your liking.
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:label value="FT Query" id="label1" for="inputText1"></xp:label>
<xp:inputText id="inputText1" value="#{viewScope.ftquery}">
</xp:inputText>
<xp:viewPanel rows="30" id="viewPanel1">
<xp:this.facets>
<xp:pager partialRefresh="true" layout="Previous Group Next" xp:key="headerPager" id="pager1" for="viewPanel1"></xp:pager>
</xp:this.facets>
<xp:this.data>
<xp:dominoView var="view1" viewName="Put-here-your-view" search="#{viewScope.ftquery}"></xp:dominoView>
</xp:this.data>
<xp:viewColumn columnName="$2" id="viewColumn1">
<xp:viewColumnHeader value="$2" id="viewColumnHeader1"></xp:viewColumnHeader>
</xp:viewColumn>
<xp:viewColumn columnName="Tournament" id="viewColumn2">
<xp:viewColumnHeader value="Name" id="viewColumnHeader2"></xp:viewColumnHeader>
</xp:viewColumn>
</xp:viewPanel>
</xp:view>
Don't forget to enable Full-Text search on your database!
The XPage can be opened from a browser using http;//yoursite/database.nsf/your-xpage.xsp
I have a combo box, a button and a view for search function. The view has two columns which are Category and Course. In the Course column, I set multi-value separator is "New Line", enable "Multiple values as separate entries" and both view column headers are sort column. Therefore, when use internet explorer to see the application, the view looks like this:
Category | Course
-------------------------------------------------------
Accounting | Advanced Accounting
Accounting | Introduction to Accounting
Accounting | Communication Skills
Accounting | Writing Skills
Engineering | Advanced Engineering
Engineering | Introduction to Engineering
Engineering | Communication Skills
Engineering | Writing Skills
Information Technology | Advanced Information Technology
Information Technology | Introduction to Information Technology
Information Technology | Communication Skills
Information Technology | Writing Skills
(Update)
Thank you stwissel's answer, I remove the button, so there is a combo box and a view that is categorised. Although I do not find "LimitToCategory" in the view properties(grateful if someone let me know where to find it), I get the value from the combo box and put it in "Filter by category name", also the combo box has onchange event and partial update the view.
I run the program, when I choose a category, the view can display relevant values related to the category. Imagine the view show the result like the following:
Category | Course
-------------------------------------------------------
Information Technology | Advanced Information Technology
Introduction to Information Technology
Communication Skills
Writing Skills
However how to display course individually? What can I do to make the course should show individual row? (please see the sample below)
Category | Course
----------------------------------------------------------
Information Technology | Advanced Information Technology
----------------------------------------------------------
Information Technology | Introduction to Information Technology
----------------------------------------------------------
Information Technology | Communication Skills
----------------------------------------------------------
Information Technology | Writing Skills
----------------------------------------------------------
I add another customerConverter from this post xpages view panel column multivalue separator but the result still the same.
Category | Course
----------------------------------------------------------
Information Technology | Advanced Information Technology
----------------------------------------------------------
Information Technology | Introduction to Information Technology
----------------------------------------------------------
Information Technology | Communication Skills
----------------------------------------------------------
Information Technology | Writing Skills
----------------------------------------------------------
I attach the full code for your review please.
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" dojoTheme="true">
<xp:this.resources>
<xp:dojoModule name="dijit.form.ComboBox"></xp:dojoModule>
</xp:this.resources>
<xp:comboBox id="comboBox2" dojoType="dijit.form.ComboBox"
style="width:400.0px" value="#{sessionScope.category}">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:
var SetFirstValueBlank = #Text("");
return SetFirstValueBlank;
}]]></xp:this.value>
</xp:selectItems>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:#Unique(#DbColumn(#DbName(), "CategoryListView", 1));}]]></xp:this.value>
</xp:selectItems>
<xp:eventHandler event="onchange" submit="true"
refreshMode="partial" refreshId="viewPanel5">
</xp:eventHandler>
</xp:comboBox>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:viewPanel rows="30" id="viewPanel5">
<xp:this.facets>
<xp:pager partialRefresh="true" layout="Previous Group Next"
xp:key="headerPager" id="pager5">
</xp:pager>
</xp:this.facets>
<xp:this.data>
<xp:dominoView var="view2"
viewName="CategoryCourseView2">
<xp:this.categoryFilter><![CDATA[#{javascript:getComponent("comboBox2").getValue();}]]></xp:this.categoryFilter>
</xp:dominoView>
</xp:this.data>
<xp:viewColumn columnName="Category" id="viewColumn9"
rendered="false">
<xp:this.converter>
<xp:customConverter
getAsObject="#{javascript:return value;}">
<xp:this.getAsString>
<![CDATA[#{javascript:return #Implode(value, "<br />")}]]>
</xp:this.getAsString>
</xp:customConverter>
</xp:this.converter>
<xp:viewColumnHeader value="Category"
id="viewColumnHeader9">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:viewColumn id="viewColumn11" columnName="$10"
contentType="HTML">
<xp:this.facets>
<xp:viewColumnHeader xp:key="header"
id="viewColumnHeader11" value="Category">
</xp:viewColumnHeader>
</xp:this.facets>
</xp:viewColumn>
<xp:viewColumn columnName="CourseName" id="viewColumn10"
contentType="HTML">
<xp:this.converter>
<xp:customConverter
getAsObject="#{javascript:return value;}">
<xp:this.getAsString>
<![CDATA[#{javascript:return #Implode(value, "<br />")}]]>
</xp:this.getAsString>
</xp:customConverter>
</xp:this.converter>
<xp:viewColumnHeader value="Course"
id="viewColumnHeader10">
</xp:viewColumnHeader>
</xp:viewColumn>
</xp:viewPanel>
</xp:view>
Grateful for your advice please. Thank you.
When selecting a value from a drop down you are actually perform a filter rather than a search. In XPages you would categorise the view and compute the value of LimitToCategory to be the drop down value - you can directly point to the value in that property.
You wouldn't even need the button. For some design inspiration see this article
Hope that helps
The ViewPanel is a very limited component, aimed at giving a basic view control on the page. If you want a more sophisticated or flexible layout like this, the best approach is to use a repeat control.
The kind of functionality you're likely to be trying to force the View Panel to give you what you want is much more complex than building the layout with a repeat control (which can also take a dominoView as a datasource).
I'm pretty sure this isn't possible but I'm going to ask anyway.
I am building a system which handles patient records. A new user needs to be able to search for a patient and once found request access to their files from the Admin.
How do I show a list of all documents even if the user has no access to them? They only appear in the view once they've been added to the Readers field, which defeats the purpose of the search.
My plan is to create 2 documents - the original patient document and a stripped-down document containing name, address used only for searching
Is there a better way of doing this, or is the 2 document approach the way to go?
Use sessionAsSigner to get database object on rights of database signer and run search on it. This will give You collection of documents that can be visualized similarly to view with use of data table.
Example (for moderate views works great - for bigger ones probably some optymalization would be necessary):
<xp:panel id="viewPanel" styleClass="usersPanel">
<xp:this.dataContexts>
<xp:dataContext var="usersList">
<xp:this.value><![CDATA[#{javascript:
var uview = sessionAsSigner.getCurrentDatabase().getView("someView");
uview.FTSearch("Some query");
return uview.getAllEntries();
}]]></xp:this.value>
</xp:dataContext>
</xp:this.dataContexts>
<xp:pager partialRefresh="true" layout="Previous Group Next"
xp:key="headerPager" id="pager2" for="usersList">
</xp:pager>
<xp:dataTable id="usersList" rows="30"
var="entry" value="#{usersList}">
<xp:column id="column1">
<xp:this.facets>
<xp:span xp:key="header"
styleClass="frameworkViewColumnHeader">
Użytkownik
</xp:span>
</xp:this.facets>
<xp:text escape="true" id="computedField1"
value="#{javascript:entry.getColumnValues().get(0)}">
</xp:text>
</xp:column>
<xp:column id="column2">
<xp:this.facets>
<xp:span xp:key="header"
styleClass="frameworkViewColumnHeader">
Instytucja
</xp:span>
</xp:this.facets>
<xp:text escape="true" id="computedField2"
value="#{javascript:entry.getColumnValues().get(1)}">
</xp:text>
</xp:column>
</xp:dataTable>
</xp:panel>
I'm using the Extension Library and XPages to build a web based workflow application. One feature is to prompt a dialog and select the next approver before submitting it forward.
For new documents, the dialog appears, and it also appears when in read mode. It never opens for a saved document. I need it to work in SSJS, though the dialog does open in CSJS. Here is some of the code:
xpMain.xsp contains two custom controls: ccButtons and ccWFloDialogs.
ccButtons "Submit" button:
getComponent('dlgNextOwner').show();
ccWFloDialogs "dlgNextOwner" dialog:
<xe:dialog id="dlgNextOwner" title="Select Supervisor">
<xe:formTable id="ftDlgNextOwner" formTitle="Select Supervisor"
formDescription="You may select a different supervisor."
disableErrorSummary="true">
<xp:this.facets>
<xe:formRow id="formRow1" xp:key="footer" for="txtWFloNextOwner"
labelWidth="125px">
<xp:inputText id="txtWFloNextOwner" style="width:200px"
value="#{viewScope.nextOwner}">
</xp:inputText>
<xe:namePicker id="npNextOwner" dialogTitle="Select Supervisor"
for="txtWFloNextOwner">
<xe:this.dataProvider>
<xe:dominoNABNamePicker addressBookSel="all-public"></xe:dominoNABNamePicker>
</xe:this.dataProvider>
</xe:namePicker>
</xe:formRow>
</xp:this.facets>
</xe:formTable>
</xe:dialog>
In CSJS, I can use the following code and it successfully opens the dialog:
XSP.openDialog("#{id:dlgNextOwner}");
I'm also using Mark Hughes' picklist from the extension library, and if I remove the panel which contains the control and data source, the dialog shows up in SSJS! The code is in a custom control, although, if it's directly in the XPage, the problem is the same. Here is the code for the panel:
<xp:panel
id="vendorDiv">
<xp:this.data>
<xp:dominoView
var="nvVend"
viewName="V_Vend"
ignoreRequestParams="true"
databaseName="other/lookupdb.nsf"
startKeys="#{javascript:viewScope.srchVend}">
</xp:dominoView>
</xp:this.data>
<xe:formTable
id="ftGetVendor"
disableErrorSummary="true"
labelPosition="above">
<xe:formRow
id="frVendor"
for="cfVendorName"
label="Name of the Vendor:">
<xp:text
escape="true"
id="cfVendorName"
value="#{currentDocument.VendorName}"
style="width:200px">
</xp:text>
<xc:viewpicklist
rowsPerPage="15"
buttonImage="./add.png"
tableClass="tablecellgreen"
headerClass="headerclass"
rowClass="odd, even"
searchBar="false"
searchButtonText="Search"
searchButtonClass="button2"
searchBarClass="headerclass"
pagerStyleFirst="navbutton1"
pagerStylePrevious="navbutton2"
pagerStyleCurrent="navbutton4"
pagerStyleNext="navbutton2"
pagerStyleLast="navbutton3"
typeAheadBar="true"
select="Column"
onReturn="Set Scope Value"
bottomBarClass="bottomround headerclass"
cancelButtonText="Cancel"
cancelButtonClass="button2 floatthisright"
type="Single Value"
finishButtonText="Finish"
finishButtonClass="button2 floatthisright"
multiSelectButtonAddImg="./add.png"
multiSelectButtonRemoveImg="./delete.png"
picklistButtonClass="button"
openDialogWith="Link"
picklistLinkImg="./add.png"
multiSelectLinkAddImg="./add.png"
multiSelectLinkRemoveImg="./delete.png"
selectWith="Link"
clearSearchImg="./cross.png"
SelectCellWidth="30px"
dialogID="dlgVend"
dialogTitle="Select a Vendor"
dialogWidth="80%"
refreshID="vendorDiv"
ssjsSelectFunction="getVendorInfo"
varName="viewScope.vendorInfo"
datasrc="nvVend"
selectColumn="4"
linkImg="./add.png"
typeAheadVar="viewScope.srchVend">
<xc:this.viewColumn>
<xp:value>0</xp:value>
<xp:value>1</xp:value>
<xp:value>2</xp:value>
<xp:value>3</xp:value>
</xc:this.viewColumn>
</xc:viewpicklist>
</xe:formRow>
<xe:formRow
id="frVendorStatus"
for="cfVendorStatus"
label="Vendor Registration Status:">
<xp:text
escape="true"
id="cfVendorStatus"
value="#{currentDocument.VendorStatus}">
</xp:text>
</xe:formRow>
<xe:formRow
id="frVendorCountry"
for="cfVendorCountry"
label="Country Name:">
<xp:text
escape="true"
id="cfVendorCountry"
value="#{currentDocument.VendorCountry}">
</xp:text>
</xe:formRow>
</xe:formTable>
</xp:panel>
The requested vendor information populates the fields, without any problem or errors. However, something here seems to prevent dialogs from opening up using SSJS.
Can anyone see anything obvious I'm missing? The data source is in the panel, ignoreRequestParams is true (otherwise it doesn't work).
The main data source is in the entire XPage context. I tried to add the ccWFloDialog custom control outside the main panel, and change the data source to the panel, but that didn't work.
Any ideas?
Forget the dialog for now. This is probably data source related. Suggest you get it working just on the xpage first. With visible fields. then maybe use the rendered property to get it working on the xpage similar to how the dialog would appear. Once you have that working then you should be good to apply to dialog. This idea is to just take the dialog out of the equation first to make sure it works normally.
Instead, I decided to open the dialogs using CSJS, instead of SSJS. I've changed some of logic, and will have a bit more to do to finish this part of the project. Thanks to all!
I have created a Dynamic View Panel custom control and want to add a pager to it. When I drop a pager into the designated editable area, I get Pager is not associated with any data control. I am computing the datasource using a sessionScope variable.
I've gone into All Properties and added the following code in the For property:
if(sessionScope.clickedView == null){
return "All Active/All By Acronym";
}else{
return sessionScope.clickedView;
}
What am I doing wrong?
MJ
The value of the for attribute should match the id attribute of the view panel.
Just incase you were curious wht it would look like, I had one up so here is an example.
<xe:dynamicViewPanel rows="30" id="dynamicViewPanel1">
<xe:this.data>
<xp:dominoView var="view1" viewName="alldocs"></xp:dominoView>
</xe:this.data>
<xp:this.facets>
<xp:pager layout="Previous Group Next" partialRefresh="true"
id="pager1" xp:key="viewTitle" for="dynamicViewPanel1">
</xp:pager>
</xp:this.facets>
</xe:dynamicViewPanel>