Xpages search between 2 dates

自古美人都是妖i 提交于 2019-11-27 08:33:51

问题


I have a view with some data, and a column with the creation date of each document. I want to make a search feature with 3 input fields: Name, StartDate, EndDate. The result of the search should be all the documents with the same name and within the 2 dates.

Can anyone help me?

Thanks


回答1:


Use the search property of DominoView data source. It does a full text search on all documents in view. Create a search string like

[Name]="Meier" AND [_creationDate]>=12-01-2013 AND [_creationDate]<=30-08-2014

Your data source code would look like this:

    <xp:this.data>
        <xp:dominoView
            var="view1"
            viewName="YourView">
            <xp:this.search><![CDATA[#{javascript:
            var search = "";
            var formatter = new java.text.SimpleDateFormat("dd-MM-yyyy");
            if (viewScope.Name) {
                search += ' AND [Name]="' + viewScope.Name + '*"';
            }
            if (viewScope.StartDate) {
                search += ' AND [_creationDate]>=' + formatter.format(viewScope.StartDate);
            }
            if (viewScope.EndDate) {
                search += ' AND [_creationDate]<=' + formatter.format(viewScope.EndDate);
            }
            return search.substring(5);}]]></xp:this.search>
        </xp:dominoView>
    </xp:this.data>

This code assumes that there are editable search fields which value is bound to viewScope.Name, viewScope.StartDate and viewScope.EndDate e.g.

<xp:inputText
    id="inputText1"
    value="#{viewScope.Name}">
</xp:inputText>

<xp:inputText
    id="inputText2"
    value="#{viewScope.StartDate}">
    <xp:this.converter>
        <xp:convertDateTime
            type="date"
            dateStyle="short">
        </xp:convertDateTime>
    </xp:this.converter>
    <xp:dateTimeHelper></xp:dateTimeHelper>
</xp:inputText>


来源:https://stackoverflow.com/questions/25424109/xpages-search-between-2-dates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!