<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest topics for the forum "MentaAjax"]]></title>
		<link>http://book.mentaframework.org/forums/show/33.page</link>
		<description><![CDATA[The newest discussed topics in the forum "MentaAjax"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>What is MentaAjax</title>
				<description><![CDATA[ MentaAjax is a small lib build with JavaScript to facilitate a comunication between Server and Client.<br /> Its turn easy put Beans, Maps, Sets, and String to ajax response.<br /> <br /> It structure is simple, look like this:<br /> [code]<br /> function getAnything(){<br /> <br /> 	var request = new mtw.request();<br /> <br /> 	request.setUrl("YourAction.mtw");<br /> <br /> 	request.onSuccess(callbackFuncion);<br /> <br /> 	request.send();<br /> }<br /> [/code]<br /> <br /> on 3 line, we create an object that will build de request.<br /> on 5 line, we tell it what URL/action we want to call.<br /> on 7 line, we tell it what JavaScript function will receive de response from request.<br /> on 9 line, we send de build request to server.<br /> <br /> The callback function can be any JavaScript function, and the [i]httptransport[/i] will be send together it.<br /> [code]<br /> function callbackFunction(transport){<br /> 	<br /> 	var text = transport.responseText;<br /> <br /> 	var xml	 = transport.responseXML;<br /> 	<br /> }<br /> [/code]<br /> <br /> But calm, MentaAjax also has a function that handle with response, and it's name is mtw.response.<br /> [code]<br /> function callbackFunction(transport){<br /> 	<br /> 	var response = new mtw.response();<br /> 	<br /> }<br /> [/code]<br /> <br /> Now lets go to build a simple example.<br /> <br /> I want to send my name to java code, turn it to uppercase and return to my page.<br /> <br /> JSP:<br /> [code]<br /> &lt;%@ taglib uri="/WEB-INF/lib/mentawai.jar" prefix="mtw" %&gt;<br /> <br /> &lt;mtw:ajaxConfig /&gt;<br /> <br /> &lt;input type="text" name="myName" id="myName"&gt;<br /> <br><br /> &lt;input type="button" onclick="goMenta();"&gt;<br /> <br><br /> <br /> &lt;div id="myNameHere"&gt;   &lt;/div&gt;<br /> <br /> &lt;script type="text/javascript"&gt;<br /> <br /> 	function callbackFunction(transport){<br /> 		<br /> 		var response = new mtw.response();<br /> <br /> 		var text = response.getString();<br /> <br /> 		var e =	document.getElementById("myNameHere");<br /> <br /> 		e.innerHTML = text;<br /> 		<br /> 	}<br /> 		<br /> 	function goMenta(){<br /> <br /> 		var inputValue = document.getElementById("myName").value;<br /> 		<br /> 		var request = new mtw.request();<br /> <br /> 		request.setUrl("TestAction.getName.mtw");<br /> <br /> 		request.addParameter("myName", inputValue);<br /> <br /> 		request.onSuccess( callbackFuncion );<br />  <br /> 		request.send();<br /> 		<br /> 	}<br /> <br /> &lt;/script&gt;<br /> [/code]<br /> <br /> <br /> Continue....]]></description>
				<guid isPermaLink="true">http://book.mentaframework.org/posts/preList/22/23.page</guid>
				<link>http://book.mentaframework.org/posts/preList/22/23.page</link>
				<pubDate><![CDATA[Wed, 13 Feb 2008 15:08:04]]> GMT</pubDate>
				<author><![CDATA[ robertwgil]]></author>
			</item>
	</channel>
</rss>