Show values in each line when search - xpages

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).

Related

Notes/Domino : Submit button is not shown in the customized search form

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

xpages: refresh the view when different user login

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/

Filter in restorted DynamicViewPanel resets sort

I have dynamic view control that is used to display several views from a database. I allow users to filter this view using input that is bound to a viewscope variable that is used in keys attribute of Domino View.
It works just fine, but some views have sortable column that strangely. Problem is that when users resorts the view and then tries to filter, the sort order is lost.
I also tried call setKeys programmatically on datasource, but with same results. Also setting setResortOrder on the dataModel has no effect. Sort order seems to be lost when different key value is set.
To get correct result, users have to resort the view again after submitting the sort.
(on Domino 9.0.1 with v11 ExtLib)
update - code snippet for basic scenario
<xp:panel id="content">
<xp:inputText id="searchInput" value="#{viewScope.tmpSearchText}" />
<xp:button id="search">
Search
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="content">
<xp:this.action><![CDATA[#{javascript:viewScope.searchText=viewScope.tmpSearchText;}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xe:dynamicViewPanel id="viewPanel">
<xe:this.data>
<xp:dominoView var="view1" keys="#{viewScope.searchText}"
viewName="DleCislaW" >
</xp:dominoView>
</xe:this.data>
</xe:dynamicViewPanel>
</xp:panel>

Can I filter an Xpages search bar

I have been given an XPages project which I did not develop. The project has a OneUILayout that includes a Search Bar "facet". Is it possible to code a filter into the search bar facet so that retrieved records are omitted that have a field with a certain value. I have very little experience with XPages. The search results are output to a OneUI_searchpage.xsp where an edit box displays the search string then a dynamic View Panel shown the retrieved records. I have attached the source code for these two items below. Thank you
<xp:label value="Search String:" id="label1"></xp:label>
<xp:inputText id="inputText1" value="#{param.search}"></xp:inputText>
<xp:panel id="maincontentpanel">
<xe:dynamicViewPanel rows="30" id="dynamicViewPanel1"
width="100%">
<xe:this.data>
<xp:dominoView viewName="ContractsFlatByYear"
var="view">
<xp:this.search><![CDATA[#{javascript:return
param.search;}]]></xp:this.search>
</xp:dominoView>
</xe:this.data>
</xe:dynamicViewPanel>
After some consultation with stwissel below, I amended the application to have a check box on the search results xpage with it checked by default and created an additional view for the same output. One view to show cancelled contracts and one to omit cancelled contracts. The relevant Xpage section now looks like as follows;
<xp:checkBox text="Omit Cancelled Contracts"
id="OmitCancelled" defaultChecked="true" checkedValue="True"
uncheckedValue="False" style="padding-left:5.0em" value="#
{viewScope.viewSel}">
<xp:eventHandler event="onchange" submit="true" refreshMode="partial"
refreshId="dynamicViewPanel1"></xp:eventHandler>
</xp:checkBox>
<xp:panel id="maincontentpanel">
<xe:dynamicViewPanel rows="30" id="dynamicViewPanel1"
width="100%" partialRefresh="true">
<xe:this.data>
<xp:dominoView var="view">
<xp:this.viewName>
<![CDATA[#{javascript:var cancelledYesNo = viewScope.viewSel
= getComponent("OmitCancelled").getValue();
if(cancelledYesNo == "True"){
viewName = "ContractsFlatByYear"}
else {
viewName = "ContractsFlatByYearandCancelled"}}]]>
</xp:this.viewName>
<xp:this.search><![CDATA[#{javascript:return param.search;}]]
></xp:this.search>
</xp:dominoView>
</xe:this.data>
</xe:dynamicViewPanel>
This appears to work but I have the check box onChange event to apply a partial refresh on the dynamicviewpanel but only refreshes when I click on the dynamicviewpanel itself
The search bar facet only captures what you want to search and sends it to the specified XPages for processing.
You have 2 options:
Alter the facet to send the additional condition to the search page
Alter the search function in the search page (the one the query gets posted to) to filter that (if it is static).
Be aware: filtering in code is not a security feature (in case you were intending that). There's reader and author fields for that.
XPages in its core is JSF with some specialities around Domino. You might want to check out my article series on them.
Update
Based on the code snippet, your can get the desired result quite fast. Edit the view selection formula and add & conContractStatus <> "cancelled". You need to check first if that view is used elsewhere to show canceled contracts too. If that is the case, copy the view (eg add Active behind the name) and make the changes there.
Update 2
Your code doesn't return a value and you don't need to get to the component
<xp:this.viewName>
<![CDATA[#{javascript:return (viewScope.viewSel=="True") ? "ContractsFlatByYear" : "ContractsFlatByYearandCancelled";}]]>
</xp:this.viewName>
Let us know how it goes

Xpages: Searching for documents I have no access to

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>

Resources