SlideShare a Scribd company logo
GEEK101 How To Build a
                         Multi-Field Search Page For Your
                         IBM Domino XPages Application
                         Mike McGarel | Collaborative Solutions Developer
                                        Czarnowski Display Services Inc




© 2013 IBM Corporation
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




2   © 2013 IBM Corporation
Searching Can Be Time-Consuming




3   © 2013 IBM Corporation
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




4   © 2013 IBM Corporation
5   © 2013 IBM Corporation
“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


6   © 2013 IBM Corporation
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 + ")");
      }
}

7     © 2013 IBM Corporation
Client-side JavaScript for Firefox, Chrome, and Safari

<xp:scriptBlock rendered="#{javascript:!context.getUserAgent().isIE();}">
    <xp:this.value><![CDATA[
         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);
    }]]></xp:this.value>
</xp:scriptBlock>
8   © 2013 IBM Corporation
Client-side JavaScript for Internet Explorer

<xp:scriptBlock rendered="#{javascript:context.getUserAgent().isIE();}">
    <xp:this.value><![CDATA[
         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');
    }]]></xp:this.value>
</xp:scriptBlock>



9   © 2013 IBM Corporation
Button Code

<xp:link escape="true" text="Update People List" id="linkPeopleList"
    outerStyleClass="lotusBtn" title="Update people list" style="width:80%;">
        <xp:eventHandler event="onclick" submit="true"
            refreshMode="partial" refreshId="namesPanel">
                <xp:this.onStart>
                   <![CDATA[addStandby();]]></xp:this.onStart>
                <xp:this.onComplete>
                   <![CDATA[removeStandby();]]></xp:this.onComplete>
        </xp:eventHandler>
</xp:link>

 




10   © 2013 IBM Corporation
View Panel Setup

    Set search property to function, e.g., “return buildPeopleQuery()”
 

    Set searchExactMatch property to false




11   © 2013 IBM Corporation
Process Flow

 (1)     User enters values in field(s)
 (2)
 (3)     User clicks button to search
 (4)
 (5)     Button triggers AJAX refresh on view panel
 (6)
 (7)     View panel displays search results based on SSJS function
         (if needed, displays “standby” image while processing)
 (8)
 (9) Because search values are kept in sessionScope variables, the same
     results are displayed if user leaves then returns to the page
 

 



12     © 2013 IBM Corporation
13   © 2013 IBM Corporation
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)




14   © 2013 IBM Corporation
Questions and Evaluations

 Mike McGarel
 Collaborative Solutions Developer
 Czarnowski Display Services Inc
 mcgarelgramming@gmail.com
 www.twitter.com/mmcgarel
 www.bleedyellow.com/blogs/McGarelGramming




                              THANK YOU!


15   © 2013 IBM Corporation
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 IBM’s 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 IBM’s 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.




16      © 2013 IBM Corporation

More Related Content

PDF
BP204 It's Not Infernal: Dante's Nine Circles of XPages Heaven
PDF
JMP401: Masterclass: XPages Scalability
PDF
High Performance JavaScript - jQuery Conference SF Bay Area 2010
PDF
High Performance JavaScript - WebDirections USA 2010
PPTX
Enough with the JavaScript already!
PDF
How to Build Real-time Chat App with Express, ReactJS, and Socket.IO?
PPTX
XPages and Java (DanNotes 50th conference, November 2013)
PPT
Responsive interfaces
BP204 It's Not Infernal: Dante's Nine Circles of XPages Heaven
JMP401: Masterclass: XPages Scalability
High Performance JavaScript - jQuery Conference SF Bay Area 2010
High Performance JavaScript - WebDirections USA 2010
Enough with the JavaScript already!
How to Build Real-time Chat App with Express, ReactJS, and Socket.IO?
XPages and Java (DanNotes 50th conference, November 2013)
Responsive interfaces

What's hot (20)

PDF
High Performance JavaScript - Fronteers 2010
KEY
HTML5 vs Silverlight
PDF
YUI Test The Next Generation (YUIConf 2010)
PDF
Nicholas' Performance Talk at Google
PDF
JMP402 Master Class: Managed beans and XPages: Your Time Is Now
PPTX
Responsive Layout Frameworks for XPages Application UI
PPTX
Bootstrap4XPages webinar
PDF
Max Voloshin - "Organization of frontend development for products with micros...
PDF
Turducken - Divide and Conquer large GWT apps with multiple teams
PPTX
JavaScript Timers, Power Consumption, and Performance
PPTX
MWLUG 2015 - AD114 Take Your XPages Development to the Next Level
PDF
Front-end optimisation & jQuery Internals
PPTX
HoloLens Unity Build Pipelines on Azure DevOps
PPTX
7 tips for javascript rich ajax websites
PDF
Week 05 Web, App and Javascript_Brandon, S.H. Wu
PDF
Tips for Building your First XPages Java Application
PDF
Bootstrap4XPages
KEY
MozTW Jetpack Workshop: Taipei
PDF
Jetpack SDK: The new possibility of the extensions on browser
PDF
MozTW Jetpack Workshop: Taichung
High Performance JavaScript - Fronteers 2010
HTML5 vs Silverlight
YUI Test The Next Generation (YUIConf 2010)
Nicholas' Performance Talk at Google
JMP402 Master Class: Managed beans and XPages: Your Time Is Now
Responsive Layout Frameworks for XPages Application UI
Bootstrap4XPages webinar
Max Voloshin - "Organization of frontend development for products with micros...
Turducken - Divide and Conquer large GWT apps with multiple teams
JavaScript Timers, Power Consumption, and Performance
MWLUG 2015 - AD114 Take Your XPages Development to the Next Level
Front-end optimisation & jQuery Internals
HoloLens Unity Build Pipelines on Azure DevOps
7 tips for javascript rich ajax websites
Week 05 Web, App and Javascript_Brandon, S.H. Wu
Tips for Building your First XPages Java Application
Bootstrap4XPages
MozTW Jetpack Workshop: Taipei
Jetpack SDK: The new possibility of the extensions on browser
MozTW Jetpack Workshop: Taichung
Ad

Similar to How To Build a Multi-Field Search Page For Your XPages Application (20)

PDF
XPages Blast - Lotusphere 2012
PDF
AD106 - IBM Lotus Domino XPages anywhere - Write them once, See them Everywhere
PDF
Developing XPages Applications
ODP
Intro to XPages for Administrators (DanNotes, November 28, 2012)
PDF
BP206 It's Not Herculean: 12 Tasks Made Easier with IBM Domino XPages
PDF
XPages Blast - Lotusphere 2011
PDF
X pages jumpstart jmp101
PDF
XPages Performance Master Class - Survive in the fast lane on the Autobahn (E...
PPTX
Connect 2014 - EXTJS in XPages: Modernizing IBM Notes Views Without Sacrifici...
PPTX
User Interface Patterns and Nuxeo
PPTX
Take Your XPages Development to the Next Level
PDF
What’s new for Developers in IBM Domino & Domino Designer 9.0.1
PDF
Ad107 - Enhance Your Existing Applications with XPages
PDF
AD1279 "Marty, You're Not Thinking Fourth Dimensionally" - Troubleshooting XP...
PDF
Twelve Tasks Made Easier with IBM Domino XPages
PDF
Connect ed2014 ad501_ibm worklight for ibm domino developers
ODP
IBM ConnectED 2015 - AD302 - Responsive Application Development for XPages
PDF
XPages101 - Building an XPages app - Lotusphere 2011
PDF
We4IT lcty 2013 - infra-man - whats new in ibm domino application development
PDF
XPages Blast - Lotusphere 2013
XPages Blast - Lotusphere 2012
AD106 - IBM Lotus Domino XPages anywhere - Write them once, See them Everywhere
Developing XPages Applications
Intro to XPages for Administrators (DanNotes, November 28, 2012)
BP206 It's Not Herculean: 12 Tasks Made Easier with IBM Domino XPages
XPages Blast - Lotusphere 2011
X pages jumpstart jmp101
XPages Performance Master Class - Survive in the fast lane on the Autobahn (E...
Connect 2014 - EXTJS in XPages: Modernizing IBM Notes Views Without Sacrifici...
User Interface Patterns and Nuxeo
Take Your XPages Development to the Next Level
What’s new for Developers in IBM Domino & Domino Designer 9.0.1
Ad107 - Enhance Your Existing Applications with XPages
AD1279 "Marty, You're Not Thinking Fourth Dimensionally" - Troubleshooting XP...
Twelve Tasks Made Easier with IBM Domino XPages
Connect ed2014 ad501_ibm worklight for ibm domino developers
IBM ConnectED 2015 - AD302 - Responsive Application Development for XPages
XPages101 - Building an XPages app - Lotusphere 2011
We4IT lcty 2013 - infra-man - whats new in ibm domino application development
XPages Blast - Lotusphere 2013
Ad

More from Michael McGarel (8)

PPTX
Next Level Coding
PPTX
Object(ive) Thinking
PDF
Extreme Development: Pair Programming
PPTX
MWLUG2014 AD107 First Java App Tips
PPTX
XPages Workshop: Customizing OneUI
ODP
Two CCs of Layout -- Stat
ODP
XPages - The Ties That Bind
ODP
Approaches to Enhancing the User Experience
Next Level Coding
Object(ive) Thinking
Extreme Development: Pair Programming
MWLUG2014 AD107 First Java App Tips
XPages Workshop: Customizing OneUI
Two CCs of Layout -- Stat
XPages - The Ties That Bind
Approaches to Enhancing the User Experience

Recently uploaded (20)

PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Web App vs Mobile App What Should You Build First.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PPTX
A Presentation on Touch Screen Technology
PDF
Hybrid model detection and classification of lung cancer
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf
1 - Historical Antecedents, Social Consideration.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Unlocking AI with Model Context Protocol (MCP)
Web App vs Mobile App What Should You Build First.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Encapsulation_ Review paper, used for researhc scholars
Programs and apps: productivity, graphics, security and other tools
cloud_computing_Infrastucture_as_cloud_p
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
A Presentation on Touch Screen Technology
Hybrid model detection and classification of lung cancer
Heart disease approach using modified random forest and particle swarm optimi...
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
A comparative analysis of optical character recognition models for extracting...
Assigned Numbers - 2025 - Bluetooth® Document
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf

How To Build a Multi-Field Search Page For Your XPages Application

  • 1. GEEK101 How To Build a Multi-Field Search Page For Your IBM Domino XPages Application Mike McGarel | Collaborative Solutions Developer Czarnowski Display Services Inc © 2013 IBM Corporation
  • 2. 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 2 © 2013 IBM Corporation
  • 3. Searching Can Be Time-Consuming 3 © 2013 IBM Corporation
  • 4. 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 4 © 2013 IBM Corporation
  • 5. 5 © 2013 IBM Corporation
  • 6. “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 6 © 2013 IBM Corporation
  • 7. 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 + ")"); } } 7 © 2013 IBM Corporation
  • 8. Client-side JavaScript for Firefox, Chrome, and Safari <xp:scriptBlock rendered="#{javascript:!context.getUserAgent().isIE();}"> <xp:this.value><![CDATA[ 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); }]]></xp:this.value> </xp:scriptBlock> 8 © 2013 IBM Corporation
  • 9. Client-side JavaScript for Internet Explorer <xp:scriptBlock rendered="#{javascript:context.getUserAgent().isIE();}"> <xp:this.value><![CDATA[ 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'); }]]></xp:this.value> </xp:scriptBlock> 9 © 2013 IBM Corporation
  • 10. Button Code <xp:link escape="true" text="Update People List" id="linkPeopleList" outerStyleClass="lotusBtn" title="Update people list" style="width:80%;"> <xp:eventHandler event="onclick" submit="true" refreshMode="partial" refreshId="namesPanel"> <xp:this.onStart> <![CDATA[addStandby();]]></xp:this.onStart> <xp:this.onComplete> <![CDATA[removeStandby();]]></xp:this.onComplete> </xp:eventHandler> </xp:link>  10 © 2013 IBM Corporation
  • 11. View Panel Setup  Set search property to function, e.g., “return buildPeopleQuery()”   Set searchExactMatch property to false 11 © 2013 IBM Corporation
  • 12. Process Flow (1) User enters values in field(s) (2) (3) User clicks button to search (4) (5) Button triggers AJAX refresh on view panel (6) (7) View panel displays search results based on SSJS function (if needed, displays “standby” image while processing) (8) (9) Because search values are kept in sessionScope variables, the same results are displayed if user leaves then returns to the page   12 © 2013 IBM Corporation
  • 13. 13 © 2013 IBM Corporation
  • 14. 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) 14 © 2013 IBM Corporation
  • 15. Questions and Evaluations Mike McGarel Collaborative Solutions Developer Czarnowski Display Services Inc [email protected] www.twitter.com/mmcgarel www.bleedyellow.com/blogs/McGarelGramming THANK YOU! 15 © 2013 IBM Corporation
  • 16. 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 IBM’s 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 IBM’s 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. 16 © 2013 IBM Corporation