1

Hello Domino programmers!

I work an Xpages application and i ran into a following problem:

I have many Xpages view controls that are being filtered by username. Recently I had to add full search to existing views. Option "Search in view results" seems to override "Filter by column value" option, so I can clearly see other users documents.

I can think of adding an additional condition to query in order to filter search results, but is it the only way?

Any help will be appreciated.

The Raven
  • 527
  • 1
  • 6
  • 31

1 Answers1

1

OK, Here's how I approached this issue. I'm using the data view with just a plain old view data source.

I wanted a single search box, if you just type something in the field it uses the "startKeys" property to navigate to the proper entry. The search field has an onFocus event which sets a boolean value "viewMoveTo" to true. You can store this value in a bean or sessionScope or wherever, doesn't matter. There is another event onKeyUp which just does a partial refresh of the data view.

If you click the search button it would do a FT Search using the "search" property in the data view. In the onClick event of the search button I set the "viewMoveTo" value to false.

Here's my code for the field:

        <xp:inputText
            id="viewSearchField1"
            value="#{UserProfile.viewSearchStr}"
            styleClass="form-control rpdViewSearchField">
            <xp:this.attrs>
                <xp:attr name="placeHolder" value="Search"></xp:attr>
            </xp:this.attrs>
            <xp:eventHandler
                event="onfocus"
                submit="true"
                refreshMode="norefresh"
                            action="#{javascript:UserProfile.setViewMoveTo(true);}">
            </xp:eventHandler>
            <xp:eventHandler
                event="onkeyup"
                submit="true"
                refreshMode="partial" 
                refreshId="dataView1">
            </xp:eventHandler>
        </xp:inputText>

Here's the code for the search button:

<xp:link id="link2" title="Perform Search">
    <xp:eventHandler
        event="onclick"
        submit="true"
        refreshMode="partial"
        refreshId="dataView1"
        action="#{javascript:UserProfile.setViewMoveTo(false);}">
    </xp:eventHandler>
    <i class="fa fa-search" />
</xp:link>

And finally here's the data source code for the data view:

<xe:this.data>
    <xp:dominoView
        var="currentView"
        expandLevel="1"
        viewName="#{javascript:return PortalContext.getCollection() != null ? PortalContext.getCollection().getViewName() : null;}"
        databaseName="#{javascript:return DesktopContext.getCurrentContainer().getFilePath();}">
        <xp:this.startKeys><![CDATA[#{javascript:var returnVal = UserProfile.getViewSearchStr();
if (!UserProfile.getViewFTSearch()) {
    returnVal = null;
}
return returnVal;}]]></xp:this.startKeys>
        <xp:this.search><![CDATA[#{javascript:var returnVal = UserProfile.getViewSearchStr();
if (UserProfile.getViewFTSearch()) {
    returnVal = null;
}
return returnVal;}]]></xp:this.search>
    </xp:dominoView>
</xe:this.data>

So, going over this... a user puts their cursor in the search field and the "viewMoveTo" variable is set to true via the onFocus event. The "startKeys" property of the data source checks to see if "viewMoveTo" is false, if it's NOT then it returns the value of the search field as the key to move to. If the viewMoveTo values IS false, then it returns a null value. In the onKeyUp event, we partial refresh the data view.

The search button does just the opposite. It sets the value of "viewMoveTo" to false. The "search" property of the data source checks to see if "viewMoveTo" is true, if it's NOT then it returns the value of the search field as the value to search for. If the viewMoveTo value IS true, then it returns a null value. Finally the onclick event does a partial refresh of the data view.

keithstric
  • 1,053
  • 1
  • 11
  • 21