ASR
ASR

Reputation: 3549

How to customize search container emptyResultsMessage in lifray?

I want to display the message with a jsp page in search container emptyResultsMessage.

Presently my code is:

<liferay-ui:search-container delta="10" emptyResultsMessage="There are no results." iteratorURL="<%=iteratorURL %>" deltaConfigurable="true" var="searchContainer" >

Now when I want to display

There are no results.+ button.jsp

in emptyResultsMessage.

In button.jsp I have a button. It has to display when emptyResultsMessage is empty.

Can any one tell me how to display it?

<liferay-ui:search-container delta="10" emptyResultsMessage="there were no courses found please <jsp:include page='subscribeSearch.jsp' /> with us" iteratorURL="<%=iteratorURL %>" deltaConfigurable="true" var="searchContainer" >

Upvotes: 0

Views: 1257

Answers (1)

Olaf Kock
Olaf Kock

Reputation: 48067

<liferay-util:buffer .../> is your friend. You don't seem to care for internationalization, so the easy approach is this: Construct the message before, then just use it:

(untested pseudocode, don't expect it to work out of the box)

<liferay-util:buffer var="emptyMessage">
    there were no courses found please 
    <liferay-util:include
        page="subscribeSearch.jsp"
    />
    with us
</liferay-util:buffer>

<liferay-ui:search-container delta="10" 
     emptyResultsMessage="<%=emptyMessage%>" 
     iteratorURL="<%=iteratorURL %>" 
     deltaConfigurable="true" 
     var="searchContainer" 
>

....

IMHO I'd construct the whole message on that jsp page rather than just fragments. But I'd also use proper i18n, but you get the basic idea from this.

Also, check if you need to escape the string (e.g. use <%=HtmlUtil.escape(emptyMessage)%>). I'm not sure which order the processing is done out of the top of my head (can't test currently)

Upvotes: 1

Related Questions