Access values displayed in Search Container in another jsp

左心房为你撑大大i 提交于 2019-12-13 03:59:52

问题


I have a jsp where I display some data of some people say employees. The data of each employee is displayed as a row. I have made each row as a link so that when a user clicks on any row which gives details of a particular employee, the user is directed to a jsp which displays the same data of the employee so that further processing could be done.

My question is how should I pass the data of an employee when a user clicks on the row which contains that particular employee information?

What I have right now done is this:

<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 keyProperty = "empId" modelVar="search"
            className="com.corpserver.mallyas.mis.portal.model.LeaveApplication">

        <portlet:renderURL var="leaveApplicationURL">
            <portlet:param name="jspPage"  value="/admin/AddCompany.jsp" />
            <portlet:param name="search" value='<%String.valueOf(search.getEmpId());%>'/>
        </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>

In the above code I am trying to pass the empId of the row which the user selects. But nothing gets displayed in the second jsp. I want to pass all of this information on second jsp.


回答1:


Well I see a small problem in the code, problem is in the way the URL is generated:

<portlet:renderURL var="leaveApplicationURL">
    <portlet:param name="jspPage"  value="/admin/AddCompany.jsp" />
    <portlet:param name="search" value='<%String.valueOf(search.getEmpId());%>'/>
</portlet:renderURL>

This line:

<portlet:param name="search" value='<%String.valueOf(search.getEmpId());%>'/>

should be:

<portlet:param name="search" value='<%= String.valueOf(search.getEmpId()) %>'/>

did you notice this: <%=String.valueOf(search.getEmpId())%>, the starting is added like <%= and the trailing ; is removed.

So in short you need an jsp expression instead of scriptlet code block in the value attribute.




回答2:


You need to use <portlet:actionURL /> instead of render one.

<portlet:actionURL var="leaveApplicationURL">
    <portlet:param name="jspPage"  value="/admin/AddCompany.jsp" />
    <portlet:param name="search" value= '<%String.valueOf(search.getEmpId());%>'/>
</portlet:actionURL>

@ProcessAction(name = "gotToEmployee")
public void changeCurrency(ActionRequest request, ActionResponse response) {
    //perform here any action you want, like search in DB
    response.setRenderParameter("search", request.getParameter("search"));
    response.setRenderParameter("page", request.getParameter("jspPage"));
}

Then use this parameters in your render method.



来源:https://stackoverflow.com/questions/16102205/access-values-displayed-in-search-container-in-another-jsp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!