jquery - serveResource called when i call actions -
i use jquery.ajax call method in portlet :
serveresource(resourcerequest request, resourceresponse response)
the problem when try call action(actionrequest req,actionresponse resp) or submit buttons,only serveresource called .
to call serveresource use in jsp :
<portlet:resourceurl var="ajaxurl" > <portlet:param name="jsp" value="<%=request.getpathinfo()%>" /> </portlet:resourceurl>
why , method called when call other actions methods .
edit:
my controller code:
public class conseillerporlet extends mvcportlet { public void addconsultant(actionrequest request,actionresponse response){ list<string> errors=new arraylist<string>(); conseillerlocalserviceutil.addconseiller(request, response); sessionerrors.add(request, "error-saving-consultant"); } } catch (exception e) { // todo auto-generated catch block e.printstacktrace(); } } @override public void serveresource(resourcerequest request, resourceresponse response) throws ioexception, portletexception { string jsp=paramutil.getstring(request, "jsp"); system.out.println("serveresouce called "+jsp); if(jsp.equals("/html/view.jsp")){ string s=""; list<classe> classes; long id=paramutil.getlong(request, "id"); try { classes=utils.getlistclasses(etablissementid); for(classe classe : classes) { s=s+"<option value='"+classe.getclasseid()+"'>"+classe.getnomclasse()+"</option>"; } } catch (systemexception e) { e.printstacktrace(); } response.getwriter().write(s);//return options <select> using ajax , jquery } }
}
thanks help
it because you're creating resource url , doing hit serveresource
method. if hit action method you'll need create action url.
<portlet:actionurl name="updatesomething" var="updatesomethingurl" />
then inside portlet class can define:
public void updatesomething(actionrequest actionrequest, actionresponse actionresponse) throws exception { // code goes here. }
note name
attribute of <portlet:actionurl />
corresponds method name above if you're extending liferay mvcportlet
class.
Comments
Post a Comment