Change classname used in container rowChange classname used in container rowhttps://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=1174256472024-03-28T10:39:51Z2024-03-28T10:39:51ZRE: Change classname used in container rowOlaf Kockhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1174320512019-10-11T08:32:21Z2019-10-11T08:32:21Z<html><head></head><body><div class="quote-title">Francesco Laquintana:</div><blockquote><br>This is all code<%--<br>...<br>What do you refer?<br></blockquote>Ahem... did you see the code formatting option in the post's editor?<br>Anyway, it's these lines:<br><br><pre><code> <liferay-ui:search-container-results results="<%= hits.toList() %>" />
<liferay-ui:search-container-row classname="com.liferay.portal.kernel.search.Document" escapedmodel="<%= false %>" keyproperty="UID" modelvar="document" stringkey="<%= true %>"></liferay-ui:search-container-row></code></pre><br>the first line (search-container-results) provides hits.toList() as the collection that the next line (search-container-row) iterates over. As there's no typed content, search-container-row states which type to expect in hits.toList(), which is - correctly - com.liferay.portal.kernel.search.Document.<br>If you'd want a different type to be available, you'll have to iterate through a different collection. For that I'd suggest to move the code creating this collection out of the JSP and into proper backend code, e.g. an MVCRenderCommand, or the doView method of your portlet. Or even into an MVCActionCommand or the processAction method.</body></html>Olaf Kock2019-10-11T08:32:21ZRE: Change classname used in container rowFrancesco Laquintanahttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1174260542019-10-10T15:55:43Z2019-10-10T15:55:43ZThis is all code<%--<br />/**<br /> * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.<br /> *<br /> * This library is free software; you can redistribute it and/or modify it under<br /> * the terms of the GNU Lesser General Public License as published by the Free<br /> * Software Foundation; either version 2.1 of the License, or (at your option)<br /> * any later version.<br /> *<br /> * This library is distributed in the hope that it will be useful, but WITHOUT<br /> * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS<br /> * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more<br /> * details.<br /> */<br />--%><%<br />SearchContainer mainSearchSearchContainer = new SearchContainer(renderRequest, null, null, SearchContainer.DEFAULT_CUR_PARAM, SearchContainer.DEFAULT_DELTA, portletURL, null, null);SearchContext searchContext = SearchContextFactory.getInstance(request);mainSearchSearchContainer.setEmptyResultsMessage(LanguageUtil.format(pageContext, "no-results-were-found-that-matched-the-keywords-x", "<strong>" + HtmlUtil.escape(searchContext.getKeywords()) + "</strong>"));searchContext.setAttribute("paginationType", "more");<br />searchContext.setEnd(mainSearchSearchContainer.getEnd());QueryConfig queryConfig = new QueryConfig();queryConfig.setCollatedSpellCheckResultEnabled(collatedSpellCheckResultEnabled);<br />queryConfig.setCollatedSpellCheckResultScoresThreshold(collatedSpellCheckResultDisplayThreshold);<br />queryConfig.setHighlightEnabled(true);<br />queryConfig.setQueryIndexingEnabled(queryIndexingEnabled);<br />queryConfig.setQueryIndexingThreshold(queryIndexingThreshold);<br />queryConfig.setQuerySuggestionEnabled(querySuggestionsEnabled);<br />queryConfig.setQuerySuggestionScoresThreshold(querySuggestionsDisplayThreshold);<br />queryConfig.setQuerySuggestionsMax(querySuggestionsMax);searchContext.setQueryConfig(queryConfig);searchContext.setStart(mainSearchSearchContainer.getStart());Facet assetEntriesFacet = new AssetEntriesFacet(searchContext);assetEntriesFacet.setStatic(true);searchContext.addFacet(assetEntriesFacet);Facet scopeFacet = new ScopeFacet(searchContext);scopeFacet.setStatic(true);searchContext.addFacet(scopeFacet);List<FacetConfiguration> facetConfigurations = FacetConfigurationUtil.load(searchConfiguration);for (FacetConfiguration facetConfiguration : facetConfigurations) {<br /> Facet facet = FacetFactoryUtil.create(searchContext, facetConfiguration); searchContext.addFacet(facet);<br />}Indexer indexer = FacetedSearcher.getInstance();Hits hits = indexer.search(searchContext);String[] queryTerms = hits.getQueryTerms();request.setAttribute("search.jsp-queryTerms", queryTerms);boolean showMenu = advancedConfiguration || displayScopeFacet || displayAssetTypeFacet || displayAssetTagsFacet || displayAssetCategoriesFacet || displayFolderFacet || displayUserFacet || displayModifiedRangeFacet;<br />%><aui:row cssClass='<%= "search-layout" + (showMenu ? " menu-column" : StringPool.BLANK) %>'><br /> <c:if test="<%= showMenu %>"><br /> <aui:col id="facetNavigation" span="2"> <%<br /> Map<String, Facet> facets = searchContext.getFacets(); List<Facet> facetsList = ListUtil.fromCollection(facets.values()); facetsList = ListUtil.sort(facetsList, new PropertyComparator("facetConfiguration.weight", false, false)); for (Facet facet : facetsList) {<br /> if (facet.isStatic()) {<br /> continue;<br /> } FacetConfiguration facetConfiguration = facet.getFacetConfiguration(); request.setAttribute("search.jsp-facet", facet);<br /> %> <liferay-util:include page='<%= "/html/portlet/search/facets/" + facetConfiguration.getDisplayStyle() + ".jsp" %>' /> <%<br /> }<br /> %> <aui:script use="aui-base"><br /> var container = A.one('#<portlet:namespace />facetNavigation'); if (container) {<br /> container.delegate(<br /> 'click',<br /> function(event) {<br /> var term = event.currentTarget; var facetValue = term.ancestor('.facet-value'); if (facetValue) {<br /> var currentTerm = facetValue.hasClass('active'); facetValue.radioClass('active'); if (!currentTerm) {<br /> facetValue.radioClass('active'); var searchFacet = facetValue.ancestor('.search-facet'); if (searchFacet) {<br /> var field = document.<portlet:namespace />fm['<portlet:namespace />' + searchFacet.attr('data-facetFieldName')]; if (field) {<br /> field.value = term.attr('data-value'); document.<portlet:namespace />fm.<portlet:namespace /><%= SearchContainer.DEFAULT_CUR_PARAM %>.value = 1; submitForm(document.<portlet:namespace />fm);<br /> }<br /> }<br /> } event.preventDefault();<br /> }<br /> },<br /> '.facet-value a'<br /> );<br /> }<br /> </aui:script><br /> </aui:col><br /> </c:if> <aui:col cssClass="result" first="<%= !showMenu %>" span="10"><br /> <%@ include file="/html/portlet/search/main_search_suggest.jspf" %> <liferay-ui:search-container<br /> searchContainer="<%= mainSearchSearchContainer %>"<br /> total="<%= hits.getLength() %>"<br /> ><br /> <liferay-ui:search-container-results<br /> results="<%= hits.toList() %>"<br /> /> <liferay-ui:search-container-row<br /> className="com.liferay.portal.kernel.search.Document"<br /> escapedModel="<%= false %>"<br /> keyProperty="UID"<br /> modelVar="document"<br /> stringKey="<%= true %>"<br /> ><br /> <liferay-ui:search-container-column-jsp path='<%= displayResultsInDocumentForm ? "/html/portlet/search/main_search_document_form.jsp" : "/html/portlet/search/main_search_result_form.jsp" %>' /><br /> </liferay-ui:search-container-row> <liferay-ui:search-iterator type="more" /> <c:if test="<%= displayMainQuery && (hits.getQuery() != null) %>"><br /> <table class="full-query"><br /> <tr><br /> <td valign="top"><br /> <div class="container"><br /> <code><br /> <%= HtmlUtil.escape(hits.getQuery().toString()) %><br /> </code><br /> </div><br /> </td><br /> </tr><br /> </table><br /> </c:if><br /> </liferay-ui:search-container><br /> </aui:col><br /></aui:row><br />What do you refer?Francesco Laquintana2019-10-10T15:55:43ZRE: Change classname used in container rowOlaf Kockhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1174239562019-10-10T15:21:59Z2019-10-10T15:21:59Z<html><head></head><body><div class="quote-title">Francesco Laquintana:</div><blockquote><br><pre><code></code></pre>How can i use Journal article list in className Field? <br></blockquote>You can, but you'd have to provide a list of JournalArticles for enumeration instead of a list of Documents. A bit further up on the page than the code that you posted, you'll find a declaration of the list (or its name) that you're using: That list's content is the key to the className parameter for the search-container-row attribute.</body></html>Olaf Kock2019-10-10T15:21:59ZChange classname used in container rowFrancesco Laquintanahttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1174256462019-10-10T14:47:24Z2019-10-10T14:47:24Z<html><head></head><body><pre><code></code></pre>How can i use Journal article list in className Field? In portlet search is used "<pre><code>com.liferay.portal.kernel.search.Document</code></pre>" But i would use "com.liferay.portlet.journal.model.JournalArticle". How can i do it? I use liferay 6.2<pre><code><liferay-ui:search-container-row classname="com.liferay.portal.kernel.search.Document" escapedmodel="<%=false%>" keyproperty="UID" modelvar="document" stringkey="<%=true%>"></liferay-ui:search-container-row></code></pre><pre><code>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;%@ include file="../../intestazione_widget_risultati_contenuti.jsp"%&gt;</code></pre><pre><code>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<liferay-ui:search-container-column-jsp path="/html/cellContenuti.jsp" />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp