-1
任何线索我们如何开发自定义JSON服务。自定义JSON服务
我们没有service.xml,因为内部服务将调用liferay服务来检索活动。 从我们的portlet中,我们希望通过Ajax调用此自定义JSON服务并显示结果。
我们不想使用serveResource。
问候, 蒂娜
任何线索我们如何开发自定义JSON服务。自定义JSON服务
我们没有service.xml,因为内部服务将调用liferay服务来检索活动。 从我们的portlet中,我们希望通过Ajax调用此自定义JSON服务并显示结果。
我们不想使用serveResource。
问候, 蒂娜
使用XMLHttpRequest()对象:
<%@include file="include.jsp"%>
<script type='text/javascript'>
function <portlet:namespace/>myService() {
var xhr = new XMLHttpRequest();
//...
var url = "<%=request.getContextPath()%>/myCustomJSONService";
xhr.open("GET", url, true);
xhr.send();
}
</script>
<table>
<tr>
<td><b><a href="#"
<!--Creates Refresh hyperlink-->
onclick="<portlet:namespace/>myService();"
style="color: black;">Refresh</a></b></td>
</tr>
</table>
<br/>
<div id="<portlet:namespace/>messageText">
</div>
这里myCustomJSONService可能是一些JSON数据发送到用户的servlet。
见A.沙林:在行动的Portlet,12.2.3章:
你要什么这个服务做“使用的portlet或servlet组件处理Ajax请求”? “检索活动”和“显示结果”太含糊。 – 2012-04-27 20:47:19