Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Seeya S Kudtarker
Pass search container values to another jsp
April 18, 2013 10:20 PM
Answer

Seeya S Kudtarker

Rank: Regular Member

Posts: 187

Join Date: January 15, 2013

Recent Posts

I have a problem here. I am using search container which displays values based on some condition.

I have made each value as a hyperlink so that when I click on them the user is redirected to another jsp.
Note that each value in the row is given the same hyperlink.
Here's a snippet of code:
leaveDetails.jsp
<portlet:renderURL var="viewPendingLeaveApplicationsURL"/>
<liferay-ui:search-container delta="20" emptyResultsMessage="No Results Found">
<liferay-ui:search-container-results total="<%= pendingApprovals .size() %>"
results="<%= ListUtil.subList(pendingApprovals , searchContainer.getStart(), searchContainer.getEnd()) %>" />
<liferay-ui:search-container-row modelVar="search"
className="com.test.portal.model.LeaveApplication">
<portlet:renderURL var="leaveApplicationURL">
<portlet:param name="jspPage" value="/admin/doSomething.jsp" />
</portlet:renderURL>
<liferay-ui:search-container-column-text name='Leave Duration' value = '<%=String.valueOf(search.getLeaveDuration())%>' href="<%= leaveApplicationURL.toString()%>" />

<liferay-ui:search-container-column-text name="From" value ='<%=String.valueOf(search.getLeaveFromDate())%>' href = "<%= leaveApplicationURL.toString()%>"/>

<liferay-ui:search-container-column-text name="To" value ='<%=String.valueOf(search.getLeaveToDate())%>' href = "<%= leaveApplicationURL.toString()%>"/>

<liferay-ui:search-container-column-text name="Reason" value ='<%=String.valueOf(search.getLeaveReason())%>' href = "<%= leaveApplicationURL.toString()%>"/>

<liferay-ui:search-container-column-text name="Remarks" value ='<%=String.valueOf(search.getLeaveRemarks())%>' href = "<%= leaveApplicationURL.toString()%>"/>

</liferay-ui:search-container-row>
<liferay-ui:search-iterator/>
</liferay-ui:search-container>




What I wan to do is this:
Whenever I click on any value in the row it should redirect me to a jsp say doSomething.jsp. The doSomething.jsp should display only those values that were clicked on in the leaveDetails.jsp so that I can do further processing on data/

What is the way to pass values diplayed in search container to another jsp?
Seeya S Kudtarker
RE: Pass search container values to another jsp
April 18, 2013 10:22 PM
Answer

Seeya S Kudtarker

Rank: Regular Member

Posts: 187

Join Date: January 15, 2013

Recent Posts

In the above code I have the follwoign snippet:

<portlet:renderURL var="leaveApplicationURL">
<portlet:param name="jspPage" value="/admin/doSomething.jsp" />
</portlet:renderURL>


Should I use actionURL instead of renderURL??
Mohammad Azharuddin
RE: Pass search container values to another jsp
April 18, 2013 10:48 PM
Answer

Mohammad Azharuddin

Rank: Expert

Posts: 479

Join Date: September 17, 2012

Recent Posts

Hi
pass the value of current row along with the URL

<portlet:renderURL var="leaveApplicationURL">
<portlet:param name="jspPage" value="/admin/doSomething.jsp" />
<portlet:param name="paramName" value="value"/>
</portlet:renderURL>


<liferay-ui:search-container-row
className="com.xxx.xxx.model.XXX" keyProperty="recId"
modelVar="category">
current row object you can get using modelVar object..ie example category.getXX()



Use renderURL
Seeya S Kudtarker
RE: Pass search container values to another jsp
April 19, 2013 2:22 AM
Answer

Seeya S Kudtarker

Rank: Regular Member

Posts: 187

Join Date: January 15, 2013

Recent Posts

Mohammad:

Here is the change that I have made:

<liferay-ui:search-container-row keyProperty = "empId" modelVar="search"
className="com.corpserver.mallyas.mis.portal.model.LeaveApplication">
<portlet:renderURL var="leaveApplicationURL">
<portlet:param name="jspPage" value="/admin/doSomething.jsp" />
<portlet:param name="search" value= <%search.getEmpId(); %>/>
</portlet:renderURL>

How do I access the values of the selected employee in the second jsp?

Can you provide me a snippet of code?
Mohammad Azharuddin
RE: Pass search container values to another jsp
April 19, 2013 2:39 AM
Answer

Mohammad Azharuddin

Rank: Expert

Posts: 479

Join Date: September 17, 2012

Recent Posts

String search= request.getParameter("search");