如何将搜索容器列文本中的参数从一个jsp传递给另一个jsp?

时间:2013-08-29 16:18:58

标签: liferay-6

我需要将参数从search-container-column-text中的一个jsp传递给另一个jsp。我已经显示了结果,并且我在列的最后添加了超链接,当它点击它将打开edit.jsp页面,我需要将courseid传递给result.jsp中的edit.jsp。任何人都可以告诉我解决方案吗?

edit.jsp文件

<% 
PortletURL editCourseURL=renderResponse.createActionURL(); 
editCourseURL.setParameter(ActionRequest.ACTION_NAME,"editCourse"); 
%>

<%
        String ns =renderRequest.getParameter("courseId");
        System.out.println("hai hello "+ns);
        //long n= Long.parseLong(ns);
        System.out.println("hello world");
        Course courses =CourseLocalServiceUtil.getCourse(3);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        //sdf = new SimpleDateFormat("yyyy-MM-dd");
        String sdate = sdf.format(courses.getSdate());
        String edate = sdf.format(courses.getEdate());
        String cname=courses.getCname();
        String cdesc=courses.getCdesc();
        System.out.println(sdate);

%>

<form action="<%=editCourseURL%>" method="post" id="register-form" >

<div class="label1">Course Name</div>
<input type="text" id="cname" name="cname" value="<%=cname%>"/><br />
 <div class="label2">Course Description</div>

<input type="text" id="cdesc" name="cdesc" value="<%=cdesc%>"/><br/>
<div class="label3">Start Date</div>
<input type="date" name="sdate" id="sdate" value="<%=sdate%>"/><br/>
<div class="label4">End Date</div>
<input type="date" id="edate" name="edate" value="<%=edate%>" /><br />
<input type="submit" name="submit" value="Submit" />
  </form>



<portlet:renderURL var="homeURL">
 <portlet:param name="jspPage" value="/html/course/view.jsp"></portlet:param>
  </portlet:renderURL>
  <a href="<%=homeURL%>"> --HOME--</a>

result.jsp中:

 <% 
    int n=CourseLocalServiceUtil.getCoursesCount();
    List courses = CourseLocalServiceUtil.getCourses(0,n);
    if(Validator.isNull(courses))courses = new ArrayList();
%>

<portlet:renderURL var="edit">
<portlet:param name="jspPage" value="/html/course/edit.jsp"></portlet:param>
</portlet:renderURL>

<portlet:renderURL var="delete">
<portlet:param name="jspPage" value="/html/course/delete.jsp"></portlet:param>
</portlet:renderURL>


<liferay-ui:search-container delta="10" emptyResultsMessage="no-courses-were-found" >
<liferay-ui:search-container-results results="<%=courses%>" total="<%=courses.size()%>" />
<liferay-ui:search-container-row className="com.course.slayer.model.Course" modelVar="course" >

<liferay-ui:search-container-column-text name="Course Name" property="cname" />
<liferay-ui:search-container-column-text name="Course Description" property="cdesc" /> 
<liferay-ui:search-container-column-text name="Start Date" property="sdate" />
<liferay-ui:search-container-column-text name="End Date" property="edate" />
<liferay-ui:search-container-column-text name="Edit" href="<%=edit%>"  value="edit">
</liferay-ui:search-container-column-text>
<liferay-ui:search-container-column-text name="Delete" href="<%=delete%>"  value="delete" />

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

result.jsp中:

1 个答案:

答案 0 :(得分:0)

你可以传递这样的参数: -

<portlet:renderURL var="edit">
<portlet:param name="jspPage" value="/html/course/edit.jsp"></portlet:param>
<portlet:param name="courseName" value="<%=courseName%>"></portlet:param>
</portlet:renderURL>

<portlet:renderURL var="delete">
<portlet:param name="jspPage" value="/html/course/delete.jsp"></portlet:param>
<portlet:param name="courseName" value="<%=courseName%>"></portlet:param>
</portlet:renderURL>

HTH