If you can't read please download the document
Upload
michael-mcgarel
View
4.542
Download
2
Embed Size (px)
Citation preview
GEEK101 How To Build a
Multi-Field Search Page For Your IBM Domino XPages Application
Mike McGarel|Collaborative Solutions Developer
Czarnowski Display Services Inc
Mike McGarel
Working with web technologies for over 13 years
Working with Notes/Domino since version 4.6
Corporate developer
Site developer for MWLUG and SkiLUG
Searching Can Be Time-Consuming
Multi-Field Searching
Also known as faceted searching
Allows user to easily narrow results
Commonly used on shopping sites
Many ways to do this with XPages
Example project on OpenNTF
Faceted Search with Standby Project on OpenNTF
On OpenNTF:
http://www.openntf.org/internal/home.nsf/project.xsp?action=openDocument&name=Faceted%20Search%20with%20Standby
Components on the XPage view panel for search results
Dojo module for standby image
search fields and button to trigger the process
Server-side JavaScript function(s)
Client-side JavaScript script(s)
Database is variation of David Leedy's FakeNames.nsf on
XPagesCheatSheet.com
Server-side JavaScript (SSJS)
function buildPeopleQuery() { var sFirst = sessionScope.get("firstValue"); var sLast = sessionScope.get("lastValue"); var sState = sessionScope.get("stateValue"); var sOccupation = sessionScope.get("occupationValue"); var fieldArray = []; if (sFirst != "") { addToQuery(sFirst,"AND",fieldArray,"firstname"); } if (sLast != "") { addToQuery(sLast,"AND",fieldArray,"lastname"); } if (sState != "") { addToQuery(sState,"AND",fieldArray,"state"); } if (sOccupation != "") { addToQuery(sOccupation,"AND",fieldArray,"occupation"); } var fieldQuery = ""; if (fieldArray.length > 0) {if (fieldArray.length == 1) {fieldQuery += fieldArray[0]; } else {fieldQuery += "(" + fieldArray.join(" AND ") + ")"; } } return fieldQuery;}
function addToQuery(str,connector,targetArray,fieldName) { var ret = ""; if ((fieldName != null) && (fieldName != "")) { ret = "[" + fieldName + "]="; } if (@Contains(str, " ")) {var arr = str.split(" ");targetArray.push(ret + "(" + arr.join(" " + connector + " ") + ")"); } else {targetArray.push("(" + ret + str + ")");}}
Client-side JavaScript for Firefox, Chrome, and Safari
var standby;function addStandby() {standby = new dojox.widget.Standby({target:'#{id:namesPanel}'});document.body.appendChild(standby.domNode);standby.startup();standby.show();}function removeStandby() {standby.hide();dojo.destroy(standby.domNode);}]]>
Client-side JavaScript for Internet Explorer
var standby;function addStandby() {dojo.addClass(dojo.byId('#{id:namesPanel}'),'displayNone');dojo.removeClass(dojo.byId('#{id:divProcessing}'),'displayNone');}function removeStandby() {dojo.addClass(dojo.byId('#{id:divProcessing}'),'displayNone');dojo.removeClass(dojo.byId('#{id:namesPanel}'),'displayNone');}]]>
Button Code
View Panel Setup
Set search property to function, e.g., return buildPeopleQuery()
Set searchExactMatch property to false
Process Flow
User enters values in field(s)
User clicks button to search
Button triggers AJAX refresh on view panel
View panel displays search results based on SSJS function
(if needed, displays standby image while processing)
Because search values are kept in sessionScope variables, the same results are displayed if user leaves then returns to the page
XPages Resources
XPages.Info (http://xpages.info)
XPages Forum (http://www-10.lotus.com/ldd/xpagesforum.nsf)
Notes/Domino Application Development Wiki
(http://www-10.lotus.com/ldd/ddwiki.nsf)
YouAtNotes XPages wiki (http://www.xpageswiki.com)
Notes in 9 (http://www.notesin9.com)
Stack Overflow (http://stackoverflow.com/questions/tagged/xpages)
Mastering XPages (IBM Press)
XPages Extension Library (IBM Press)
XPages Portable Command Guide (IBM Press)
Questions and Evaluations
Mike McGarelCollaborative Solutions DeveloperCzarnowski Display Services [email protected]/mmcgarelwww.bleedyellow.com/blogs/McGarelGramming
THANK YOU!
Legal disclaimer
IBM Corporation 2013. All Rights Reserved.The information contained in this publication is provided for informational purposes only. While efforts were made to verify the completeness and accuracy of the information contained in this publication, it is provided AS IS without warranty of any kind, express or implied. In addition, this information is based on IBMs current product plans and strategy, which are subject to change by IBM without notice. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, this publication or any other materials. Nothing contained in this publication is intended to, nor shall have the effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms and conditions of the applicable license agreement governing the use of IBM software.References in this presentation to IBM products, programs, or services do not imply that they will be available in all countries in which IBM operates. Product release dates and/or capabilities referenced in this presentation may change at any time at IBMs sole discretion based on market opportunities or other factors, and are not intended to be a commitment to future product or feature availability in any way. Nothing contained in these materials is intended to, nor shall have the effect of, stating or implying that any activities undertaken by you will result in any specific sales, revenue growth or other results.Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.All references refer to fictitious companies and persons and are used for illustration purposes only.
Click to edit the outline text format
2013 IBM Corporation
Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline Level
2013 IBM Corporation