Note that there are some explanatory texts on larger screens.

plurals
  1. POLiferay liferay-ui:search-toggle not showing (on search-form)
    primarykey
    data
    text
    <p>I'm trying to create a search form for my portlet. The portlet is an addressbook application, all dao and service build with service builder. I would like to give users a basic/advanced search form (like other on liferay, for example on "users and organizations" in control center.</p> <p>I've implemented all logic and pages looking at liferay source code (6.1 GA1), but the search form is NOT showing up in any way, i'll put the code here.</p> <p>in view.jsp:</p> <pre class="lang-jsp prettyprint-override"><code>&lt;% PortletURL portletURL = renderResponse.createRenderURL(); portletURL.setParameter("jspPage", "/html/addressbookportlet/view.jsp"); pageContext.setAttribute("portletURL", portletURL); String portletURLString = portletURL.toString(); %&gt; &lt;aui:form action="&lt;%= portletURLString %&gt;" method="get" name="fm"&gt; &lt;liferay-portlet:renderURLParams varImpl="portletURL" /&gt; &lt;aui:input name="isSearch" type="hidden" value="true" /&gt; &lt;aui:input name="redirect" type="hidden" value="&lt;%= portletURLString %&gt;" /&gt; &lt;liferay-ui:search-container searchContainer="&lt;%= new ABContactSearch(renderRequest, portletURL) %&gt;" &gt; &lt;% ABContactDisplayTerms displayTerms = (ABContactDisplayTerms)searchContainer.getDisplayTerms(); ABContactSearchTerms searchTerms = (ABContactSearchTerms)searchContainer.getSearchTerms(); Long societyId = GetterUtil.getLong(searchTerms.getSocietyId(),0); Long contactTypeId = GetterUtil.getLong(searchTerms.getContactTypeId(), 0); Long brandId = GetterUtil.getLong(searchTerms.getBrandId(),0); Long channelId = GetterUtil.getLong(searchTerms.getChannelId(),0); %&gt; &lt;liferay-ui:search-form searchContainer="&lt;%=searchContainer%&gt;" servletContext="&lt;%= this.getServletConfig().getServletContext() %&gt;" showAddButton="true" page='&lt;%= request.getContextPath() + "/html/addressbookportlet/contact_search_form.jsp" %&gt;' /&gt; &lt;liferay-ui:search-container-results&gt; &lt;% if (searchTerms.isAdvancedSearch()) { results = AddressbookSearchUtil.searchAdvanced(scopes, searchTerms, searchTerms.isAndOperator(), searchContainer.getStart(), searchContainer.getEnd()); //, searchContainer.getOrderByComparator()); total = AddressbookSearchUtil.countAdvanced(scopes, searchTerms, searchTerms.isAndOperator()); } else { results = AddressbookSearchUtil.searchFullText(scopes, searchTerms.getKeywords(), searchContainer.getStart(), searchContainer.getEnd()); //, searchContainer.getOrderByComparator()); total = AddressbookSearchUtil.countFullText(scopes, searchTerms.getKeywords()); } pageContext.setAttribute("results", results); pageContext.setAttribute("total", total); %&gt; &lt;/liferay-ui:search-container-results&gt; &lt;liferay-ui:search-container-row className="it.mir4unicomm.addressbook.model.ABContact" escapedModel="&lt;%= true %&gt;" keyProperty="contactId" modelVar="abcontact" &gt; &lt;liferay-ui:search-container-column-text title="Surname" property="surname" /&gt; &lt;liferay-ui:search-container-column-text title="Name" property="name" /&gt; &lt;liferay-ui:search-container-column-text title="Position" property="position" /&gt; &lt;/liferay-ui:search-container-row&gt; &lt;liferay-ui:search-iterator /&gt; &lt;/liferay-ui:search-container&gt; &lt;/aui:form&gt; </code></pre> <p>contact_search_form.jsp:</p> <pre class="lang-jsp prettyprint-override"><code>&lt;%@ include file="/html/addressbookportlet/init.jsp" %&gt; &lt;% the ABContactDisplayTerms displayTerms = (ABContactDisplayTerms)searchContainer.getDisplayTerms(); List&lt;ABSociety&gt; societyList = ABSocietyLocalServiceUtil.getABSocieties(0, Integer.MAX_VALUE); List&lt;ABBrand&gt; brandList = ABBrandLocalServiceUtil.getABBrands(0, Integer.MAX_VALUE); List&lt;ABContactType&gt; contactTypeList = ABContactTypeLocalServiceUtil.getABContactTypes(0, Integer.MAX_VALUE); List&lt;ABChannel&gt; channelList = ABChannelLocalServiceUtil.getABChannels(0, Integer.MAX_VALUE); %&gt; &lt;liferay-ui:search-toggle id="toggle_id_contact_search" displayTerms="&lt;%= displayTerms %&gt;" buttonLabel="search-contact" &gt; &lt;aui:fieldset&gt; &lt;aui:input name="&lt;%= ABContactDisplayTerms.SURNAME %&gt;" size="20" value="&lt;%= displayTerms.getSurname() %&gt;" /&gt; &lt;aui:input name="&lt;%= ABContactDisplayTerms.NAME %&gt;" size="20" value="&lt;%= displayTerms.getName() %&gt;" /&gt; &lt;aui:input name="&lt;%= ABContactDisplayTerms.POSITION %&gt;" size="20" value="&lt;%= displayTerms.getPosition() %&gt;" /&gt; &lt;aui:input name="&lt;%= ABContactDisplayTerms.DETAIL_VALUE %&gt;" size="20" value="&lt;%= displayTerms.getDetailValue() %&gt;" /&gt; &lt;/aui:fieldset&gt; &lt;/liferay-ui:search-toggle&gt; &lt;c:if test="&lt;%= windowState.equals(WindowState.MAXIMIZED) %&gt;"&gt; &lt;aui:script&gt; Liferay.Util.focusFormField(document.&lt;portlet:namespace /&gt;fm.&lt;portlet:namespace /&gt;&lt;%= ABContactDisplayTerms.SURNAME %&gt;); Liferay.Util.focusFormField(document.&lt;portlet:namespace /&gt;fm.&lt;portlet:namespace /&gt;&lt;%= ABContactDisplayTerms.KEYWORDS %&gt;); &lt;/aui:script&gt; &lt;/c:if&gt;meDisplay.setIncludeServiceJs(true); ABContactSearch searchContainer = (ABContactSearch)request.getAttribute("liferay-ui:search:searchContainer"); </code></pre> <p>ABContactDisplayTerm.java:</p> <pre class="lang-java prettyprint-override"><code>public class ABContactDisplayTerms extends DisplayTerms { public static final String NAME = "name"; public static final String SURNAME = "surname"; public static final String POSITION = "position"; public static final String SOCIETY_ID = "societyId"; public static final String CONTACT_TYPE_ID = "contactTypeId"; public static final String BRAND_ID = "brandId"; public static final String CHANNEL_ID = "channelId"; public static final String DETAIL_VALUE = "detailValue"; protected String name; protected String surname; protected String position; protected Long societyId; protected Long contactTypeId; protected Long brandId; protected Long channelId; protected String detailValue; public ABContactDisplayTerms(PortletRequest portletRequest) { super(portletRequest); name = ParamUtil.getString(portletRequest, NAME); surname = ParamUtil.getString(portletRequest, SURNAME); position = ParamUtil.getString(portletRequest, POSITION); societyId = ParamUtil.getLong(portletRequest, SOCIETY_ID); contactTypeId = ParamUtil.getLong(portletRequest, CONTACT_TYPE_ID); brandId = ParamUtil.getLong(portletRequest, BRAND_ID); channelId = ParamUtil.getLong(portletRequest, CHANNEL_ID); detailValue = ParamUtil.getString(portletRequest, DETAIL_VALUE); } public String getName() { return name; } public String getSurname() { return surname; } public String getPosition() { return position; } public Long getSocietyId() { return societyId; } public Long getContactTypeId() { return contactTypeId; } public Long getBrandId() { return brandId; } public Long getChannelId() { return channelId; } public String getDetailValue() { return detailValue; } } </code></pre> <p>and finally ABContactSearch.java</p> <pre class="lang-java prettyprint-override"><code>public class ABContactSearch extends SearchContainer&lt;ABContact&gt; { private static Log _log = LogFactoryUtil.getLog(ABContactSearch.class); static List&lt;String&gt; headerNames = new ArrayList&lt;String&gt;(); static Map&lt;String, String&gt; orderableHeaders = new HashMap&lt;String, String&gt;(); static { headerNames.add("name"); headerNames.add("surname"); headerNames.add("position"); headerNames.add("society"); headerNames.add("contact-type"); headerNames.add("channel"); headerNames.add("brand"); headerNames.add("detail-value"); orderableHeaders.put("name", "name"); orderableHeaders.put("surname", "surname"); orderableHeaders.put("society", "society"); orderableHeaders.put("contact-type", "contact-type"); } public static final String EMPTY_RESULTS_MESSAGE = "no-contacts-were-found"; public ABContactSearch(PortletRequest portletRequest, PortletURL iteratorURL) { super( portletRequest, new ABContactDisplayTerms(portletRequest), new ABContactSearchTerms(portletRequest), DEFAULT_CUR_PARAM, DEFAULT_DELTA, iteratorURL, headerNames, EMPTY_RESULTS_MESSAGE); ABContactDisplayTerms displayTerms = (ABContactDisplayTerms)getDisplayTerms(); iteratorURL.setParameter( ABContactDisplayTerms.NAME, displayTerms.getName()); iteratorURL.setParameter( ABContactDisplayTerms.SURNAME, displayTerms.getSurname()); iteratorURL.setParameter( ABContactDisplayTerms.POSITION, displayTerms.getPosition()); iteratorURL.setParameter( ABContactDisplayTerms.DETAIL_VALUE, displayTerms.getDetailValue()); iteratorURL.setParameter( ABContactDisplayTerms.SOCIETY_ID, String.valueOf(displayTerms.getSocietyId())); iteratorURL.setParameter( ABContactDisplayTerms.CONTACT_TYPE_ID, String.valueOf(displayTerms.getContactTypeId())); iteratorURL.setParameter( ABContactDisplayTerms.BRAND_ID, String.valueOf(displayTerms.getBrandId())); iteratorURL.setParameter( ABContactDisplayTerms.CHANNEL_ID, String.valueOf(displayTerms.getChannelId())); try { String orderByCol = ParamUtil.getString( portletRequest, "orderByCol", "surname"); String orderByType = ParamUtil.getString( portletRequest, "orderByType", "asc"); // OrderByComparator orderByComparator = // UsersAdminUtil.getUserOrderByComparator( // orderByCol, orderByType); setOrderableHeaders(orderableHeaders); setOrderByCol(orderByCol); setOrderByType(orderByType); // setOrderByComparator(orderByComparator); } catch (Exception e) { _log.error(e.getMessage()); _log.debug(e.getMessage(), e); } } } </code></pre> <p>the search container itself is working good, as the base search is performed by default with empty string, but the "search form" is not showing. I've tryed to put some debug messages on contact_search_form.jsp but none of them are printed into console. It seems the file is not being found or processed by the taglib..</p> <p>Any help would be appreciated!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload