0

我的 Liferay 有问题。我正在执行以下操作:

function deleting() {
    <portlet:actionURL var="deletePolyURL"> 
        <portlet:param name="jspPage" value="/deletePoly.jsp" /> 
    </portlet:actionURL>  

    <portlet:renderURL var="listingURL"> 
        <portlet:param name="jspPage" value="/listing.jsp" /> 
    </portlet:renderURL>

    $.post(
        "<%=deletePolyURL%>",
        {
            ids:ch.toString()
        },
        function(per) {
              $("#WRAPlist").load("<%=listingURL%>");
               }
    );
}

<div>重新加载,但在此<div>整个 Liferay 页面被加载,而不仅仅是我的页面,请参见图像的右侧。

在此处输入图像描述

我做错了什么?

deletePoly.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>


<%
            {
              //String st = request.getParameter("ids");
              String st = ParamUtil.getString(request,"ids");
              out.println("NE TORT");
                        String[] id_str;
                        id_str=st.split(",");
              Class.forName("org.postgresql.Driver");
                Connection connect= null;
                connect = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgis","postgres","123456");
                Statement state = null;
                state = connect.createStatement();
                int id;
                String sql1="";
                String sql2="";
                for(int i=0;i<id_str.length;i++)
                {
                    id=Integer.parseInt(id_str[i]);
                    sql1="DELETE FROM filestatus WHERE id=?";
                    PreparedStatement stmt1 = connect.prepareStatement(sql1);
                    stmt1.setInt(1, id);
                    stmt1.execute();
                    sql2="DELETE FROM filedata WHERE id=?";
                    PreparedStatement stmt2 = connect.prepareStatement(sql2);
                    stmt2.setInt(1, id);
                    stmt2.execute();
                }
                state.close();
                connect.close();
                Integer per=1;
                out.println(per);
              }

         %>

列表.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
Class.forName("org.postgresql.Driver");
Connection conn= null;
conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgis","postgres","123456");
Statement sta = null;
sta = conn.createStatement();
String fileName= "";
Integer fileId=null;
String fileStatus ="";

ResultSet r=sta.executeQuery("SELECT id, name, status FROM filestatus");
String acc="Принят                   ";
while(r.next())
{
    fileId=r.getInt("id");
    fileName=r.getString("name");
    fileStatus=r.getString("status");   
    if(fileStatus.equalsIgnoreCase(acc))
    {
        out.write("<input type='checkbox' class='myclass' id='check"+fileId+"' name='"+fileName+"' value='"+fileId+"'/><label for=check"+fileId+">"+fileName+"</label><br>");   
  }
    else
    {
        out.write("<input type='checkbox' class='myclass' id='check"+fileId+"' name='"+fileName+"' value='"+fileId+"'/><label for=check"+fileId+" style='color:blue'>"+fileName+"</label><br>");

    }
}
r.close();
sta.close();
conn.close();

%>
</body>
</html>

我刷新问题。

4

2 回答 2

0

如果您不想通过资源处理来自己处理整个 Ajax 调用,您还可以将回复限制为仅包含 portlet,而不是整个页面:

<%@ page import="com.liferay.portal.kernel.portlet.LiferayWindowState" %>

<portlet:actionURL var="deletePolyURL" windowState="<%=LiferayWindowState.EXCLUSIVE.toString() %>"> 
    <portlet:param name="jspPage" value="/deletePoly.jsp" /> 
</portlet:actionURL>

看看这是否有帮助 - 否则您应该<portlet:resourceURL>按照 Prakash 的建议使用(并在您的 portlet 的资源服务方法中处理该过程。

于 2012-07-02T13:00:36.077 回答
0

我建议您需要 a<portlet:resourceURL>而不是 renderURL 来加载 ,jsp因为它是一个 ajax 请求,并且您需要使用serveResourceportlet 类中的方法来加载listing.jsp.

<portlet:resourceURL var="listingURL"> 
    <portlet:param name="jspPage" value="/listing.jsp" /> 
</portlet:resourceURL>

希望这可以帮助。

于 2012-07-02T06:40:13.273 回答