访问另一个jsp中搜索容器中显示的值 [英] Access values displayed in Search Container in another jsp
问题描述
我有一个jsp,其中显示了一些有人说员工的数据. 每个员工的数据显示为一行. 我已将每一行都做为链接,以便当用户单击任何提供特定员工详细信息的行时, 用户将被定向到一个显示员工相同数据的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 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>
在上面的代码中,我试图传递用户选择的行的empId
.
但是第二个jsp中什么也没有显示.我想在第二个jsp上传递所有这些信息.
我在代码中看到一个小问题,问题在于生成URL的方式:
<portlet:renderURL var="leaveApplicationURL">
<portlet:param name="jspPage" value="/admin/AddCompany.jsp" />
<portlet:param name="search" value='<%String.valueOf(search.getEmpId());%>'/>
</portlet:renderURL>
此行:
<portlet:param name="search" value='<%String.valueOf(search.getEmpId());%>'/>
应为:
<portlet:param name="search" value='<%= String.valueOf(search.getEmpId()) %>'/>
您是否注意到了这一点: <%=
String.valueOf(search.getEmpId())%>
,所以像<%=
这样添加了开头,而尾随的;
也被删除了.
因此,简而言之,您需要使用 jsp expression
在value
属性中的脚本代码块中. >
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.
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.
这篇关于访问另一个jsp中搜索容器中显示的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!