java032 发表于 2013-1-29 11:41:00

未定题目

I am developing the JSP portlet using plugin sdk.

I want to implement AJAX in this portlet.

I am facing the problem while sending the URL in

jQuery.ajax({
type: "GET",
url: "/changemode.jsp",
data: "modeVal=rahul",
success: function(msg){
alert( "Data Saved: " + msg );
}});


the changemode.jsp is @ same location as the calling JSP.

It doest show any error msg, but the changemode.jsp is not get called.

Please advice.

Thanks in advance.
------------------------------------------------------------------------------------
you need to pass url like that

var url = '<portlet:renderURL windowState="<%= LiferayWindowState.EXCLUSIVE.toString() %>"><portlet:param name="struts_action" value="/ext/search/changemode" /></portlet:renderURL>';

and struts action entry should be in struts-config.xml and tiles-defs.xml

-------------------------------------------------------------------------------------
Use the serveResource() method (javax.portlet.GenericPortlet):

<div class="code"> 1    public void serveResource(ResourceRequest request, ResourceResponse response)
 2            throws PortletException, IOException {
 3       
 4        // Make the parameter "modeVal" available in changeMode.jsp
 5        String modeVal = ParamUtil.getString(request, "modeVal");
 6        request.setAttribute("modeVal", modeVal);
 7       
 8        // Dispatch to changeMode.jsp
 9        PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher(
10                "/WEB-INF/jsp/changeMode.jsp");
11        dispatcher.include(request, response);
12    }
页: [1]
查看完整版本: 未定题目