Search container column jsp not working in liferay - search

The Search Container column jsp is not working in liferay.
I am trying to include a jsp within Liferay Search-container of type Document, for displaying search results for a given string.
Below is the snippet of code displaying search-container in the page:
<liferay-ui:search-container searchContainer="<%=tagsearchContainer%>">
<liferay-ui:search-container-results>
results="<%= hits.toList() %>"
total="<%= hits.getLength() %>"
</liferay-ui:search-container-results>
<liferay-ui:search-container-row
className="com.liferay.portal.kernel.search.Document"
escapedModel="<%= false %>"
keyProperty="UID"
modelVar="document"
stringKey="<%=true %>"
>
<liferay-ui:search-container-column-jsp path="/html/search_tag_result_form.jsp"/>
</liferay-ui:search-container-row>
</liferay-ui:search-container>
The search container only displays all fields from the document,all mashed up,without any errors.It does not display the content from the jsp(actually does not include it,and does not throw even if wrong path for jsp is there).Mashed up results are displayed from container-row .

I think you are missing the <liferay-ui:search-iterator /> before the end-tag </liferay-ui:search-container>.
This <liferay-ui:search-iterator /> is used to actually displays the list and the contents inside the <liferay-ui:search-container-row> tag.
Here is a good explanation for most of the commonly used tags for search-container.

Related

Display html code in browser in liferay search container

I am using liferay search container to display tables data. In one of the field, I need to display the HTML code as given. My question is How to Display html code in browser. My code is as follows.
<liferay-ui:search-container-column-text property="question" name="Question" />
You could do something like this:
<liferay-ui:search-container-column-text name="Question" >
<div class="question"><%= nameOfTheObjectInCollection.getQuestion() %></div>
</liferay-ui:search-container-column-text>

How to pass input text value as portlet param

I have a portlet page:
<%# taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
<portlet:resourceURL var="resourceUrl">
<portlet:param name="startDate" value="" />
</portlet:resourceURL>
<input id="startdateexportaging" type="text" />
<a style="font-size: 15px;" href="${resourceUrl}" >URL</a>
How to pass the content of startdateexportaging as portlet param startDate when clicking the link with resourceUrl?
You could use an onclick handler to add the content to the URL as soon the link is clicked. But that would be cumbersome, error prone and not necessary.
Instead you should add your input to a form and define the URL as action parameter:
<aui:form action="<%= resourceUrl.toString() %>" method="get">
<aui:input name="startDate" type="text" />
<aui:button value="Download" type="submit" />
</aui:form>
(if you don't use AUI - you can use simple HTML tags as well)
Another advantage of this solution: A button instead of a link makes it easier for the user to understand that the content from the text field is submitted. Compare it with the use of links and buttons here on SO - if you enter some information you have to hit a button.
And it is easier for search engines to parse the website, as those try to follow links - but ignore buttons.

How can we create the back button in liferay

Can any one tell me how can I create the back button in my portlet. Are there any existing tags to create the back button which looks like as shared below.
Solution as mentioned in below post should work.
http://www.liferay.com/en_GB/community/forums/-/message_boards/message/22392288
Liferay uses back URL in many of its default portlets.
For example, You can refer sources for message board portlet - view.jsp, edit_category.jsp
If you use to move from first JSP to second JSP, then backURL should be passed as argument in first JSP and retrieve in second JSP to use inside liferay-ui:header tag.
For example,
<portlet:renderURL var="varURL">
<portlet:param name="mvcPath" value="<second-JSP-URL>"></portlet:param>
<portlet:param name="backURL" value="<%= themeDisplay.getURLCurrent() %>"></portlet:param>
</portlet:renderURL>
Try this instead.
Just use one line and it will direct back to previous URL.(Place this code in second jsp).
<input type=button value=" Back" onClick="javascript: window.history.go(-1)" text-align="right">

Refer the id variable of logic - iterate using jstl-el

Facing a unusual challenge :
//Code
<logic:iterate id="list" name="accountRouteConfigListForm" property="valueList" indexId="incr">
<div <custom:align defaultAlign="left"/>>
<html:select name="list" property="accountStatus" onchange="onChangeStatus(${list.accName})"> //This is not working, how to refer accName in list
<html:option value="<%= String.valueOf(Constants.ENABLED) %>">
</html:option>
<html:option value="<%= String.valueOf(Constants.DISABLED) %>">
</html:option>
How do i refer a field inside a list and pass it as an argument to onChangeStatus
First, it seems you are missing an end tag for <logic:iterate> in your example code.
Second, unless you have a very good reason, try to use JSTL instead of the outdated struts custom tags. It's always good to stay with standards, right?
In your case, that would look like this:
<c:forEach items="${accountRouteConfigListForm.valueList}" var="list">
....
</c:forEach>

Create own customized Web Content List

I'm looking to create my own Web Content List portlet. I exactly want to display the web content of my portal applying some filters.
I'm a little bit lost...
I tried to create a hook but I dont know how to find the possible actions of this portlet.
I don't want to get all the content. I want to use a rules mechanism for filtering the contents(drools portlet), depending on the user information.
Thank you in advance,
Oriol
You can get the list of web contents by using following method:
List<JournalArticle> result = JournalArticleLocalServiceUtil.getArticles(groupId, -1, -1);
You can display the list using liferay search container as:
<liferay-ui:search-container delta="30" emptyResultsMessage="no-users-were-found">`
<liferay-ui:search-container-results>`
results="<%= result%>"
total="<%=result.size() %>" />
<liferay-ui:search-container-row
className="com.liferay.portlet.journal.model.JournalArticle"
keyProperty="articleId"
modelVar="content" >
<liferay-ui:search-container-column-text
name="ID" value="<%= content.getArticleId()%>" /> // You can add multiple columns
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
Hope this will help you.

Resources