Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to defer opening of a view in an Xpage

Tags:

xpages

In my Xpage I have search criteria at the top of the page and a view at the bottom. The user will select some search criteria and then click search and I do a FT search on the view.

I want to avoid loading the view when first opening the xpage as that takes a lot of time. How can I do this?

like image 849
Bryan Schmiedeler Avatar asked Mar 20 '23 06:03

Bryan Schmiedeler


1 Answers

Use the rendered property of your view control. Return false for rendered property if search field is empty and return true if it's filled.

Example:

<xp:inputText
    id="inputText1"
    value="#{viewScope.search}">
</xp:inputText>
<xp:button
    value="Search"
    id="button1">
    <xp:eventHandler
        event="onclick"
        submit="true"
        refreshMode="partial"
        refreshId="viewForSearch">
    </xp:eventHandler>
</xp:button>
<xp:panel
    id="viewForSearch">
    <xp:viewPanel
        rows="30"
        id="viewPanel1"
        rendered="#{javascript:viewScope.search}">
        ... pager ... view ... columns ...
    </xp:viewPanel>
</xp:panel>

The search field is stored in a view scope variable "search". If it's empty then rendered="#{javascript:viewScope.search}" returns false and view doesn't get rendered. As soon as user enters a search string and clicks search button #{javascript:viewScope.search} returns true and view gets visible.

Partial refresh the view control panel clicking on search button.

like image 95
Knut Herrmann Avatar answered May 11 '23 16:05

Knut Herrmann