XPages Advanced Search Options


  <xp:panel
    id="dbindexed"
    rendered="#{javascript:database.isFTIndexed()}">
    <xp:inputText
      id="inputTextSearchQuery"
      value="#{viewScope.fts1}"></xp:inputText>
    <xp:button
      value="Search"
      id="button1">
      <xp:eventHandler
        event="onclick"
        submit="true"
        refreshMode="complete">
      </xp:eventHandler>
    </xp:button>
    <xp:button
      id="button2"
      value="Clear Results">
      <xp:this.rendered><![CDATA[#{javascript:!viewScope.fts1 ==""}]]></xp:this.rendered>
      <xp:eventHandler
        event="onclick"
        submit="true"
        refreshMode="partial"
        refreshId="searchQueryView">
        <xp:this.action><![CDATA[#{javascript:viewScope.remove("fts1")}]]></xp:this.action>
      </xp:eventHandler>
    </xp:button>
    <xp:br></xp:br>
    <xp:checkBox
      id="checkBoxExactMatch"
      value="#{viewScope.em1}"
      text="Exact Match"
      rendered="false">
      <xp:eventHandler
        event="onchange"
        submit="true"
        refreshMode="partial"
        refreshId="searchQueryView">
      </xp:eventHandler>
    </xp:checkBox>
    <xp:br
      rendered="false"></xp:br>
    <xp:checkBox
      id="checkBoxFuzzySearch"
      value="#{viewScope.fuzzy1}"
      text="Fuzzy Search">
      <xp:eventHandler
        event="onchange"
        submit="true"
        refreshMode="partial"
        refreshId="searchQueryView">
      </xp:eventHandler>
    </xp:checkBox>
            
            <xp:br></xp:br>
    <xp:checkBox
      id="checkBoxWordVariants"
      value="#{viewScope.wv1}"
      text="Word Variants">
      <xp:eventHandler
        event="onchange"
        submit="true"
        refreshMode="partial"
        refreshId="searchQueryView">
      </xp:eventHandler>
    </xp:checkBox>
            
            <xp:br></xp:br>
    <xp:label
      value="Maximum results: "
      id="labelMaxResults"></xp:label>
    <xp:comboBox
      id="comboBox1"
      value="#{viewScope.md1}">

      <xp:selectItem
        itemLabel="No Maximum"></xp:selectItem>
      <xp:selectItem
        itemLabel="5"
        itemValue="5"></xp:selectItem>
      <xp:selectItem
        itemLabel="10"
        itemValue="10"></xp:selectItem>
      <xp:selectItem
        itemLabel="15"
        itemValue="15"></xp:selectItem>
      <xp:selectItem
        itemLabel="20"
        itemValue="20"></xp:selectItem>
      <xp:eventHandler
        event="onchange"
        submit="true"
        refreshMode="partial"
        refreshId="searchQueryView">
      </xp:eventHandler>
    </xp:comboBox>
  </xp:panel>


  <xp:panel
    id="searchQueryView">
    <xp:label
      value="Options: "
      id="labeloptions"
      style="font-weight:bold"></xp:label>
    <xp:label
      id="labelfuzzyoption"
      style="color:rgb(0,128,192)"
      value="Fuzzy search ">
      <xp:this.rendered><![CDATA[#{javascript:viewScope.fuzzy1 =="true"}]]></xp:this.rendered>
    </xp:label>
    &#160;
    <xp:label
      id="labelWordVariants"
      style="color:rgb(0,64,128)"
      value="Word variants ">
      <xp:this.rendered><![CDATA[#{javascript:viewScope.wv1 =="true"}]]></xp:this.rendered>
    </xp:label>
    &#160;
    <xp:label
      id="labelExactMatch"
      style="color:rgb(128,0,128)"
      value="Exact Match">
      <xp:this.rendered><![CDATA[#{javascript:viewScope.em1 =="true"}]]></xp:this.rendered>
    </xp:label>

    //This view panel will have to be redone for each use case.
    //The important part of this part of the snippet is how the view data
    //source is configured
    //Here the main property to set is 'search' - the value of this property
    //will be the search query of the view
    //Then the other proerties 'searchMaxDocs', 'searchExactMatch',
    //'searchFuzzy', and 'searchVariants' all modify the search query.
    
<xp:viewPanel
      rows="25"
      id="viewPanel1"
      indexVar="vi1">

      <xp:this.data>
        <xp:dominoView
          var="view1"
          viewName="myNotesViewDataSource"
          searchMaxDocs="#{javascript:viewScope.md1}">
          <xp:this.search><![CDATA[#{javascript:var f = database.isFTIndexed();
var vs = viewScope.fts1;
@If(f = false,"",vs)}]]></xp:this.search>
          <xp:this.searchExactMatch><![CDATA[#{javascript:@If(viewScope.em1=="true",true,false)}]]></xp:this.searchExactMatch>
          <xp:this.searchFuzzy><![CDATA[#{javascript:@If(viewScope.fuzzy1=="true",true,false)}]]></xp:this.searchFuzzy>
          <xp:this.searchVariants><![CDATA[#{javascript:@If(viewScope.wv1=="true",true,false)}]]></xp:this.searchVariants>
        </xp:dominoView>
      </xp:this.data>
      //columns deleted
      ...


    </xp:viewPanel>
  </xp:panel>
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
No comments yetLogin first to comment...