So I have a search container with results in it. The last column of this container is a jsp column. Here is the code for the search container:
<%
PortletURL postsUrlPaginator = renderResponse.createRenderURL();
postsUrlPaginator.setParameter( "currentID", Long.toString( currentID ) );
postsUrlPaginator.setParameter( "jspPage", "/admin/CLAdmin.jsp" );
postsUrlPaginator.setParameter( "mainTabs", "Categories" );
%>
<liferay-ui:search-container emptyResultsMessage = "there-are-no-postings" delta = "5" iteratorURL="<%= postsUrlPaginator %>" curParam="postsUrlPaginator">
<liferay-ui:search-container-results>
<%
List<CLPosting> postings = CLPostingLocalServiceUtil.getLockedPostings( true );
results = ListUtil.subList( postings, searchContainer.getStart(), searchContainer.getEnd() );
pageContext.setAttribute( "results", results );
pageContext.setAttribute( "total", postings.size() );
%>
</liferay-ui:search-container-results>
<liferay-ui:search-container-row
className="com.camelslist.posting.model.CLPosting"
keyProperty="postID"
modelVar="posting">
<liferay-ui:search-container-column-text
name="postingTitle"
property="postTitle" />
<liferay-ui:search-container-column-text
name="locked"
property="locked" />
<liferay-ui:search-container-column-jsp
path="/admin/post/CLAdmin_post_actions.jsp" />
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
I use a jsp file (CLAdmin_post_actions.jsp) in that last column to generate action buttons for each row returned. I would like to pass values to that jsp file before it creates those buttons for each row.
<%@include file="/init.jsp" %>
<%
ResultRow row = (ResultRow) request.getAttribute( WebKeys.SEARCH_CONTAINER_RESULT_ROW );
CLPosting posting = (CLPosting) row.getObject();
long groupId = themeDisplay.getLayout().getGroupId();
String name = CLPosting.class.getName();
String primeKey = String.valueOf( posting.getPrimaryKey() );
System.out.println( "posting: " + posting.getPostTitle() + " : " + "ID: " + Long.toString( posting.getPrimaryKey() ) );
long currentID = posting.getCategoryID();
CLCategory category = ( currentID != Long.valueOf( 0 ) ) ? CLCategoryLocalServiceUtil.getCLCategory( currentID ) : null;
long parentCatID = ( category != null ) ? category.getParentID() : Long.valueOf( 0 );
%>
<liferay-ui:icon-menu>
<c:if test = "<%= permissionChecker.hasPermission( groupId, name, primeKey, ActionKeys.DELETE ) %>" >
<portlet:actionURL name="deletePosting" var="deleteURL">
<portlet:param name="resourcePrimeKey" value="<%= primeKey %>" />
<portlet:param name="currentID" value="<%= Long.toString( currentID ) %>" />
</portlet:actionURL>
<liferay-ui:icon-delete url="<%= deleteURL.toString() %>" />
</c:if>
<c:if test="<%= permissionChecker.hasPermission(groupId, name, primeKey, ActionKeys.VIEW) %>" >
</c:if>
<c:if test="<%= permissionChecker.hasPermission(groupId, name, primeKey, ActionKeys.UPDATE) %>" >
<c:if test="<%= posting.getLocked() == false %>" >
<portlet:actionURL name="lockPosting" var="lockURL">
<portlet:param name="resourcePrimeKey" value="<%= primeKey %>" />
<portlet:param name="currentID" value="<%= Long.toString( currentID ) %>" />
<portlet:param name="mainTabs" value="Categories" />
<portlet:param name="lock" value="true" />
</portlet:actionURL>
<liferay-ui:icon image="lock" url="<%= lockURL.toString() %>" />
</c:if>
<c:if test="<%= posting.getLocked() == true %>" >
<portlet:actionURL name="lockPosting" var="lockURL">
<portlet:param name="resourcePrimeKey" value="<%= primeKey %>" />
<portlet:param name="currentID" value="<%= Long.toString( currentID ) %>" />
<portlet:param name="mainTabs" value="Categories" />
<portlet:param name="lock" value="false" />
</portlet:actionURL>
<liferay-ui:icon image="unlock" url="<%= lockURL.toString() %>" />
</c:if>
</c:if>
<c:if test = "<%= permissionChecker.hasPermission( groupId, name, primeKey, ActionKeys.PERMISSIONS) %>">
<liferay-security:permissionsURL
modelResource="<%= CLPosting.class.getName() %>"
modelResourceDescription="<%= posting.getPostTitle() %>"
resourcePrimKey="<%= primeKey %>"
var="permissionsURL" />
<liferay-ui:icon image="permissions" url="<%= permissionsURL.toString() %>" />
</c:if>
</liferay-ui:icon-menu>
How would I do so? Can I do so?
I answered this question myself actually, and the answer is very obvious (for seasoned portlet developers I suppose).
I was attempting to pass the needed values by way of a parameter. When I used the servlets attribute instead I was able to get the needed value.
Here is what was added to the above code to make this answer a bit more clear:
<%
//NEW LINES ADDED
String mainTabs = ParamUtil.getString( request, "mainTabs", "Categories" );
request.setAttribute( "mainTabs", mainTabs );
PortletURL postsUrlPaginator = renderResponse.createRenderURL();
postsUrlPaginator.setParameter( "currentID", Long.toString( currentID ) );
postsUrlPaginator.setParameter( "jspPage", "/admin/CLAdmin.jsp" );
postsUrlPaginator.setParameter( "mainTabs", "Categories" );
%>
//... additional code not shown
then in the CLAdmin_actions.jsp add the following line at the top to retrieve our value:
String mainTabs = (String) request.getAttribute( "mainTabs" );