0
votes

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

1

1 Answers

0
votes

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