Hello as many people I'm new to ajax but trying my best to understand. At this point I got a problem I'm not able to solve. I've looked on several forums and googled internet but I can't find a solution :S.
This is the basic idea: I'm trying to implement Ajax in a Portal page created in weblogic 9.2. I've created a portlet with the name Ajax.jsp and an additional page called test.jsp. Ajax.jsp is the main portlet page. And uses the xmlHttp.open on test.jsp to get some data from the database which should then be shown in ajax.jsp. I've now temporary put the responsetext in a textfield because when I run this the responsetext contains the whole Portal page (without the data from test.jsp). when I run ajax.jsp as a standalone page it works and get's the right output. Could somebody give me some help?
the code for ajax.jsp=
test.jsp looks like this:
This is the basic idea: I'm trying to implement Ajax in a Portal page created in weblogic 9.2. I've created a portlet with the name Ajax.jsp and an additional page called test.jsp. Ajax.jsp is the main portlet page. And uses the xmlHttp.open on test.jsp to get some data from the database which should then be shown in ajax.jsp. I've now temporary put the responsetext in a textfield because when I run this the responsetext contains the whole Portal page (without the data from test.jsp). when I run ajax.jsp as a standalone page it works and get's the right output. Could somebody give me some help?
the code for ajax.jsp=
Code:
<%@taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0" prefix="netui-data"%>
<%@taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
<html>
<body>
<script type="text/javascript">
function ajaxFunction(){
var xmlHttp;
var url="test.jsp?input=";
//var url="ajax.do?input= ";
//var url="ajax.do";
try{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e){
// Internet Explorer
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
//document.getElementById("txtHint").innerHtml= xmlHttp.responseText;
document.myForm.text.value= xmlHttp.responseText;
}
}
//document.myForm.text.value= url+document.myForm.channelID.value;
xmlHttp.open("GET",url+document.myForm.channelID.value,true);
//xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
</script>
<netui-data:declarePageInput name="channel" type="java.lang.Long" required="true" />
<netui:label value="${pageInput.channel}"></netui:label>
<form name="myForm">
Name: <input type="text"
onkeyup="ajaxFunction();" name="username"/>
<input type="hidden" name="channelID" value="${pageInput.channel}"/>
<textarea rows="35" cols="50" name="text">
</textarea>
</form>
<p>output: <span id="txtHint"></span></p>
</body>
</html>
Code:
<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0" prefix="netui-data"%>
<%@ taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
<%@ taglib uri="http://www.bea.com/servers/portal/tags/netuix/render" prefix="render"%>
<%@ page import="com.componence.repository.channel.ChannelModel"%>
<%@ page import="com.componence.repository.channel.ChannelService"%>
<%
Long typedvalue = Long.parseLong(request.getParameter("input"));//Long.parseLong("101");//
ChannelModel cm = ChannelService.getInstance().getChannel(typedvalue);
//System.out.println(typedvalue);
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");
response.getWriter().write(cm.toString());
%>
Comment