Fórumok

liferay portlet method call using Ajax

thumbnail
Yogesh Kumar, módosítva 10 év-val korábban

liferay portlet method call using Ajax

New Member Bejegyzések: 9 Csatlakozás dátuma: 2013.06.03. Legújabb bejegyzések
This code is not working plz help me....
jsp page:-
<portlet:actionURL var="methodURL" name="stateCityDropDownList" windowState="<%= LiferayWindowState.EXCLUSIVE.toString()%>"
--------------------------
ajax call:-
var url='<%= methodURL%>';
---------------------
Portlet :-
long stateId = ParamUtil.getLong(actionRequest , "stateId");
System.out.println("State Id = " +stateId);

This is showing stateId=0

please reply soon anybody.

Thanks
thumbnail
David H Nebinger, módosítva 10 év-val korábban

RE: liferay portlet method call using Ajax

Liferay Legend Bejegyzések: 14919 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
I don't see where you are setting any parameters on the url such as stateId...
thumbnail
Yogesh Kumar, módosítva 10 év-val korábban

RE: liferay portlet method call using Ajax

New Member Bejegyzések: 9 Csatlakozás dátuma: 2013.06.03. Legújabb bejegyzések
<select id="provinceId" name="provinceId"
onchange="changeCity(this.value);">
<option value=""><%=LanguageUtil.get(pageContext, "Spec-Cat-Name")%></option>
<%
for (SpecCategory specCatObj : specCatList) {
%>
<option value="<%=specCatObj.getSpecCatId()%>"><%=specCatObj.getSpecCatName()%></option>
<%
}
%>
</select>
<select id="cityId" name="cityId">
<option value=""><%=LanguageUtil.get(pageContext, "Specifi-Name")%></option>
</select>

<script type="text/javascript>
<portlet:actionURL var="methodURL" name="showStatCityAjax"
windowState="<%=LiferayWindowState.EXCLUSIVE.toString()%>" />

<script src="<%=request.getContextPath()%>/js/jquery.js"></script>
<script type="text/javascript">

function changeCity(provinceId)
{
<%-- var url="<%=request.getContextPath().concat(showStatCityAjax.toString())%>"+"?provinceId="+provinceId; --%>
var url='<%=methodURL%>';
alert("URL="+url);
alert("id = " +provinceId);
var id = document.getElementById('cityId');
var controlId = id.options[id.selectedIndex].text;
init(url, controlId);
}


</script>
-----------------------------------------------------------
portlet class is:

public void showStatCityAjax(ActionRequest request , ActionResponse response) throws NumberFormatException, SystemException{
System.out.println("Hello");
String specCantName = null;
String specName = null;
long specId;
String message = "*" + "" + "#";
String provinceId = request.getParameter("provinceId");
//String provinceId = ParamUtil.getString(request, "provinceId");
System.out.println("Province Id =" +provinceId);

Here this is printing Province Id is null and i am able to show NullPointerException
please guide me.
thumbnail
David H Nebinger, módosítva 10 év-val korábban

RE: liferay portlet method call using Ajax

Liferay Legend Bejegyzések: 14919 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
You cannot just tack on url arguments and expect them to be passed in. Portals don't work that way.

That's the whole reason there's the <actionURL /> tag, it has sub-tags available that you can use to specify parameters to pass.

In AJAX, though, you would normally be doing a resource request (not a portlet action).
thumbnail
Ramanjeneyulu Bodepudi, módosítva 10 év-val korábban

RE: liferay portlet method call using Ajax

Junior Member Bejegyzések: 42 Csatlakozás dátuma: 2012.02.24. Legújabb bejegyzések
Need to User serveResource method instead of process Action.