Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Andrew Jardine
SearchContainer woes -- can't render certain columns?
October 25, 2012 10:02 AM
Answer

Andrew Jardine

Community Moderator

Rank: Liferay Legend

Posts: 1699

Join Date: December 22, 2010

Recent Posts

Help! I'm getting so frustrated with Liferay right now that I am contemplating switching over to the red side (Oracle).

Summary.
1. I query SOLR using the solrj library (works).

2. The result (SolrDocumentList) is added to the renderRequest as an attribute to get it back to the JSP (works).
1
2renderRequest.setAttribute("searchResults", resultsList);       


3. In the JSP I retrieve the list (works).
1
2    int recordCount = 0;
3    SolrDocumentList searchResults = (SolrDocumentList)renderRequest.getAttribute("searchResults");
4
5    if ( searchResults != null )
6        recordCount = searchResults.size();


4. I bind the variable used to store this (searchResults) to the search-container-results (like so)
1
2<liferay-ui:search-container-results results="<%= searchResults %>" total="<%= recordCount %>" >


5. My schema in SOLR has three fields I am concerned with --
name (type="text_general" multiValue="false")
parents (type="text_general" multiValue="true")
children (type="text_general" multiValue="true")

Outputting the name column like so (works).
1
2<liferay-ui:search-container-column-text
3                                name="skill"
4                                value='<%= solrDocument.getFieldValue("name").toString() %>'
5                                />


6. When I try eiher the children or the parents, I get a stack trace --
1
2<liferay-ui:search-container-column-text
3                                name="skill"
4                                value='<%= solrDocument.getFieldValue("parents").toString() %>'
5                                />


.. the stack trace ultimately giving a null pointer exception. I checked the portal source and the columns want Strings... and the toString() generates one. The only difference really is that for the name its a single value and when I toString() the list for parents I get "[name, name. name]". I even went as far as to create a String variable, set it using THE SAME CODE, and then adding teh variable to the column, which works?!

I don't understand what the issue is. Any help would be appreciated.
Andrew Jardine
[SOLVED]RE: SearchContainer woes -- can't render certain columns?
October 25, 2012 6:36 PM
Answer

Andrew Jardine

Community Moderator

Rank: Liferay Legend

Posts: 1699

Join Date: December 22, 2010

Recent Posts

In the end this (thanks to Ray for this one) did it for me --

1
2<liferay-ui:search-container-column-text name="Parents">
3    <%= solrDocument.getFieldValue("parents") %>
4</liferay-ui:search-container-column-text>


.. which I swear I had tried. Interestingly though, if I use the same code, but place .toString() on the end it fails. Anyway, that's what solved it for me.

Participate in the State of Liferay Community 2017. Help the community and even win some prizes!