Fórum

SearchContainer woes -- can't render certain columns?

thumbnail
Andew Jardine, modificado 11 Anos atrás.

SearchContainer woes -- can't render certain columns?

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
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).

renderRequest.setAttribute("searchResults", resultsList);		


3. In the JSP I retrieve the list (works).

	int recordCount = 0;
	SolrDocumentList searchResults = (SolrDocumentList)renderRequest.getAttribute("searchResults");

	if ( searchResults != null )
		recordCount = searchResults.size();


4. I bind the variable used to store this (searchResults) to the search-container-results (like so)

<liferay-ui:search-container-results results="<%= searchResults %>" total="<%= recordCount %>">
</liferay-ui:search-container-results>


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).

<liferay-ui:search-container-column-text name="skill" value="<%= solrDocument.getFieldValue(&quot;name&quot;).toString() %>" />


6. When I try eiher the children or the parents, I get a stack trace --

<liferay-ui:search-container-column-text name="skill" value="<%= solrDocument.getFieldValue(&quot;parents&quot;).toString() %>" />


.. 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.
thumbnail
Andew Jardine, modificado 11 Anos atrás.

[SOLVED]RE: SearchContainer woes -- can't render certain columns?

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
In the end this (thanks to Ray for this one) did it for me --


<liferay-ui:search-container-column-text name="Parents">
	&lt;%= solrDocument.getFieldValue("parents") %&gt;
</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.