<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>luauf.com &#187; AJAX</title>
	<atom:link href="http://luauf.com/category/programacion/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://luauf.com</link>
	<description>Sistemas Operativos, Bases de Datos, Programación y Redes</description>
	<lastBuildDate>Mon, 14 May 2012 01:15:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Introducción a GWT</title>
		<link>http://luauf.com/2008/06/23/introduccion-a-gwt/</link>
		<comments>http://luauf.com/2008/06/23/introduccion-a-gwt/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 23:50:38 +0000</pubDate>
		<dc:creator>Luciano</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programación]]></category>

		<guid isPermaLink="false">http://luauf.com/?p=460</guid>
		<description><![CDATA[Mucho se puede hablar acerca de GWT, como son mis primeros pasos y este post está dedicado a quienes también quieran dar sus primeros pasos, intentaré ser breve y preciso. GWT es un...]]></description>
			<content:encoded><![CDATA[<p>Mucho se puede hablar acerca de GWT, como son mis primeros pasos y este post está dedicado a quienes también quieran dar sus primeros pasos, intentaré ser breve y preciso.</p>
<p>GWT es un framework open source de Google para el desarrollo en Java, que permite compilar esa aplicación y traducirla a Javascript y HTML. De esta forma podrás escribir complejas aplicaciones que hagan uso de AJAX, pero sin tener la menor idea de AJAX.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-461" title="google_balls" src="http://luauf.com/wp-content/uploads/2008/06/google_balls.png" alt="" width="135" height="86" /></p>
<p>Sin más preámbulos, ayudado por <a href="http://esgooglewebtoolkit.blogspot.com/" target="_blank">Google Web Tookit &#8211; Documentación en español</a> vamos a descargar GWT y crear el primer y clásico Hola Mundo.</p>
<p><span id="more-460"></span></p>
<ul>
<li>Primero de todo, descargamos <a href="http://code.google.com/webtoolkit/" target="_blank">Google Web Toolkit</a></li>
<li>Descomprimimos el archivo, esto nos genera un directorio que debemos agregar al path a la variable de entorno PATH:
<ul>
<li>En Linux, hacemos un export de la variable PATH, agregándole el path del GWT. Es una buena idea hacer el export al abrir el shell en el archivo $HOME/.<span>bashrc.</span></li>
<li><span>En Windows, a través de Propiedades del Sistema -&gt; Opciones avanzadas -&gt; Variables de entorno y Variables de usuario o Variables del Sistema.<br />
</span></li>
</ul>
</li>
</ul>
<ul>
<li>Para crear una nueva aplicación nos valemos de un script applicationCreator (o applicationCreator.cmd para Windows).
<ul>
<li>Para crear una aplicación, en una consola ejecuto <strong>applicationCreator com.luauf.client.Hola</strong>, esto nos creará la estructura de directorios y el archivo <strong>src/luauf/client/Hola.java</strong>.</li>
<li>Al mismo nivel del directorio src, creará dos scripts (de igual forma que el script applicationCreator, si utilizamos Windows los scripts tendrán la extensión .cmd.
<ul>
<li><strong>Hola-shell</strong>: este script corre la aplicación en &#8220;Hosted Mode&#8221;. El navegador web &#8220;Hosted&#8221; de GWT permite correr y ejecutar aplicaciones GWT pero sobre bytecodes de una máquina virtual.</li>
<li><strong>Hola-compile</strong>: convierte el código fuente Java a JavaScript, transformando tu aplicación Java a su equivalente aplicación JavaScript.  application.</li>
</ul>
</li>
<li>En primera instancia, lo que haremos será correr nuestra aplicación, ejecutando el script <strong>Hola-shell</strong>.</li>
</ul>
</li>
<li>También es posible crear una aplicación GWT con todos los archivos de proyecto para Eclipse, uno de los IDE por excelencia para el desarrollo y depuración de aplicaciones Java.
<ul>
<li>Para crear una aplicación GWT para Eclipse, debemos correr <strong>applicationCreator -eclipse GWTHola com.luauf.client.Hola</strong>, y luego, para crear la base de la aplicación y los archivos de configuración para eclipse <strong>projectCreator -eclipse GWTHola</strong>.</li>
<li>Luego, desde Eclipse importamos el proyecto desde File -&gt; Import -&gt; Existing Projects into Workspace&#8221;</li>
</ul>
</li>
</ul>
<p>Esto es todo por ahora, el próximo paso será empezar a programar.<br />
<a href="http://esgooglewebtoolkit.blogspot.com/" target="_blank"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://luauf.com/2008/06/23/introduccion-a-gwt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Servlets, NetBeans y AJAX</title>
		<link>http://luauf.com/2008/05/24/servlets-netbeans-y-ajax/</link>
		<comments>http://luauf.com/2008/05/24/servlets-netbeans-y-ajax/#comments</comments>
		<pubDate>Sat, 24 May 2008 22:33:20 +0000</pubDate>
		<dc:creator>Luciano</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[J2EE]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://luauf.com/?p=318</guid>
		<description><![CDATA[Este artículo es la continuación del ejemplo iniciado con Introducción a Java Servlets con NetBeans. El objetivo es modificar el proyecto realizado, para que los datos que se envían al Servlet se hagan...]]></description>
			<content:encoded><![CDATA[<p>Este artículo es la continuación del ejemplo iniciado con <a href="http://luauf.com/2008/05/21/introduccion-a-java-servlets-con-netbeans/" target="_self">Introducción a Java Servlets con NetBeans</a>. El objetivo es modificar el proyecto realizado, para que los datos que se envían al Servlet se hagan por medio del objeto XMLHttpRequest y que mediante DOM accedamos y modifiquemos algunas partes de nuestro documento actual. En resumen, el objetivo es incorporar AJAX a nuestro proyecto. Por lo tanto, también recomiendo leer una <a href="http://luauf.com/2008/05/04/ajax-introduccion-teorica/" target="_self">Introducción teórica a AJAX</a>, ya que en este artículo me enfocaré exclusivamente en el código.</p>
<p><span id="more-318"></span></p>
<p>Sobre el proyecto inicial de <a href="http://luauf.com/2008/05/21/introduccion-a-java-servlets-con-netbeans/" target="_self">Introducción a Java Servlets con NetBeans</a>, realizaremos las siguientes modificaciones:</p>
<ul>
<li>Del lado del cliente:
<ul>
<li>En el formulario de envío de datos se quitará el botón submit y se agregará un nuevo botón, que en su evento onclick ejecutará una función Javascript.</li>
<li>Se agregará una función Javascript, que instanciará el objeto XMLHttpRequest, enviará los datos al servidor y procesará la respuesta del Servlet.</li>
</ul>
</li>
<li>Del lado del servidor:
<ul>
<li>Se modificará el código de la respuesta enviada por el Servlet, antes enviaba todo un documento HTML (&lt;HTML&gt;&lt;HEAD&gt;&#8230;. &lt;/HEAD&gt;&lt;BODY&gt;&#8230;&lt;/BODY&gt;&lt;/HTML&gt;). Ahora solo enviará un fragmento de código HTML, pues el mismo, procesado por el cliente, se insertará en la página HTML existente, pues con el objeto XMLHttpRequest el cliente se evita cargar de nuevo la página (uno de los principales objetivos de AJAX)</li>
</ul>
</li>
</ul>
<p>Haciendo efectivos los cambios mencionados, el cliente queda así:</p>
<p><code></p>
<div class="syntax_hilite">
<div id="html-3">
<div class="html"><span style="color: #009900;"><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">&lt;html&gt;</span></a></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">&lt;head&gt;</span></a></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">&lt;meta</span></a> <span style="color: #000066;">http-equiv</span>=<span style="color: #ff0000;">"Content-Type"</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">"text/html; charset=UTF-8"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">&lt;title&gt;</span></a></span>Hello World<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head&gt;</span></span></p>
<p>
&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script&gt;</span></a></span><br />
&nbsp; &nbsp; function Enviar() {</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; var obj = false;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; if (window.XMLHttpRequest) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Cuidado aqui, el objeto XMLHttpRequest no esta disponible en versiones previas a IE7<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; obj = new XMLHttpRequest();<br />
&nbsp; &nbsp; &nbsp; &nbsp; } else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; obj.onreadystatechange = function () {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ( obj.readyState == 4 <span style="color: #ddbb00;">&amp;&amp; (obj.status == 200 || window.location.href.indexOf (&quot;http&quot;)==- 1)) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document.getElementById(&quot;Respuesta_Hello&quot;).innerHTML = obj.responseText;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //procesando...<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; };<br />
&nbsp; &nbsp; &nbsp; &nbsp; obj.open(&quot;GET&quot;, &quot;Servlet_Hola?nombre=&quot; + document.getElementById(&quot;nombre&quot;).value , true);<br />
&nbsp; &nbsp; &nbsp; &nbsp; obj.send(null);</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; return (true);<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></p>
<p>&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">&lt;body&gt;</span></a></span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/form.html"><span style="color: #000000; font-weight: bold;">&lt;form</span></a> <span style="color: #000066;">action</span>=<span style="color: #ff0000;">"Servlet_Hola"</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">"GET"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Ingrese su nombre: <span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">&lt;input</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text"</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"nombre"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">""</span> <span style="color: #000066;">size</span>=<span style="color: #ff0000;">"45"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"nombre"</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">&lt;input</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"button"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"Enviar (con Ajax)"</span> <span style="color: #000066;">onclick</span>=<span style="color: #ff0000;">"Enviar();"</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"enviarAjax"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/form&gt;</span></span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"Respuesta_Hello"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- Este DIV contendra la respuesta enviada por el Servlet --&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></p>
<p>&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body&gt;</span></span></p>
<p><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html&gt;</span></span></div>
</div>
</div>
<p>
</code></p>
<p>Por el lado del servidor, el método <strong>processRequest</strong> del Servlet queda así:</p>
<p><code></p>
<div class="syntax_hilite">
<div id="java-4">
<div class="java"><span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">void</span> processRequest<span style="color: #66cc66;">&#40;</span>HttpServletRequest request, HttpServletResponse response<span style="color: #66cc66;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">throws</span> ServletException, <a href="http://www.google.com/search?q=allinurl%3AIOException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">IOException</span></a> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; response.<span style="color: #006600;">setContentType</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"text/html;charset=UTF-8"</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3APrintWriter+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">PrintWriter</span></a> out = response.<span style="color: #006600;">getWriter</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; out.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"&lt;strong&gt;Hola "</span> + request.<span style="color: #006600;">getParameter</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"nombre"</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #ff0000;">"&lt;strong&gt;"</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">finally</span> <span style="color: #66cc66;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; out.<span style="color: #006600;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
<p>
</code></p>
<p>Lo ejecutamos, de la misma forma que antes ejecutabamos nuestro proyecto desde NetBeans y probamos tener el comportamiento deseado:</p>
<p style="text-align: center;"><a href="http://luauf.com/wp-content/uploads/2008/05/hello.jpg"><img class="aligncenter size-medium wp-image-319" title="hello" src="http://luauf.com/wp-content/uploads/2008/05/hello-300x88.jpg" alt="" width="300" height="88" /></a></p>
<p style="text-align: left;">
]]></content:encoded>
			<wfw:commentRss>http://luauf.com/2008/05/24/servlets-netbeans-y-ajax/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>AJAX: Introducción teórica</title>
		<link>http://luauf.com/2008/05/04/ajax-introduccion-teorica/</link>
		<comments>http://luauf.com/2008/05/04/ajax-introduccion-teorica/#comments</comments>
		<pubDate>Sun, 04 May 2008 22:18:02 +0000</pubDate>
		<dc:creator>Luciano</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Programación]]></category>

		<guid isPermaLink="false">http://luauf.com/?p=232</guid>
		<description><![CDATA[AJAX (Asynchronous JavaScript And XML) no es el nombre de una nueva tecnología, sinó una combinación de ellas. Básicamente, el principio de AJAX es hacer que las aplicaciones web se comporten de forma...]]></description>
			<content:encoded><![CDATA[<p>AJAX (Asynchronous JavaScript And XML) no es el nombre de una nueva tecnología, sinó una combinación de ellas. Básicamente, el principio de AJAX es hacer que las aplicaciones web se comporten de forma más natural, como lo hacen las aplicaciones de escritorio.</p>
<p style="text-align: center;"><a href="http://luauf.com/wp-content/uploads/2008/05/ajax_p.jpg"><img class="aligncenter size-medium wp-image-233" title="ajax_p" src="http://luauf.com/wp-content/uploads/2008/05/ajax_p-300x149.jpg" alt="" width="300" height="149" /></a></p>
<p><span id="more-232"></span></p>
<p>Las tecnologías de AJAX:</p>
<ul>
<li><strong>XHTML y CSS</strong>: la interfaz de una aplicación AJAX es una página web cargada en un navegador.  XHTML y CSS son los dos estándares definidos por la W3C para la construcción de una página web.</li>
<li><strong>JavaScript</strong>: las aplicaciones AJAX deben ser escritas en algún lenguaje de programación, este lenguaje es JavaScript.</li>
<li><strong>XML</strong>: aunque podría utilizarse cualquier otro formato basado en texto (por ejemplo JSON), cuando la aplicación del servidor tiene que enviar una serie de datos de forma estructurada al cliente, XML resulta la solución más práctica.</li>
<li><strong>El Modelo de Objeto de Documento (DOM)</strong>: proporciona el mecanismo para acceder desde código a información contenida en un documento de texto basado en etiquedas (XHTML o XML)</li>
<li><strong>El objeto XMLHttpRequest</strong>: se trata del componente fundamental de una aplicación AJAX. A través de sus propiedades es posible lanzar peticiones en modo asíncrono al servidor y acceder a la cadena de testo enviada en la respuesta.</li>
</ul>
<p>Las anteriores tecnologías constituyen el núcleo fundamental de AJAX, sin embargo, estas aplicaciones se apoyan de las siguientes tecnologías y estándares:</p>
<ul>
<li><strong>HTTP</strong>: al igual que el navegador, el objeto XMLHttpRequest utiliza el protocolo HTTP para realizar las solicitudes al servidor, manejando también las respuestas recibidas.</li>
<li><strong>Tecnologías del servidor</strong>: una aplicación AJAX debe tener del lado del servidor un programa que atienda las peticiones, genere y envíe las respuestas. Existen numerosas tecnologías, pero puedne emplearse J2EE, ASP.NET o PHP.</li>
</ul>
<p>Vía: Ajax en J2EE (Antonio J. Martín Sierra)</p>
]]></content:encoded>
			<wfw:commentRss>http://luauf.com/2008/05/04/ajax-introduccion-teorica/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

