<?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>Kudos Ltda. - Blog &#187; Tutorial</title>
	<atom:link href="http://blog.gkudos.com/category/tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.gkudos.com</link>
	<description>.: Open Systems, Open Ideas :.</description>
	<lastBuildDate>Thu, 29 Apr 2010 23:25:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Creando un lector de GeoRSS con Adobe Flex 3</title>
		<link>http://blog.gkudos.com/2009/09/06/creando-un-lector-de-georss-con-adobe-flex-3/</link>
		<comments>http://blog.gkudos.com/2009/09/06/creando-un-lector-de-georss-con-adobe-flex-3/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 18:21:57 +0000</pubDate>
		<dc:creator>juanmendez</dc:creator>
				<category><![CDATA[Adobe Flex]]></category>
		<category><![CDATA[Datos Geográficos]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[adobe flex 3]]></category>
		<category><![CDATA[mashup]]></category>
		<category><![CDATA[Rich Internet Applications]]></category>

		<guid isPermaLink="false">http://blog.gkudos.com/?p=188</guid>
		<description><![CDATA[Uno de los ejemplos tradicionales que se desarrollan durante el aprendizaje de Flex 3 y Actionscript 3 es el de la creación de un lector de RSS. En el presente artículo se presenta una extensión de dicho ejemplo adicionando la capacidad de interpretar infomación publicada en el formato GeoRSS.


Qué es un RSS?

RSS es una familia [...]]]></description>
			<content:encoded><![CDATA[<p>Uno de los ejemplos tradicionales que se desarrollan durante el aprendizaje de Flex 3 y Actionscript 3 es el de la creación de un lector de RSS. En el presente artículo se presenta una extensión de dicho ejemplo adicionando la capacidad de interpretar infomación publicada en el formato GeoRSS.<br />
<a href="http://blog.gkudos.com/wp-content/uploads/georss.jpg"><img src="http://blog.gkudos.com/wp-content/uploads/georss.jpg" alt="" width="80%" heigth="80%" title="georss"  class="aligncenter size-medium wp-image-189" /></a></p>
<ul>
<li><strong>Qué es un RSS?</strong></li>
</ul>
<p><strong>RSS</strong> es una familia de formatos de <a title="Fuente web" href="http://es.wikipedia.org/wiki/Fuente_web">fuentes web</a> codificados en <a class="mw-redirect" title="XML" href="http://es.wikipedia.org/wiki/XML">XML</a>. Se utiliza para suministrar a suscriptores de <a title="Información" href="http://es.wikipedia.org/wiki/Informaci%C3%B3n">información</a> <a class="mw-redirect" title="Actualidad" href="http://es.wikipedia.org/wiki/Actualidad">actualizada</a> frecuentemente. El formato permite distribuir contenido sin necesidad de un navegador, utilizando un software diseñado para leer estos contenidos RSS (<a title="Agregador" href="http://es.wikipedia.org/wiki/Agregador">agregador</a>).</p>
<ul>
<li><strong>Qué es un GeoRSS?</strong></li>
</ul>
<p><strong>GeoRSS</strong> es un conjunto de estándares para representar información geográfica mediante el uso de capas y está construido dentro de la familia de estándares <a title="RSS" href="http://es.wikipedia.org/wiki/RSS">RSS</a>.</p>
<ul>
<li><strong>Cómo convertir un RSS en GeoRSS?</strong></li>
</ul>
<p>Si usted no dispone de una aplicación para convertir sus RSS en GeoRSS puede utilizar Geonames para realizar dicha traducción de formato.<br />
El &#8220;<a href="http://www.geonames.org/rss-to-georss-converter.html">RSS to GeoRSS Converter</a>&#8221; de Geonames busca posibles ubicaciones (sitios geogràficos) en el texto del  rss.  Si alguna ubicación geográfica relevante es encontrada, adiciona la latitud y longitud al RSS durante la codificación a GeoRSS.</p>
<ul>
<li><strong>Que requiero para implementar el lector de GeoRSS utilizando Adobe Flex 3?</strong></li>
</ul>
<p>- <a href="http://opensource.adobe.com/wiki/display/flexsdk/Flex+SDK">Flex SDK</a></p>
<p>- <a href="http://code.google.com/intl/es-ES/apis/maps/documentation/flash/">Google Maps Flash API</a></p>
<ul>
<li><strong>Donde puedo descargar el código fuente del ejemplo?</strong></li>
</ul>
<p>Puede descargar el código fuente desde <a href="http://pwp.007mundo.com/jcmendez/kudos/georss/src.zip">esta ubicación.</a></p>
<ul>
<li><strong>Que ejemplos de programación flex / actionscript  puedo encontrar en el código? </strong></li>
</ul>
<p>- Carga de datos en XML utilizando el objeto HTTPService</p>
<p>- Despliegue de datos utilizando componentes ComboBox, Datagrid e Image</p>
<p>- Formatear etiquetas de un ComboBox utilizando labelFunction.</p>
<p>- Despliegue de información HTML en el tooltip de la aplicación.</p>
<p>- Ejemplo básico de carga de Markers en Google Maps para Adobe Flex.</p>
<p>- Procesamiento de datos publicados en formatos XML, RSS y GeoRSS.</p>
<p>- Utilizar el servicio &#8220;Rss to GeoRSS&#8221; de Geonames con Flex y Actionscript.</p>
<ul>
<li><strong>Puedo ver en línea el código fuente del ejemplo y la aplicación resultante?</strong></li>
</ul>
<p>A continuación puede ver tanto la aplicación como el código fuente relacionado.<br/><br/><br />
<iframe src ="http://pwp.007mundo.com/jcmendez/kudos/georss/index.html" width="100%" height="400" frameborder="0"><br />
</iframe><br />
<br/><br/><br />
<strong>Código fuente del archivo Rss.mxml:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
</pre></td><td class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> </span>
<span style="color: #000000;">	layout=<span style="color: #ff0000;">&quot;vertical&quot;</span></span>
<span style="color: #000000;">	applicationComplete=<span style="color: #ff0000;">&quot;onComplete();&quot;</span> </span>
<span style="color: #000000;">	creationComplete=<span style="color: #ff0000;">&quot;loadSourcesService.send();&quot;</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Style</span><span style="color: #7400FF;">&gt;</span></span>
	Application{
		background-color:#ffffff;
		paddingBottom:5; 
		paddingLeft:5;
		paddingRight:5; 
		paddingTop:5;
	}
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Style</span><span style="color: #7400FF;">&gt;</span></span>	
<span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">	&lt;![CDATA[</span>
<span style="color: #339933;">		import com.google.maps.controls.ZoomControlOptions;</span>
<span style="color: #339933;">		import mx.collections.ArrayCollection;</span>
<span style="color: #339933;">		import com.google.maps.overlays.MarkerOptions;</span>
<span style="color: #339933;">		import com.google.maps.overlays.Marker;</span>
<span style="color: #339933;">		import ejemplo.HTMLToolTip;</span>
<span style="color: #339933;">		import mx.managers.ToolTipManager;</span>
<span style="color: #339933;">		import flash.net.navigateToURL;</span>
<span style="color: #339933;">		import mx.controls.List;</span>
<span style="color: #339933;">		import mx.controls.Alert;</span>
<span style="color: #339933;">		import mx.events.ListEvent;</span>
<span style="color: #339933;">		import mx.rpc.events.FaultEvent;</span>
<span style="color: #339933;">		import mx.rpc.events.ResultEvent;</span>
<span style="color: #339933;">		import com.google.maps.MapType;</span>
<span style="color: #339933;">		import com.google.maps.LatLng;</span>
<span style="color: #339933;">		import com.google.maps.controls.PositionControl;</span>
<span style="color: #339933;">		import com.google.maps.controls.MapTypeControl;</span>
<span style="color: #339933;">		import com.google.maps.controls.ZoomControl;</span>
<span style="color: #339933;">		import com.google.maps.Map;</span>
<span style="color: #339933;">		import com.google.maps.MapEvent;</span>
&nbsp;
<span style="color: #339933;">		public var map:Map;</span>
&nbsp;
<span style="color: #339933;">	    //se invoca en el evento 'creationComplete' </span>
<span style="color: #339933;">		private function onComplete() :void{</span>
<span style="color: #339933;">			//configuración del tooltip para despliegue de HTML</span>
<span style="color: #339933;">			ToolTipManager.toolTipClass = HTMLToolTip; </span>
<span style="color: #339933;">		}</span>
&nbsp;
<span style="color: #339933;">		//Manejo de la respuesta del HTTPService loadSourcesService</span>
<span style="color: #339933;">		private function loadSourcesService_result(evt:ResultEvent):void {</span>
<span style="color: #339933;">		    var resultObj:Object = evt.result;</span>
<span style="color: #339933;">		    sourcesCb.dataProvider = resultObj.xml.lista.item;</span>
<span style="color: #339933;">		}</span>
&nbsp;
<span style="color: #339933;">		//Iniciar el Mapa</span>
<span style="color: #339933;">		private function startMap(event:Event):void {</span>
<span style="color: #339933;">			map = new Map();</span>
<span style="color: #339933;">			//Key de google Maps: http://code.google.com/intl/es-ES/apis/maps/documentation/flash/</span>
<span style="color: #339933;">			map.key = map.key = &quot;ABQIAAAAzP_X84EVzii7yEPHkonPNRRMdub8RYo7ePgaMtJOPXtU0LG1eBQz8J6xJi_XxLQ80ti-WlGkph7kVw&quot;;</span>
<span style="color: #339933;">			map.addEventListener(MapEvent.MAP_READY, onMapReady);</span>
&nbsp;
<span style="color: #339933;">			var zoomopts:ZoomControlOptions = new ZoomControlOptions();</span>
<span style="color: #339933;">			zoomopts.hasScrollTrack = false;</span>
<span style="color: #339933;">			var zoomCtrl:ZoomControl = new ZoomControl(zoomopts);</span>
<span style="color: #339933;">			map.addControl(zoomCtrl);</span>
&nbsp;
<span style="color: #339933;">			// add MapType Controller</span>
<span style="color: #339933;">			var mapTypeCtrl:MapTypeControl = new MapTypeControl();</span>
<span style="color: #339933;">			map.addControl(mapTypeCtrl);</span>
&nbsp;
<span style="color: #339933;">			// add Position Controller</span>
<span style="color: #339933;">			var posCtrl:PositionControl = new PositionControl();</span>
<span style="color: #339933;">			map.addControl(posCtrl);</span>
<span style="color: #339933;">			mapContainer.addChild(map);</span>
<span style="color: #339933;">		}</span>
&nbsp;
<span style="color: #339933;">		private function resizeMap(event:Event):void {</span>
<span style="color: #339933;">			map.setSize(new Point(mapContainer.width, mapContainer.height));</span>
<span style="color: #339933;">		}</span>
&nbsp;
<span style="color: #339933;">		private function onMapReady(event:MapEvent):void {</span>
<span style="color: #339933;">			//setCenter:  Parámetros: Coordenada Punto Central, Nivel de Zoom, Tipo de Mapa</span>
<span style="color: #339933;">			map.setCenter(new LatLng(4,-73),3, MapType.NORMAL_MAP_TYPE);</span>
<span style="color: #339933;">			//Habilita el Zoom Continuo</span>
<span style="color: #339933;">			map.enableContinuousZoom();</span>
<span style="color: #339933;">			//Habilita el Scroll del mapa utilizando el Mouse </span>
<span style="color: #339933;">			map.enableScrollWheelZoom();</span>
<span style="color: #339933;">		}</span>
&nbsp;
<span style="color: #339933;">		// Se invoca cuando el usuario cambia de opcion en el combo box</span>
<span style="color: #339933;">		// se obtiene el rss y se pasa al HTTPService 'loadRssService'</span>
<span style="color: #339933;">		private function getFuenteNombre ( event: ListEvent) : void{					</span>
<span style="color: #339933;">			if(sourcesCb.selectedItem){</span>
<span style="color: #339933;">				//configura la llamada al servicio geonames que recibe como parámetro</span>
<span style="color: #339933;">				//la url del rss que se va a georreferenciar</span>
<span style="color: #339933;">				//http://www.geonames.org/rss-to-georss-converter.html</span>
<span style="color: #339933;">				loadRssService.url= &quot;http://ws.geonames.org/rssToGeoRSS?feedUrl=&quot;+sourcesCb.selectedItem.url;</span>
<span style="color: #339933;">				loadRssService.send();</span>
<span style="color: #339933;">				//elimina todos los markers del mapa</span>
<span style="color: #339933;">				map.clearOverlays();</span>
<span style="color: #339933;">				rssList.dataProvider = new ArrayCollection();</span>
<span style="color: #339933;">			}</span>
<span style="color: #339933;">		}</span>
&nbsp;
<span style="color: #339933;">		//Esta funcion se llama cuando cambia el DataGrid, tiene como objetivo</span>
<span style="color: #339933;">		//establecer el contenido a desplegar en la descripcion, tomandolo del xml.</span>
<span style="color: #339933;">		private function getPage(event: ListEvent) : void{</span>
<span style="color: #339933;">			var selectedEq:Object = rssList.selectedItem;</span>
<span style="color: #339933;">			titulo.text = rssList.selectedItem.title;</span>
<span style="color: #339933;">			contenido.htmlText=rssList.selectedItem.description;</span>
<span style="color: #339933;">			//Alert.show(rssList.selectedItem[&quot;encoded&quot;])</span>
<span style="color: #339933;">			mas.visible=true;</span>
<span style="color: #339933;">			var latlng:LatLng = new LatLng(Number(rssList.selectedItem.lat),Number(rssList.selectedItem.long));</span>
<span style="color: #339933;">			//lo hace solo cuando geonames devuelva la latitud y la longitud</span>
<span style="color: #339933;">			if(rssList.selectedItem.lat!=undefined||rssList.selectedItem.long!=undefined){</span>
<span style="color: #339933;">				var marker:Marker = generateMarker(selectedEq); </span>
<span style="color: #339933;">				map.setCenter(latlng , 3);	</span>
<span style="color: #339933;">				map.addOverlay(marker);</span>
<span style="color: #339933;">			}</span>
<span style="color: #339933;">		}</span>
&nbsp;
<span style="color: #339933;">		private function generateMarker(item:Object ):Marker{</span>
<span style="color: #339933;">			//crea un objeto de tipo LatLng</span>
<span style="color: #339933;">				var latlng:LatLng = new LatLng(Number(item.lat),Number(item.long));				</span>
<span style="color: #339933;">				//tooltip del Marker  </span>
<span style="color: #339933;">				var markerOptions : MarkerOptions= new MarkerOptions();</span>
<span style="color: #339933;">			    markerOptions.tooltip = item.title;</span>
<span style="color: #339933;">			    var marker : Marker = new Marker( latlng, markerOptions );</span>
<span style="color: #339933;">				return marker;</span>
<span style="color: #339933;">		}</span>
&nbsp;
<span style="color: #339933;">		//Esta funcion se llama cuando se hace click en el enlace </span>
<span style="color: #339933;">		//que me envia a la pagina de la fuente, coge el campo link del xml.</span>
<span style="color: #339933;">		private function getUrl() : void{</span>
<span style="color: #339933;">			//configura el request del LinkButton con el objeto link del xml </span>
<span style="color: #339933;">			var u:URLRequest = new URLRequest(rssList.selectedItem.link);</span>
<span style="color: #339933;">        	navigateToURL(u,&quot;_blank&quot;);</span>
<span style="color: #339933;">		}</span>
&nbsp;
<span style="color: #339933;">		//Se llama cuando hay un resultado en HTTPService loadRssService</span>
<span style="color: #339933;">		protected function onServiceResult(event:ResultEvent):void {</span>
<span style="color: #339933;">			rssList.dataProvider = event.result.rss.channel.item;</span>
<span style="color: #339933;">			//configura la ubicacion de la imagen con el campo image.url</span>
<span style="color: #339933;">			imagen.source=event.result.rss.channel.image.url;</span>
<span style="color: #339933;">			titulo.text = &quot;&quot;;</span>
<span style="color: #339933;">			contenido.htmlText='Seleccione una Noticia';</span>
<span style="color: #339933;">			mas.visible=false;</span>
<span style="color: #339933;">		}</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #339933;">		//Se llama cuando hay un fault HTTPService loadEQService y en HTTPService loadRssService</span>
<span style="color: #339933;">		private function load_fault(evt:FaultEvent):void {</span>
<span style="color: #339933;">			Alert.show('Ocurrió un Error en el Servidor', evt.fault.faultString);</span>
<span style="color: #339933;">		}</span>
&nbsp;
<span style="color: #339933;">		private function  sourcesCbLabelFunction(item:Object):String{</span>
<span style="color: #339933;">			return item.nombre + &quot; (&quot;+item.pais+&quot;)&quot;;</span>
<span style="color: #339933;">		}</span>
&nbsp;
<span style="color: #339933;">	]]&gt;</span>
<span style="color: #339933;">&lt;/mx:Script&gt;</span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:HTTPService</span> id=<span style="color: #ff0000;">&quot;loadSourcesService&quot;</span></span>
<span style="color: #000000;">	            url=<span style="color: #ff0000;">&quot;sources.xml&quot;</span></span>
<span style="color: #000000;">	            resultFormat=<span style="color: #ff0000;">&quot;object&quot;</span></span>
<span style="color: #000000;">	            result=<span style="color: #ff0000;">&quot;{loadSourcesService_result(event);}&quot;</span></span>
<span style="color: #000000;">	            fault=<span style="color: #ff0000;">&quot;load_fault(event);&quot;</span></span>
<span style="color: #000000;">	            showBusyCursor=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:HTTPService</span> id=<span style="color: #ff0000;">&quot;loadRssService&quot;</span></span>
<span style="color: #000000;">	            resultFormat=<span style="color: #ff0000;">&quot;object&quot;</span></span>
<span style="color: #000000;">	            result=<span style="color: #ff0000;">&quot;onServiceResult(event);&quot;</span></span>
<span style="color: #000000;">	            fault=<span style="color: #ff0000;">&quot;load_fault(event);&quot;</span></span>
<span style="color: #000000;">	            showBusyCursor=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:HDividedBox</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> height=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Panel</span> id=<span style="color: #ff0000;">&quot;panel1&quot;</span> width=<span style="color: #ff0000;">&quot;50%&quot;</span> height=<span style="color: #ff0000;">&quot;100%&quot;</span> title=<span style="color: #ff0000;">&quot;Lector de GeoRSS&quot;</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:VBox</span> id=<span style="color: #ff0000;">&quot;box&quot;</span>  height=<span style="color: #ff0000;">&quot;100%&quot;</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #7400FF;">&gt;</span></span>
				<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:HBox</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #7400FF;">&gt;</span></span>			
					<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:ComboBox</span> id=<span style="color: #ff0000;">&quot;sourcesCb&quot;</span>  textAlign=<span style="color: #ff0000;">&quot;left&quot;</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span>  </span>
<span style="color: #000000;">						labelFunction=<span style="color: #ff0000;">&quot;sourcesCbLabelFunction&quot;</span></span>
<span style="color: #000000;">						change=<span style="color: #ff0000;">&quot;getFuenteNombre(event)&quot;</span> rowCount=<span style="color: #ff0000;">&quot;10&quot;</span></span>
<span style="color: #000000;">						prompt=<span style="color: #ff0000;">&quot;Seleccione una opción...&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
				<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:HBox</span><span style="color: #7400FF;">&gt;</span></span>
				<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:DataGrid</span> id=<span style="color: #ff0000;">&quot;rssList&quot;</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> height=<span style="color: #ff0000;">&quot;100%&quot;</span>  change=<span style="color: #ff0000;">&quot;getPage(event)&quot;</span><span style="color: #7400FF;">&gt;</span></span>
					<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:columns</span><span style="color: #7400FF;">&gt;</span></span>
						<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:DataGridColumn</span> dataField=<span style="color: #ff0000;">&quot;title&quot;</span> headerText=<span style="color: #ff0000;">&quot;Titular&quot;</span> </span>
<span style="color: #000000;">							dataTipField=<span style="color: #ff0000;">&quot;description&quot;</span> showDataTips=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
					<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:columns</span><span style="color: #7400FF;">&gt;</span></span>		
				<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:DataGrid</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:VBox</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Panel</span><span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Panel</span>  width=<span style="color: #ff0000;">&quot;50%&quot;</span> height=<span style="color: #ff0000;">&quot;100%&quot;</span> title=<span style="color: #ff0000;">&quot;Detalle de la Noticia&quot;</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:VDividedBox</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> height=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #7400FF;">&gt;</span></span>
				<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:VBox</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> height=<span style="color: #ff0000;">&quot;30%&quot;</span><span style="color: #7400FF;">&gt;</span></span>
					<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:HBox</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #7400FF;">&gt;</span></span>
						<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Image</span> id=<span style="color: #ff0000;">&quot;imagen&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
						<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:LinkButton</span> id=<span style="color: #ff0000;">&quot;mas&quot;</span> visible=<span style="color: #ff0000;">&quot;false&quot;</span> label=<span style="color: #ff0000;">&quot;Ver mas...&quot;</span> click=<span style="color: #ff0000;">&quot;{getUrl()}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>	
					<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:HBox</span><span style="color: #7400FF;">&gt;</span></span>
					<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Text</span> id=<span style="color: #ff0000;">&quot;titulo&quot;</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> fontWeight=<span style="color: #ff0000;">&quot;bold&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
					<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Text</span> id=<span style="color: #ff0000;">&quot;contenido&quot;</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
				<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:VBox</span><span style="color: #7400FF;">&gt;</span></span>
				<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:VBox</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> height=<span style="color: #ff0000;">&quot;70%&quot;</span><span style="color: #7400FF;">&gt;</span></span>
					<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:UIComponent</span> id=<span style="color: #ff0000;">&quot;mapContainer&quot;</span> </span>
<span style="color: #000000;">			        initialize=<span style="color: #ff0000;">&quot;startMap(event);&quot;</span> </span>
<span style="color: #000000;">			        resize=<span style="color: #ff0000;">&quot;resizeMap(event)&quot;</span> </span>
<span style="color: #000000;">			        width=<span style="color: #ff0000;">&quot;100%&quot;</span> height=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
				<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:VBox</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:VDividedBox</span><span style="color: #7400FF;">&gt;</span></span>	
		<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Panel</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:HDividedBox</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></td></tr></table></div>

<p><strong>Código fuente del archivo ejemplo/HTMLToolTip.as:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> ejemplo
<span style="color: #000000;">&#123;</span>
<span style="color: #009900;">//Esta es la clase que maneja el tooltip para que muestre el contenido</span>
<span style="color: #009900;">//que esta en html y no como un string.</span>
     <span style="color: #0033ff; font-weight: bold;">import</span> mx.containers.<span style="color: #000000; font-weight: bold;">*</span>;  
     <span style="color: #0033ff; font-weight: bold;">import</span> mx.controls.Text;  
     <span style="color: #0033ff; font-weight: bold;">import</span> mx.controls.ToolTip;  
     <span style="color: #0033ff; font-weight: bold;">import</span> mx.core.<span style="color: #000000; font-weight: bold;">*</span>;  
&nbsp;
     <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> HTMLToolTip extends ToolTip  
     <span style="color: #000000;">&#123;</span>  
         <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> HTMLToolTip<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>  
         <span style="color: #000000;">&#123;</span>    <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>; <span style="color: #000000;">&#125;</span>  
&nbsp;
         override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> commitProperties<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>  
             <span style="color: #0033ff; font-weight: bold;">super</span>.commitProperties<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;  
             textField.<span style="color: #004993;">htmlText</span> = <span style="color: #004993;">text</span>;  
         <span style="color: #000000;">&#125;</span>  
     <span style="color: #000000;">&#125;</span> 
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p><strong>Archivo sources.xml:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xml<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;lista<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;nombre<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>El Tiempo - Mundo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/nombre<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://www.eltiempo.com/mundo/rss.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pais<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Colombia<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pais<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;nombre<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>El Tiempo - Colombia<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/nombre<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://www.eltiempo.com/colombia/rss.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pais<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Colombia<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pais<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;nombre<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>El Espectador<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/nombre<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://www.elespectador.com/rss.xml <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pais<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Colombia<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pais<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;nombre<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>El Pais - America Latina<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/nombre<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://www.elpais.com/rss/feed.html?feedId=17041<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pais<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>España<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pais<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;nombre<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>ABC - Portada<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/nombre<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://www.abc.es/rss/feeds/abcPortada.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pais<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>España<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pais<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;nombre<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>BBC Mundo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/nombre<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://www.bbc.co.uk/mundo/index.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pais<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Inglaterra<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pais<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;nombre<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>CNN - World<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/nombre<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://rss.cnn.com/rss/edition_world.rss<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pais<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Estados Unidos<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pais<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;nombre<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Reuters - World News<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/nombre<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://feeds.reuters.com/reuters/worldNews<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pais<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Estados Unidos<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pais<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;nombre<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>BusinessWeek.com<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/nombre<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://rss.businessweek.com/bw_rss/bwdaily<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pais<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Estados Unidos<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pais<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;nombre<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Google News<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/nombre<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://news.google.com/news?output=rss<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pais<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Alemania<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pais<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/lista<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xml<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.gkudos.com/2009/09/06/creando-un-lector-de-georss-con-adobe-flex-3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Groovy: Ejemplos Básicos de Programación</title>
		<link>http://blog.gkudos.com/2009/07/01/groovy-ejemplos-basicos-de-programacion/</link>
		<comments>http://blog.gkudos.com/2009/07/01/groovy-ejemplos-basicos-de-programacion/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 16:52:57 +0000</pubDate>
		<dc:creator>juanmendez</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Groovy]]></category>

		<guid isPermaLink="false">http://blog.gkudos.com/?p=154</guid>
		<description><![CDATA[
En el siguiente archivo Groovy Examples pueden encontrarse algunos ejemplos básicos de programación utilizando el lenguaje Groovy.
Entre otros pueden encontrarse los siguientes ejemplos:

 En el archivo _1_Hello hay una introduccion a la definicion de variables, rangos, listas y mapas y a la definicion de closures
En el archivo _2_Estructuras_Logicas hay una descripcion de la forma en [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter" title="Groovy" src="http://media.xircles.codehaus.org/_projects/groovy/_logos/medium.png" alt="" width="203" height="100" /></p>
<p>En el siguiente archivo <a href="http://static.gkudos.com/blog/Groovy_Examples.rar">Groovy Examples</a> pueden encontrarse algunos ejemplos básicos de programación utilizando el lenguaje Groovy.<br />
Entre otros pueden encontrarse los siguientes ejemplos:</p>
<ul>
<li> En el archivo _1_Hello hay una introduccion a la definicion de variables, rangos, listas y mapas y a la definicion de closures</li>
<li>En el archivo _2_Estructuras_Logicas hay una descripcion de la forma en que trabajan las estructuras de control basicas y los loops particulares de groovy</li>
<li>En el archivo _3_Metodos hay una explicacion del llamado a métodos y las sentencias try_catch_finally</li>
</ul>
<p><a href="http://static.gkudos.com/blog/Groovy_Examples.rar">Descargar Archivo Groovy Examples</a></p>
<p>Ejemplo de Loops con Groovy:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #993333;">void</span> loops<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">//la variable it es el iterador</span>
&nbsp;
<span style="color: #808080; font-style: italic;">//al igual que todas los loop y closures, las sentencias del bucle se declaran entre corchetes</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// inicia en 0</span>
&nbsp;
		5.<span style="color: #993399;">times</span> <span style="color: #66cc66;">&#123;</span><span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Times + $it &quot;</span><span style="color: #66cc66;">&#125;</span>
&nbsp;
		1.<span style="color: #993399;">upto</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Up + $it &quot;</span><span style="color: #66cc66;">&#125;</span>
&nbsp;
		4.<span style="color: #006600;">downto</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Down + $it &quot;</span><span style="color: #66cc66;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
		<span style="color: #000000; font-weight: bold;">def</span> sum <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">0</span>
&nbsp;
		1.<span style="color: #993399;">upto</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>sum <span style="color: #66cc66;">+=</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #993399;">println</span> sum
&nbsp;
&nbsp;
&nbsp;
		<span style="color: #66cc66;">&#40;</span>1..6<span style="color: #66cc66;">&#41;</span>.<span style="color: #663399;">each</span> <span style="color: #66cc66;">&#123;</span><span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Range $it&quot;</span><span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.gkudos.com/2009/07/01/groovy-ejemplos-basicos-de-programacion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>gr8conf: Conferencia dedicada a Groovy, Grails y Griffon</title>
		<link>http://blog.gkudos.com/2009/06/25/gr8conf-conferencia-dedicada-a-groovy-grails-y-griffon/</link>
		<comments>http://blog.gkudos.com/2009/06/25/gr8conf-conferencia-dedicada-a-groovy-grails-y-griffon/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 05:00:19 +0000</pubDate>
		<dc:creator>juanmendez</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[Groovy]]></category>

		<guid isPermaLink="false">http://blog.gkudos.com/?p=146</guid>
		<description><![CDATA[
En días pasados se realizó la conferencia gr8conf  dedicada por completo a los temas de Groovy, Grails y Griffon.
Griffon es un nuevo framework destinado al desarrollo de interfaces gráficas:
Although several options exist for interface development in Java, even popular UI toolkits like Swing have been notoriously complex and difficult to use. Griffon, an agile [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter" title="http://www.gr8conf.org/images/gr8-full-banner.png" src="http://www.gr8conf.org/images/gr8-full-banner.png" alt="" width="397" height="66" /><br />
En días pasados se realizó la conferencia <a href="http://www.gr8conf.org/">gr8conf </a> dedicada por completo a los temas de Groovy, Grails y Griffon.<br />
<a href="http://www.manning.com/almiray/">Griffon </a>es un nuevo framework destinado al desarrollo de interfaces gráficas:</p>
<blockquote><p>Although several options exist for interface development in Java, even popular UI toolkits like Swing have been notoriously complex and difficult to use. Griffon, an agile framework that uses Groovy to simplify Swing, makes UI development dramatically faster and easier. In many respects, Griffon is for desktop development what Grails is for web development. While it&#8217;s based on Swing, its declarative style and approachable level of abstraction is instantly familiar to developers familiar with other technologies such as Flex or JavaFX.</p></blockquote>
<p>A continuación algunas de las presentaciones disponibles en Slideshare:</p>
<ul>
<li> <a href="http://www.slideshare.net/gr8conf/gr8conf-opening-keynote">Opening Keynote by Søren Berg Glasius and Guillaume Laforge </a></li>
<li><a href="http://www.slideshare.net/gr8conf/gr8conf-practical-groovy-dsl">Practical Groovy DSL by Guillaume Laforge</a></li>
<li><a href="http://www.slideshare.net/gr8conf/gr8conf-whats-new-in-groovy-16">What&#8217;s New in Groovy 1.6? by Guillaume Laforge</a></li>
<li><a href="http://www.slideshare.net/gr8conf/industrial-strength-groovy-by-paul-king">Industrial Strength Groovy by Paul King</a></li>
<li><a href="http://www.slideshare.net/gr8conf/groovy-in-fiance-case-study-by-jonathan-felch">Groovy Finance: Grid Computing and Computational Finance</a></li>
<li><a href="http://www.slideshare.net/gr8conf/the-grails-plugin-system-by-graeme-rocher">The Grails Plugin System by Graeme Rocher </a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.gkudos.com/2009/06/25/gr8conf-conferencia-dedicada-a-groovy-grails-y-griffon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recopilación de Enlaces con Documentación sobre Groovy y Grails</title>
		<link>http://blog.gkudos.com/2009/06/04/recopilacion-de-enlaces-con-documentacion-sobre-groovy-y-grails/</link>
		<comments>http://blog.gkudos.com/2009/06/04/recopilacion-de-enlaces-con-documentacion-sobre-groovy-y-grails/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 17:20:38 +0000</pubDate>
		<dc:creator>juanmendez</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[Groovy]]></category>

		<guid isPermaLink="false">http://blog.gkudos.com/?p=144</guid>
		<description><![CDATA[Documentación sobre Groovy y Grails

Getting Started Guide
User Guide
Advanced usage guide
Groovy and Grails talk: http://www.slideshare.net/desistartups/groovy-and-grails-talk
Curso de Groovy: http://www.dosideas.com/cursos/course/view.php?id=9
Introducción a Groovy: http://www.asert.com/pubs/Groovy/Groovy.pdf
Creating “Hello World” Web Application Using the Grails Framework
Grails : Hello world
Getting Started with Grails :
GRAILS QUICK REFERENCE
http://www.slideshare.net/loffenauer/2007-09-10-fzi-training-groovy-grails-v-ws
http://www.slideshare.net/desistartups/groovy-and-grails-talk
http://www.slideshare.net/mjhugo/groovy-grails-devjam-jam-session-presentation

]]></description>
			<content:encoded><![CDATA[<h2>Documentación sobre Groovy y Grails</h2>
<ul>
<li><a href="http://groovy.codehaus.org/Getting+Started+Guide">Getting Started Guide</a></li>
<li><a href="http://groovy.codehaus.org/User+Guide">User Guide</a></li>
<li><a href="http://groovy.codehaus.org/Advanced+Usage+Guide">Advanced usage guide</a></li>
<li><a href="http://www.slideshare.net/desistartups/groovy-and-grails-talk">Groovy and Grails talk: http://www.slideshare.net/desistartups/groovy-and-grails-talk</a></li>
<li><a href="http://www.dosideas.com/cursos/course/view.php?id=9">Curso de Groovy: http://www.dosideas.com/cursos/course/view.php?id=9</a></li>
<li><a href="http://www.asert.com/pubs/Groovy/Groovy.pdf">Introducción a Groovy: http://www.asert.com/pubs/Groovy/Groovy.pdf</a></li>
<li><a href="http://beans.seartipy.com/2008/06/15/creating-hello-world-web-application-using-the-grails-framework/">Creating “Hello World” Web Application Using the Grails Framework</a></li>
<li><a href="http://www.noppanit.com/?p=114">Grails : Hello world</a></li>
<li><a href="http://docs.codehaus.org/display/GFS/GFS+Example+for+Grails+1.1">Getting Started with Grails :</a></li>
<li><a href="http://docs.codehaus.org/download/attachments/40788/grailsqr-1.1.0.pdf">GRAILS QUICK REFERENCE</a></li>
<li><a href="http://www.slideshare.net/loffenauer/2007-09-10-fzi-training-groovy-grails-v-ws">http://www.slideshare.net/loffenauer/2007-09-10-fzi-training-groovy-grails-v-ws</a></li>
<li><a href="http://www.slideshare.net/desistartups/groovy-and-grails-talk">http://www.slideshare.net/desistartups/groovy-and-grails-talk</a></li>
<li><a href="http://www.slideshare.net/mjhugo/groovy-grails-devjam-jam-session-presentation">http://www.slideshare.net/mjhugo/groovy-grails-devjam-jam-session-presentation</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.gkudos.com/2009/06/04/recopilacion-de-enlaces-con-documentacion-sobre-groovy-y-grails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducción al Desarrollo de Aplicaciones con Groovy y Grails (Parte 6)</title>
		<link>http://blog.gkudos.com/2009/06/03/introduccion-al-desarrollo-de-aplicaciones-con-groovy-y-grails-parte-6/</link>
		<comments>http://blog.gkudos.com/2009/06/03/introduccion-al-desarrollo-de-aplicaciones-con-groovy-y-grails-parte-6/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 16:51:06 +0000</pubDate>
		<dc:creator>juanmendez</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.gkudos.com/?p=140</guid>
		<description><![CDATA[Generación de RSS con Grails
En esta sección del tutorial utilizaremos un plugin para la generación de RSS utilizando grails.  (Puede encontrar una lista de los plugins existentes en la siguiente ubicación: http://grails.org/plugin/home
El plugin que utilizaremos para la generación de rss se llama Feeds.  Para instalarlo ejecutamos el siguiente comando (tenga en cuenta estar ubicado en [...]]]></description>
			<content:encoded><![CDATA[<h2>Generación de RSS con Grails</h2>
<p>En esta sección del tutorial utilizaremos un plugin para la generación de RSS utilizando grails.  (Puede encontrar una lista de los plugins existentes en la siguiente ubicación: <a href="http://grails.org/plugin/home">http://grails.org/plugin/home</a></p>
<p>El plugin que utilizaremos para la generación de rss se llama <a href="http://grails.org/plugin/feeds">Feeds</a>.  Para instalarlo ejecutamos el siguiente comando (tenga en cuenta estar ubicado en la carpeta de su proyecto)</p>
<p style="padding-left: 30px;"><span style="color: #0000ff;">&gt; F:\dev\issuetracker&gt;grails install-plugin feeds</span></p>
<p>Cuando aparezca en la consola el mensaje &#8220;<strong>Plugin feeds-1.4 installed</strong>&#8221; podemos seguir al siguiente paso del tutorial.</p>
<p>Vamos a crear un feed rss con los issues creados en el sistema. Primero procedemos a ubicar el archivo <strong>/issuetracker/grails-app/controllers/IssueController.groovy</strong> y adicionamos el siguiente método:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">def</span> feed <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
        render<span style="color: #66cc66;">&#40;</span>feedType:<span style="color: #ff0000;">&quot;rss&quot;</span>, feedVersion:<span style="color: #ff0000;">&quot;2.0&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            title <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;Mi feed de prueba &quot;</span>
            link <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;http://localhost:8080/issuetracker/issue/feed&quot;</span>
            description <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;Issues Grails news feed&quot;</span>
&nbsp;
            Issue.<span style="color: #006600;">list</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #663399;">each</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> 
            	issue <span style="color: #66cc66;">-&gt;</span> entry<span style="color: #66cc66;">&#40;</span>issue.<span style="color: #006600;">submitter</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> 
            		link <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;http://your.test.server/article/${issue.id}&quot;</span> 
            		issue.<span style="color: #006600;">description</span> <span style="color: #808080; font-style: italic;">// return the content </span>
            	<span style="color: #66cc66;">&#125;</span> 
            <span style="color: #66cc66;">&#125;</span> 
        <span style="color: #66cc66;">&#125;</span> 
    <span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Si digitamos la dirección <strong>http://localhost:8080/issuetracker/issue/feed</strong> podremos ver generado el siguiente feed:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rss</span> <span style="color: #000066;">xmlns:content</span>=<span style="color: #ff0000;">&quot;http://purl.org/rss/1.0/modules/content/&quot;</span> <span style="color: #000066;">xmlns:rdf</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot;</span> <span style="color: #000066;">xmlns:itunes</span>=<span style="color: #ff0000;">&quot;http://www.itunes.com/dtds/podcast-1.0.dtd&quot;</span> <span style="color: #000066;">xmlns:dc</span>=<span style="color: #ff0000;">&quot;http://purl.org/dc/elements/1.1/&quot;</span> <span style="color: #000066;">xmlns:taxo</span>=<span style="color: #ff0000;">&quot;http://purl.org/rss/1.0/modules/taxonomy/&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;2.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;channel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Mi feed de prueba<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://localhost:8080/issuetracker/issue/feed<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/link<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Issues Grails news feed<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>User 1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://your.test.server/article/5<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/link<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;content:encoded<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>My report from error<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/content:encoded<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;guid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://your.test.server/article/5<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/guid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>User 2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://your.test.server/article/6<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/link<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;content:encoded<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>This component does not work in firefox<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/content:encoded<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;guid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://your.test.server/article/6<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/guid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/channel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rss<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Si queremos incluir el enlace para la visualización del RSS en nuestra página de listado de Issues podemos adicionar el siguiente código al archivo <strong>/issuetracker/grails-app/views/issue/list.gsp</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">   &lt;div &gt;
	&lt;a href=&quot;${createLinkTo(dir:'issue/feed', file:'')}&quot;&gt;View RSS&lt;/a&gt;
   &lt;/div&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.gkudos.com/2009/06/03/introduccion-al-desarrollo-de-aplicaciones-con-groovy-y-grails-parte-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducción al Desarrollo de Aplicaciones con Groovy y Grails (Parte 5)</title>
		<link>http://blog.gkudos.com/2009/06/03/introduccion-al-desarrollo-de-aplicaciones-con-groovy-y-grails-parte-4-2/</link>
		<comments>http://blog.gkudos.com/2009/06/03/introduccion-al-desarrollo-de-aplicaciones-con-groovy-y-grails-parte-4-2/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 16:20:51 +0000</pubDate>
		<dc:creator>juanmendez</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.gkudos.com/?p=131</guid>
		<description><![CDATA[Modificación de las Vistas Generadas por Grails
En muchas ocasiones no es suficiente la funcionalidad que genera automáticamente el marco de trabajo Grails.  En la presente sección realizaremos algunas modificaciones a las pantallas generadas por la herramienta.
Vamos a la carpeta &#8216;grails-app/views&#8216;, notese que hay una carpeta por cada tabla creada, en estas carpetas estará en código [...]]]></description>
			<content:encoded><![CDATA[<h2>Modificación de las Vistas Generadas por Grails</h2>
<p>En muchas ocasiones no es suficiente la funcionalidad que genera automáticamente el marco de trabajo Grails.  En la presente sección realizaremos algunas modificaciones a las pantallas generadas por la herramienta.</p>
<p>Vamos a la carpeta &#8216;<strong>grails-app/views</strong>&#8216;, notese que hay una carpeta por cada tabla creada, en estas carpetas estará en código seudo-HTML para cada una de nuestras vistas en la aplicación.</p>
<p>El siguiente paso es modificar algunas de las vistas para ver su funcionamiento, para nuestro ejemplo vamos a modificar la vista que muestra la lista de<strong> “issues”</strong>, abrimos el archivo &#8216;<strong>grails-app/views/issue/list.gsp</strong>&#8216;, pero, primero vamos a crear un nuevo tag dinamico para nuestra aplicación (ud puede ver mas de los tags en <a href="http://grails.org/Dynamic+Tag+Libraries">http://grails.org/Dynamic+Tag+Libraries</a>).</p>
<p>Teniendo como base la carpeta de nuestro proyecto ejecutamos el comando:</p>
<p style="padding-left: 30px;"><span style="color: #0000ff;"> </span><span style="color: #0000ff;">&gt; grails create-tag-lib Misc</span></p>
<p>Una vez ejecutado este comando se creara el archivo &#8216;<strong>grails-app/taglib/MiscTagLib.groovy</strong> &#8216; y a este le vamos a añadir las siguientes líneas de código:</p>
<p><img class="aligncenter" title="http://static.gkudos.com/blog/grails_taglibs/Imagen1.jpg" src="http://static.gkudos.com/blog/grails_taglibs/Imagen1.jpg" alt="" width="563" height="168" /></p>
<p>Descargamos la siguiente imagen: <a href="http://openclipart.org/people/hrum/hrum_cocktail.png">http://openclipart.org/people/hrum/hrum_cocktail.png</a> y la copiamos en la carpeta <strong>issuetracker\web-app\images</strong> (es recomendable reducir el tamaño de la imagen para una mejor visualización).</p>
<p>Ahora modificamos   el archivo &#8216;<strong>grails-app/views/issue/list.gsp</strong> &#8216; de la siguiente forma: (Nótense las líneas 27, y 39 a la 43.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>html<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>head<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>meta http<span style="color: #66cc66;">-</span>equiv<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Content-Type&quot;</span> content<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html; charset=UTF-8&quot;</span>/<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>meta name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;layout&quot;</span> content<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;main&quot;</span> /<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>title<span style="color: #66cc66;">&gt;</span>Issue List<span style="color: #66cc66;">&lt;</span>/title<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>/head<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>body<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nav&quot;</span><span style="color: #66cc66;">&gt;</span>
            <span style="color: #66cc66;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;menuButton&quot;</span><span style="color: #66cc66;">&gt;&lt;</span>a <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;home&quot;</span> href<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${resource(dir:'')}&quot;</span><span style="color: #66cc66;">&gt;</span>Home<span style="color: #66cc66;">&lt;</span>/a<span style="color: #66cc66;">&gt;&lt;</span>/span<span style="color: #66cc66;">&gt;</span>
            <span style="color: #66cc66;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;menuButton&quot;</span><span style="color: #66cc66;">&gt;&lt;</span>g:link <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;create&quot;</span> action<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;create&quot;</span><span style="color: #66cc66;">&gt;</span>New Issue<span style="color: #66cc66;">&lt;</span>/g:link<span style="color: #66cc66;">&gt;&lt;</span>/span<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>/div<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;body&quot;</span><span style="color: #66cc66;">&gt;</span>
            <span style="color: #66cc66;">&lt;</span>h1<span style="color: #66cc66;">&gt;</span>Issue List<span style="color: #66cc66;">&lt;</span>/h1<span style="color: #66cc66;">&gt;</span>
            <span style="color: #66cc66;">&lt;</span>g:<span style="color: #b1b100;">if</span> test<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${flash.message}&quot;</span><span style="color: #66cc66;">&gt;</span>
            <span style="color: #66cc66;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;message&quot;</span><span style="color: #66cc66;">&gt;</span>$<span style="color: #66cc66;">&#123;</span>flash.<span style="color: #006600;">message</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&lt;</span>/div<span style="color: #66cc66;">&gt;</span>
            <span style="color: #66cc66;">&lt;</span>/g:if<span style="color: #66cc66;">&gt;</span>
            <span style="color: #66cc66;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;list&quot;</span><span style="color: #66cc66;">&gt;</span>
                <span style="color: #66cc66;">&lt;</span>table<span style="color: #66cc66;">&gt;</span>
                    <span style="color: #66cc66;">&lt;</span>thead<span style="color: #66cc66;">&gt;</span>
                        <span style="color: #66cc66;">&lt;</span>tr<span style="color: #66cc66;">&gt;</span>
                   	        <span style="color: #66cc66;">&lt;</span>g:sortableColumn <span style="color: #000000; font-weight: bold;">property</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;id&quot;</span> title<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Id&quot;</span> /<span style="color: #66cc66;">&gt;</span>
                   	        <span style="color: #66cc66;">&lt;</span>th<span style="color: #66cc66;">&gt;</span>Component<span style="color: #66cc66;">&lt;</span>/th<span style="color: #66cc66;">&gt;</span>
                   	        <span style="color: #66cc66;">&lt;</span>g:sortableColumn <span style="color: #000000; font-weight: bold;">property</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;type&quot;</span> title<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Type&quot;</span> /<span style="color: #66cc66;">&gt;</span>
                   	        <span style="color: #66cc66;">&lt;</span>g:sortableColumn <span style="color: #000000; font-weight: bold;">property</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submitter&quot;</span> title<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Submitter&quot;</span> /<span style="color: #66cc66;">&gt;</span>
                   	        <span style="color: #66cc66;">&lt;</span>g:sortableColumn <span style="color: #000000; font-weight: bold;">property</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;description&quot;</span> title<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Description&quot;</span> /<span style="color: #66cc66;">&gt;</span>
                   	        <span style="color: #66cc66;">&lt;</span>g:sortableColumn <span style="color: #000000; font-weight: bold;">property</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;status&quot;</span> title<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Status&quot;</span> /<span style="color: #66cc66;">&gt;</span>
                   	        <span style="color: #66cc66;">&lt;</span>g:sortableColumn <span style="color: #000000; font-weight: bold;">property</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;bounty&quot;</span> title<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Bounty&quot;</span> /<span style="color: #66cc66;">&gt;</span>
                        <span style="color: #66cc66;">&lt;</span>/tr<span style="color: #66cc66;">&gt;</span>
                    <span style="color: #66cc66;">&lt;</span>/thead<span style="color: #66cc66;">&gt;</span>
                    <span style="color: #66cc66;">&lt;</span>tbody<span style="color: #66cc66;">&gt;</span>
                    <span style="color: #66cc66;">&lt;</span>g:<span style="color: #663399;">each</span> <span style="color: #b1b100;">in</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${issueInstanceList}&quot;</span> status<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;i&quot;</span> var<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;issueInstance&quot;</span><span style="color: #66cc66;">&gt;</span>
                        <span style="color: #66cc66;">&lt;</span>tr <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${(i % 2) == 0 ? 'odd' : 'even'}&quot;</span><span style="color: #66cc66;">&gt;</span>
                            <span style="color: #66cc66;">&lt;</span>td<span style="color: #66cc66;">&gt;&lt;</span>g:link action<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;show&quot;</span> id<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${issueInstance.id}&quot;</span><span style="color: #66cc66;">&gt;</span>$<span style="color: #66cc66;">&#123;</span>fieldValue<span style="color: #66cc66;">&#40;</span>bean:issueInstance, field:<span style="color: #ff0000;">'id'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&lt;</span>/g:link<span style="color: #66cc66;">&gt;&lt;</span>/td<span style="color: #66cc66;">&gt;</span>
                            <span style="color: #66cc66;">&lt;</span>td<span style="color: #66cc66;">&gt;</span>$<span style="color: #66cc66;">&#123;</span>fieldValue<span style="color: #66cc66;">&#40;</span>bean:issueInstance, field:<span style="color: #ff0000;">'component'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&lt;</span>/td<span style="color: #66cc66;">&gt;</span>
                            <span style="color: #66cc66;">&lt;</span>td<span style="color: #66cc66;">&gt;</span>$<span style="color: #66cc66;">&#123;</span>fieldValue<span style="color: #66cc66;">&#40;</span>bean:issueInstance, field:<span style="color: #ff0000;">'type'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&lt;</span>/td<span style="color: #66cc66;">&gt;</span>
                            <span style="color: #66cc66;">&lt;</span>td<span style="color: #66cc66;">&gt;</span>$<span style="color: #66cc66;">&#123;</span>fieldValue<span style="color: #66cc66;">&#40;</span>bean:issueInstance, field:<span style="color: #ff0000;">'submitter'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&lt;</span>/td<span style="color: #66cc66;">&gt;</span>
                            <span style="color: #66cc66;">&lt;</span>td<span style="color: #66cc66;">&gt;</span>$<span style="color: #66cc66;">&#123;</span>fieldValue<span style="color: #66cc66;">&#40;</span>bean:issueInstance, field:<span style="color: #ff0000;">'description'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&lt;</span>/td<span style="color: #66cc66;">&gt;</span>
                            <span style="color: #66cc66;">&lt;</span>td<span style="color: #66cc66;">&gt;</span>$<span style="color: #66cc66;">&#123;</span>fieldValue<span style="color: #66cc66;">&#40;</span>bean:issueInstance, field:<span style="color: #ff0000;">'status'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&lt;</span>/td<span style="color: #66cc66;">&gt;</span>
                            <span style="color: #66cc66;">&lt;</span>td<span style="color: #66cc66;">&gt;</span>
                            	<span style="color: #66cc66;">&lt;</span>g:repeat <span style="color: #993399;">times</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${issueInstance.bounty}&quot;</span><span style="color: #66cc66;">&gt;</span>  
   									<span style="color: #66cc66;">&lt;</span>img src<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${createLinkTo(dir:'images', file:'hrum_cocktail.png')}&quot;</span> alt<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${issueInstance.bounty} beers&quot;</span>/<span style="color: #66cc66;">&gt;</span>  
   								<span style="color: #66cc66;">&lt;</span>/g:repeat<span style="color: #66cc66;">&gt;</span>  
                            <span style="color: #66cc66;">&lt;</span>/td<span style="color: #66cc66;">&gt;</span>
                        <span style="color: #66cc66;">&lt;</span>/tr<span style="color: #66cc66;">&gt;</span>
                    <span style="color: #66cc66;">&lt;</span>/g:each<span style="color: #66cc66;">&gt;</span>
                    <span style="color: #66cc66;">&lt;</span>/tbody<span style="color: #66cc66;">&gt;</span>
                <span style="color: #66cc66;">&lt;</span>/table<span style="color: #66cc66;">&gt;</span>
            <span style="color: #66cc66;">&lt;</span>/div<span style="color: #66cc66;">&gt;</span>
            <span style="color: #66cc66;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;paginateButtons&quot;</span><span style="color: #66cc66;">&gt;</span>
                <span style="color: #66cc66;">&lt;</span>g:paginate total<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${issueInstanceTotal}&quot;</span> /<span style="color: #66cc66;">&gt;</span>
            <span style="color: #66cc66;">&lt;</span>/div<span style="color: #66cc66;">&gt;</span>
        <span style="color: #66cc66;">&lt;</span>/div<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;</span>/body<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>/html<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>Ahora nuestro listado de Issues se verá de la siguiente forma:</p>
<p><img class="aligncenter" title="http://static.gkudos.com/blog/grails_taglibs/img_list_modified.jpg" src="http://static.gkudos.com/blog/grails_taglibs/img_list_modified.jpg" alt="" width="704" height="300" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gkudos.com/2009/06/03/introduccion-al-desarrollo-de-aplicaciones-con-groovy-y-grails-parte-4-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Introducción al Desarrollo de Aplicaciones con Groovy y Grails (Parte 4)</title>
		<link>http://blog.gkudos.com/2009/06/02/introduccion-al-desarrollo-de-aplicaciones-con-groovy-y-grails-parte-4/</link>
		<comments>http://blog.gkudos.com/2009/06/02/introduccion-al-desarrollo-de-aplicaciones-con-groovy-y-grails-parte-4/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 22:49:08 +0000</pubDate>
		<dc:creator>juanmendez</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.gkudos.com/?p=120</guid>
		<description><![CDATA[Pruebas Unitarias de Proyectos Grails
Grails soporta los conceptos de &#8220;Pruebas Unitarias&#8221; y &#8220;Pruebas de Integración&#8220;.
Las &#8220;pruebas unitarias&#8221; se orientan a pruebas pequeñas de ejecución rápida que no soportan carga de Componentes.  Las &#8220;pruebas de integración&#8221; se encargan de evalular el ambiente en el que se ejecuta el aplicativo.

Para nuestro ejemplo vamos a modificar el archivo [...]]]></description>
			<content:encoded><![CDATA[<h2>Pruebas Unitarias de Proyectos Grails</h2>
<p>Grails soporta los conceptos de &#8220;<strong>Pruebas Unitarias</strong>&#8221; y &#8220;<strong>Pruebas de Integración</strong>&#8220;.<br />
Las &#8220;<strong>pruebas unitarias</strong>&#8221; se orientan a pruebas pequeñas de ejecución rápida que no soportan carga de Componentes.  Las &#8220;<strong>pruebas de integración</strong>&#8221; se encargan de evalular el ambiente en el que se ejecuta el aplicativo.</p>
<p><span id="more-120"></span></p>
<p>Para nuestro ejemplo vamos a modificar el archivo &#8220;<strong>ProjectTests.groovy</strong>&#8220;  (Este archivo se encuentra dentro de la carpeta   &#8220;<strong>\issuetracker\test\unit\</strong>&#8221; .  Grails crea automáticamente Archivos de pruebas para las entidades del dominio creadas previamente) :</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">grails.test.*</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> ProjectTests <span style="color: #000000; font-weight: bold;">extends</span> GrailsUnitTestCase <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">void</span> setUp<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006600;">setUp</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">void</span> tearDown<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006600;">tearDown</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">//Test sin errores</span>
    <span style="color: #993333;">void</span> testSomething<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    	Project hs <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Project<span style="color: #66cc66;">&#40;</span>name:<span style="color: #ff0000;">&quot;hello world&quot;</span><span style="color: #66cc66;">&#41;</span>
        assertEquals <span style="color: #ff0000;">&quot;hello world&quot;</span>, hs.<span style="color: #006600;">name</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">//Test con errores</span>
    <span style="color: #993333;">void</span> testSomethingFails<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    	Project hs <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Project<span style="color: #66cc66;">&#40;</span>name:<span style="color: #ff0000;">&quot;hello world&quot;</span><span style="color: #66cc66;">&#41;</span>
        assertEquals <span style="color: #ff0000;">&quot;hello world failed&quot;</span>, hs.<span style="color: #006600;">name</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>En este ejemplo vemos dos pruebas <strong>testsomething</strong> y <strong>testsomethingfails</strong>.</p>
<p>Para ejecutar el conjunto de pruebas unitarias del proyecto ejecutamos el comando:</p>
<p style="padding-left: 30px;"><span style="color: #0000ff;">&gt;&gt; F:\dev\issuetracker&gt;grails test-app</span></p>
<p>Para nuestro ejemplo la consola debería mostrar un mensaje similar al siguiente:</p>
<pre style="padding-left: 30px;">Starting unit tests ...
Running tests of type 'unit'
-------------------------------------------------------
Running 4 unit tests...
Running test ComponentTests...PASSED
Running test IssueTests...PASSED
Running test ProjectTests...
                    testSomethingFails...FAILED
Tests Completed in 312ms ...
-------------------------------------------------------
Tests passed: 3
Tests failed: 1
-------------------------------------------------------</pre>
<p>Adicionalmente grails genera un reporte en la siguiente ruta: <strong>F:\dev\issuetracker\test\reports\html\index.html</strong>. A continuación un pantallazo del reporte:</p>
<p><img class="aligncenter" title="http://static.gkudos.com/blog/eclipse_grails/test.jpg" src="http://static.gkudos.com/blog/eclipse_grails/test.jpg" alt="" width="742" height="515" /></p>
<h2>Pruebas Funcionales de Proyectos Grails</h2>
<p>Además de pruebas unitarias , Grails también soporta pruebas funcionales utilizando <a class="pageLink" href="http://webtest.canoo.com/">Canoo WebTest</a>. (Canoo WebTest es una herramienta de software libre destinada para la automatización de pruebas de aplicaciones web.)</p>
<p>Para instalar el plugin de pruebas funcionales ejecutamos el siguiente comando:</p>
<p style="padding-left: 30px;"><span style="color: #0000ff;">F:\dev\issuetracker&gt;grails install-plugin webtest</span></p>
<p>(<strong>Nota:</strong> Durante la instalación del plugin el instalador pedirá también la instalación de WebTest)</p>
<p>Para crear una prueba funcional de nuestra clase de dominio Project, ejecutamos el siguiente comando:</p>
<p style="padding-left: 30px;"><span style="color: #0000ff;">F:\dev\issuetracker&gt;grails create-webtest Project</span></p>
<p>Grails creará el siguiente archivo: &#8220;<strong>/issuetracker/webtest/tests/ProjectTest.groovy</strong>&#8220;  con el siguiente contenido:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> ProjectTest <span style="color: #000000; font-weight: bold;">extends</span> grails.<span style="color: #006600;">util</span>.<span style="color: #006600;">WebTest</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">// Unlike unit tests, functional tests are sometimes sequence dependent.</span>
    <span style="color: #808080; font-style: italic;">// Methods starting with 'test' will be run automatically in alphabetical order.</span>
	<span style="color: #808080; font-style: italic;">// If you require a specific sequence, prefix the method name (following 'test') with a sequence</span>
	<span style="color: #808080; font-style: italic;">// e.g. test001ProjectListNewDelete</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">def</span> testProjectListNewDelete<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            invoke      <span style="color: #ff0000;">'project'</span>
            verifyText  <span style="color: #ff0000;">'Home'</span>
&nbsp;
            verifyListSize <span style="color: #cc66cc;">0</span>
&nbsp;
            clickLink   <span style="color: #ff0000;">'New Project'</span>
            verifyText  <span style="color: #ff0000;">'Create Project'</span>
            clickButton <span style="color: #ff0000;">'Create'</span>
            verifyText  <span style="color: #ff0000;">'Show Project'</span>, description:<span style="color: #ff0000;">'Detail page'</span>
            clickLink   <span style="color: #ff0000;">'List'</span>, description:<span style="color: #ff0000;">'Back to list view'</span>
&nbsp;
            verifyListSize <span style="color: #cc66cc;">1</span>
&nbsp;
            group<span style="color: #66cc66;">&#40;</span>description:<span style="color: #ff0000;">'edit the one element'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                showFirstElementDetails<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
                clickButton <span style="color: #ff0000;">'Edit'</span>
                verifyText  <span style="color: #ff0000;">'Edit Project'</span>
                clickButton <span style="color: #ff0000;">'Update'</span>
                verifyText  <span style="color: #ff0000;">'Show Project'</span>
                clickLink   <span style="color: #ff0000;">'List'</span>, description:<span style="color: #ff0000;">'Back to list view'</span>
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            verifyListSize <span style="color: #cc66cc;">1</span>
&nbsp;
            group<span style="color: #66cc66;">&#40;</span>description:<span style="color: #ff0000;">'delete the only element'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                showFirstElementDetails<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
                clickButton <span style="color: #ff0000;">'Delete'</span>
                verifyXPath xpath:  <span style="color: #ff0000;">&quot;//div[@class='message']&quot;</span>,
                            text:   /.<span style="color: #66cc66;">*</span>Project.<span style="color: #66cc66;">*</span>deleted.<span style="color: #66cc66;">*</span>/,
                            regex:  <span style="color: #000000; font-weight: bold;">true</span>
            <span style="color: #66cc66;">&#125;</span>
&nbsp;
            verifyListSize <span style="color: #cc66cc;">0</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #aaaadd; font-weight: bold;">String</span> ROW_COUNT_XPATH <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;count(//div[@class='list']//tbody/tr)&quot;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">def</span> verifyListSize<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> <span style="color: #663399;">size</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        ant.<span style="color: #006600;">group</span><span style="color: #66cc66;">&#40;</span>description:<span style="color: #ff0000;">&quot;verify Project list view with $size row(s)&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            verifyText  <span style="color: #ff0000;">'Project List'</span>
            verifyXPath xpath:      ROW_COUNT_XPATH,
                        text:       <span style="color: #663399;">size</span>,
                        description:<span style="color: #ff0000;">&quot;$size row(s) of data expected&quot;</span>
        <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">def</span> showFirstElementDetails<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        clickLink   <span style="color: #ff0000;">'1'</span>, description:<span style="color: #ff0000;">'go to detail view'</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Para ejecutar la prueba escribimos el comando:</p>
<p style="padding-left: 30px;"><span style="color: #0000ff;">&gt; F:\dev\issuetracker&gt;grails run-webtest</span></p>
<p>Se generará un reporte como el siguiente:</p>
<p><img class="aligncenter" title="http://static.gkudos.com/blog/eclipse_grails/webtest.jpg" src="http://static.gkudos.com/blog/eclipse_grails/webtest.jpg" alt="" width="805" height="379" /></p>
<p>Puede encontrar un listado de completo para pruebas de canoo en la siguiente ubicación: <a href="http://webtest.canoo.com/webtest/manual/manualOverview.html">http://webtest.canoo.com/webtest/manual/manualOverview.html</a></p>
<p>Adicionalmente puede utilizar la herramienta <a href="http://webtestrecorder.canoo.com/">WebTestRecorder</a>.</p>
<p><strong>Enlaces Relacionados:</strong></p>
<ul>
<li><a href="http://www.grails.org/Unit+Testing">Grails Unit Testing</a></li>
<li><a href="http://www.grails.org/Testing+Controllers">Testing Controllers</a></li>
<li><a href="http://www.grails.org/Testing+Services">Testing Services</a></li>
<li><a href="http://www.grails.org/Testing+Domain+Classes">Testing Domain Classes</a></li>
<li><a href="http://www.grails.org/Functional+Testing">Grails Functional Testing</a></li>
<li><a href="Mastering Grails: Testing your Grails application">Mastering Grails: Testing your Grails application</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.gkudos.com/2009/06/02/introduccion-al-desarrollo-de-aplicaciones-con-groovy-y-grails-parte-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducción al Desarrollo de Aplicaciones con Groovy y Grails (Parte 3)</title>
		<link>http://blog.gkudos.com/2009/06/02/introduccion-al-desarrollo-de-aplicaciones-con-groovy-y-grails-parte-3/</link>
		<comments>http://blog.gkudos.com/2009/06/02/introduccion-al-desarrollo-de-aplicaciones-con-groovy-y-grails-parte-3/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 21:05:15 +0000</pubDate>
		<dc:creator>juanmendez</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.gkudos.com/?p=99</guid>
		<description><![CDATA[Configuración de Eclipse con soporte para Groovy y Grails
A continuación se describirá el proceso para configurar el entorno de Eclipse con las opciones para edición de Código Groovy y soporte para aplicaciones Grails.  (Eclipse es un entorno de desarrollo múltiplataforma de código abierto. Más información en esta dirección: http://es.wikipedia.org/wiki/Eclipse_(software)  ) .
Primero abrir eclipse y [...]]]></description>
			<content:encoded><![CDATA[<h2>Configuración de Eclipse con soporte para Groovy y Grails</h2>
<p style="margin-bottom: 0in;">A continuación se describirá el proceso para configurar el entorno de <a href="http://www.eclipse.org/">Eclipse</a> con las opciones para edición de Código Groovy y soporte para aplicaciones Grails.  (Eclipse es un entorno de desarrollo múltiplataforma de código abierto. Más información en esta dirección: <a href="http://es.wikipedia.org/wiki/Eclipse_(software) ">http://es.wikipedia.org/wiki/Eclipse_(software) </a> ) .</p>
<p style="margin-bottom: 0in;">Primero abrir eclipse y seleccionar en el menú la opción  <strong>help → software updates</strong>.   Esta opción abrirá una nueva pantalla. En esta seleccionamos la opción  <strong>Avaliable Software: </strong><span id="more-99"></span></p>
<p style="margin-bottom: 0in;"><img class="aligncenter" title="http://static.gkudos.com/blog/eclipse_grails/Imagen1.JPG" src="http://static.gkudos.com/blog/eclipse_grails/Imagen1.JPG" alt="" width="663" height="464" /></p>
<p>Seleccionamos el botón <strong>Add Site</strong> y en la url añadimos <a href="http://dist.codehaus.org/groovy/distributions/updateDev/">http://dist.codehaus.org/groovy/distributions/updateDev/</a> y damos clic en OK.</p>
<p>Ahora agregamos el siguiente sitio, repitiendo el paso anterior <a href="http://dist.codehaus.org/groovy/distributions/update/">http://dist.codehaus.org/groovy/distributions/update/</a></p>
<p>Y seleccionamos los plugins a instalar de la siguiente forma  (Tener en cuenta exactamente las versiones seleccionadas para el <strong>&#8220;Groovy Feature</strong>&#8221; y el &#8220;<strong>Grails Eclipse Feature</strong>&#8221; :</p>
<p style="text-align: center;"><img class="aligncenter" title="http://static.gkudos.com/blog/eclipse_grails/Imagen3.JPG" src="http://static.gkudos.com/blog/eclipse_grails/Imagen3.JPG" alt="" width="751" height="526" /></p>
<p>Seleccionamos la opción &#8220;<strong>Install</strong>&#8221; y aceptamos los términos de la licencia.  Luego de terminada la descarga  automática de los plugins seleccionados  debemos proceder a reiniciar Eclipse.</p>
<h2>Configuración de Variables de Entorno de Eclipse</h2>
<p>Ahora vamos a añadir la variable de entorno <strong>GRAILS_HOME</strong> en eclipse. Vamos a <strong>Windows → Preferences</strong>, buscamos <strong>Java → Build Path → Classpath Variables</strong>:</p>
<p style="text-align: center;"><img class="aligncenter" title="http://static.gkudos.com/blog/eclipse_grails/Imagen4.JPG" src="http://static.gkudos.com/blog/eclipse_grails/Imagen4.JPG" alt="" width="647" height="688" /></p>
<p>Damos clic en la opción <strong>New, </strong></p>
<p style="padding-left: 30px;"><strong>Name:</strong> GRAILS_HOME<br />
<strong>Path:</strong> <em>(La ruta donde esta instalado grails, ej: C:\grails)</em></p>
<p>Ahora importemos un proyecto grails a eclipse.<br />
Vamos a <strong>File → Import</strong>, ahí escogemos <strong>General</strong> → <strong>Existing Projects into Workspace</strong>, y le damos <strong>Next:</strong></p>
<p><img class="aligncenter" title="http://static.gkudos.com/blog/eclipse_grails/Imagen5.JPG" src="http://static.gkudos.com/blog/eclipse_grails/Imagen5.JPG" alt="" width="491" height="564" /></p>
<p>Ahora buscamos el directorio donde esta nuestro proyecto grails y hacemos clic en finish:</p>
<p><img class="aligncenter" title="http://static.gkudos.com/blog/eclipse_grails/Imagen5.JPG" src="http://static.gkudos.com/blog/eclipse_grails/Imagen5.JPG" alt="" width="491" height="564" /></p>
<p>Ahora vamos a modificar  las propiedades del configuración del proyecto Eclipse. Hacemos Click derecho sobre el proyecto → <strong>properties </strong>y seleccionamos la opción<strong> &#8220;groovy project properties&#8221; </strong>(Modificamos los valores de las variables según como muestra la imagen)</p>
<p><img class="aligncenter" title="http://static.gkudos.com/blog/eclipse_grails/Imagen7.JPG" src="http://static.gkudos.com/blog/eclipse_grails/Imagen7.JPG" alt="" width="642" height="564" /></p>
<p>Para ejecutar la aplicación podemos utilizar la combinación de teclas  <strong>CTRL+F11</strong>, o la opción  <strong>Run → Run</strong> en el menú. Seleccionamos la primera opción, para nuestro ejemplo issuetracker y la opción  OK.</p>
<p><img class="aligncenter" title="http://static.gkudos.com/blog/eclipse_grails/Imagen8.JPG" src="http://static.gkudos.com/blog/eclipse_grails/Imagen8.JPG" alt="" width="375" height="370" /></p>
<p>Cuando en la consola de eclipse aparezca  <strong><em> Server running. Browse to http://localhost:8080</em><em>/issuetracker,</em></strong> podremos iniciar la aplicación  en el explorador.</p>
<h2>Configuración para Depuración (Debug) de Grails en Eclipse</h2>
<p>Para que el depurador de Eclipse funcione con Grails, debemos verificar en las propiedades del proyecto  que la opción <strong>Disable Groovy Compiler Generating File</strong>s esté habilitada  y en <strong>Groovy compiler output</strong> location este la ruta “<strong>web-app/WEB-INF/classe</strong>s”.</p>
<p><img class="aligncenter" title="http://static.gkudos.com/blog/eclipse_grails/Imagen7.JPG" src="http://static.gkudos.com/blog/eclipse_grails/Imagen7.JPG" alt="" width="642" height="564" /></p>
<p>Para nuestro ejemplo, vamos a hacer un debug para la clase “<strong>ComponentController.groovy</strong>”</p>
<p>Abrimos la clase “<strong>ComponentController.groovy</strong>” y ponemos un break point en cualquier linea, para nuestro ejemplo en la linea 9, Hacemos clic en el botón debug, o F11, saldrá una pantalla similar a esta:</p>
<p><img class="aligncenter" title="http://static.gkudos.com/blog/eclipse_grails/img01.jpg" src="http://static.gkudos.com/blog/eclipse_grails/img01.jpg" alt="" width="480" height="246" /></p>
<p>Habilitamos la casilla “<strong>Don&#8217;t tell me again</strong>” y OK.<br />
Ahora vemos la aplicación en el navegador, y hacemos clic en el vinculo <strong>ComponentController</strong> ,y el debug es activado en eclipse.</p>
<p><img class="aligncenter" title="http://static.gkudos.com/blog/eclipse_grails/Imagen10.JPG" src="http://static.gkudos.com/blog/eclipse_grails/Imagen10.JPG" alt="" width="717" height="284" /></p>
<p>Damos clic derecho en el proyecto en la pantalla <strong>debug</strong> y vamos a <strong>Edit Source Lookup</strong>, damos click en el botón <strong>add</strong>, seleccionamos la opción <strong>Workspace Folder</strong>,</p>
<p><img class="aligncenter" title="http://static.gkudos.com/blog/eclipse_grails/Imagen11.JPG" src="http://static.gkudos.com/blog/eclipse_grails/Imagen11.JPG" alt="" width="516" height="534" /></p>
<p>Buscamos la ruta <strong>web-app/ WEB-INF/classes</strong>, habilitamos la opción <strong>Search subfolders </strong>y la opción <strong>OK</strong>.  Adicionalmente, seleccionamos de nuevo la opción  <strong>add</strong>, y agregamos la ruta <strong>grails-app</strong>, también habilitamos la opción Search subfolders y OK.</p>
<p>En este momento ya tenemos habilitado  entorno de eclipse para depuración de aplicaciones <strong>Groovy / Grails</strong>.</p>
<p><a href="http://static.gkudos.com/blog/eclipse_grails/Imagen12.JPG"><img class="aligncenter" title="http://static.gkudos.com/blog/eclipse_grails/Imagen12.JPG" src="http://static.gkudos.com/blog/eclipse_grails/Imagen12.JPG" alt="" width="924" height="576" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gkudos.com/2009/06/02/introduccion-al-desarrollo-de-aplicaciones-con-groovy-y-grails-parte-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducción al Desarrollo de Aplicaciones con Groovy y Grails (Parte 2)</title>
		<link>http://blog.gkudos.com/2009/05/31/introduccion-al-desarrollo-de-aplicaciones-con-groovy-y-grails-parte-2/</link>
		<comments>http://blog.gkudos.com/2009/05/31/introduccion-al-desarrollo-de-aplicaciones-con-groovy-y-grails-parte-2/#comments</comments>
		<pubDate>Sun, 31 May 2009 13:23:31 +0000</pubDate>
		<dc:creator>juanmendez</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.gkudos.com/?p=82</guid>
		<description><![CDATA[Creando una Clase del Dominio del Problema
Para nuestro ejemplo vamos a crear los siguientes modelos de dominio: Project, Component, and Issue.
La clase &#8220;Project&#8221; que representa el proyecto de software para el cual vamos a registrar incidencias (Bugs).
Un Project puede tener uno o más Componentes (Ejm: gui, documentación, etc)
Un Componente solo está asociado a un proyecto [...]]]></description>
			<content:encoded><![CDATA[<h2>Creando una Clase del Dominio del Problema</h2>
<p>Para nuestro ejemplo vamos a crear los siguientes modelos de dominio: Project, Component, and Issue.<br />
La clase &#8220;Project&#8221; que representa el proyecto de software para el cual vamos a registrar incidencias (Bugs).<br />
Un Project puede tener uno o más Componentes (Ejm: gui, documentación, etc)<br />
Un Componente solo está asociado a un proyecto y puede tener cero o más Issues asociados.<br />
Un objeto Issue está asociado a un Componente.</p>
<p><span id="more-82"></span></p>
<p>Con el siguiente comando creamos la entidad Project:</p>
<p style="padding-left: 30px;">
<p><span style="color: #0000ff;">&gt;  D:\dev\issuetracker&gt;grails create-domain-class  Project</span></p>
<p>Si el comando se ejecuta satisfactoriamente debería obtenerse una respuesta similar a la<br />
siguiente:</p>
<p style="padding-left: 30px;"><span style="color: #0000ff;">&gt;  Welcome to Grails 1.1.1 &#8211; http://grails.org/<br />
&gt;  Licensed under Apache Standard License 2.0<br />
&gt;  Grails home is set to: C:\dev\grails-1.1.1<br />
&gt;  Base Directory: D:\dev\issuetracker<br />
&gt;  Running script C:\dev\grails-1.1.1\scripts\CreateDomainClass.groovy<br />
&gt;  Environment set to development<br />
&gt;  Created DomainClass for Project<br />
&gt;  Created Tests for Project</span></p>
<p>grails automáticamente crea el archivo    %PROJECT_HOME%\grails-app\domain\Project.groovy     con la siguiente estructura</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Project <span style="color: #66cc66;">&#123;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">static</span> constraints <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<h2>Qué es una Clase de Dominio?</h2>
<p>Una clase de dominio es un artefacto persistente para el cual todas sus propiedades  son persistidas<br />
en la base de datos (Más información en  GORM http://www.grails.org/GORM (Grails Object Relational Mapping) )</p>
<p>Para nuestro ejemplo editamos el archivo Project.groovy de la siguiente forma:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Project <span style="color: #66cc66;">&#123;</span>
  <span style="color: #808080; font-style: italic;">// relaciones</span>
  <span style="color: #000000; font-weight: bold;">static</span> hasMany <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>components: <span style="color: #aaaadd; font-weight: bold;">Component</span><span style="color: #66cc66;">&#93;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// campos</span>
<span style="color: #aaaadd; font-weight: bold;">String</span> name
&nbsp;
<span style="color: #aaaadd; font-weight: bold;">String</span> toString<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #000000; font-weight: bold;">return</span> name
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// restricciones</span>
<span style="color: #000000; font-weight: bold;">static</span> constraints <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
name<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
components<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Como se puede ver en la clase Project, por lo general una clase de dominio de GORM se compone de relaciones con otras entidades,<br />
campos (Columnas en la base de datos), y restricciones.</p>
<p>Para nuestro sistema de ejemplo debemos crear también las clases de dominio Issue y Component:</p>
<p style="padding-left: 30px;"><span style="color: #0000ff;">&gt;  D:\dev\issuetracker&gt;grails create-domain-class  Component<br />
&gt;  D:\dev\issuetracker&gt;grails create-domain-class  Issue</span></p>
<p>y las editamos de la siguiente forma:</p>
<p style="padding-left: 30px;"><strong>Component.groovy</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> <span style="color: #aaaadd; font-weight: bold;">Component</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #808080; font-style: italic;">// relationships</span>
<span style="color: #000000; font-weight: bold;">static</span> belongsTo <span style="color: #66cc66;">=</span> Project
<span style="color: #000000; font-weight: bold;">static</span> hasMany <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>issues: Issue<span style="color: #66cc66;">&#93;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// fields</span>
Project project
<span style="color: #aaaadd; font-weight: bold;">String</span> name
&nbsp;
<span style="color: #808080; font-style: italic;">// override for nice display</span>
<span style="color: #aaaadd; font-weight: bold;">String</span> toString<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #000000; font-weight: bold;">return</span> “<span style="color: #0000ff;">$<span style="color: #66cc66;">&#123;</span>project<span style="color: #66cc66;">&#125;</span></span> <span style="color: #66cc66;">-</span> <span style="color: #0000ff;">$<span style="color: #66cc66;">&#123;</span>name<span style="color: #66cc66;">&#125;</span></span>”
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// constraints</span>
<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">def</span> constraints <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #808080; font-style: italic;">//’empty’ constraints</span>
<span style="color: #808080; font-style: italic;">//garantizan el orden como apareceran los campos en la forma</span>
name<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
project<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
issues<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p style="padding-left: 30px;"><strong>Issue.groovy</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Issue <span style="color: #66cc66;">&#123;</span>
<span style="color: #808080; font-style: italic;">// relationships</span>
<span style="color: #000000; font-weight: bold;">static</span> belongsTo <span style="color: #66cc66;">=</span> <span style="color: #aaaadd; font-weight: bold;">Component</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// fields</span>
<span style="color: #aaaadd; font-weight: bold;">Component</span> component
<span style="color: #aaaadd; font-weight: bold;">String</span> type
<span style="color: #aaaadd; font-weight: bold;">String</span> submitter
<span style="color: #aaaadd; font-weight: bold;">String</span> description
<span style="color: #aaaadd; font-weight: bold;">String</span> status <span style="color: #66cc66;">=</span> “<span style="color: #000000; font-weight: bold;">New</span>”
<span style="color: #aaaadd; font-weight: bold;">Integer</span> bounty
<span style="color: #aaaadd; font-weight: bold;">Date</span> dateCreated
<span style="color: #aaaadd; font-weight: bold;">Date</span> lastUpdated
&nbsp;
<span style="color: #808080; font-style: italic;">// constraints</span>
<span style="color: #000000; font-weight: bold;">static</span> constraints <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
component<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #808080; font-style: italic;">//restringe una lista de valores</span>
type<span style="color: #66cc66;">&#40;</span>inList: <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Defect&quot;</span>, <span style="color: #ff0000;">&quot;Feature&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>
submitter<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
description<span style="color: #66cc66;">&#40;</span><span style="color: #663399;">size</span>: 0..5000<span style="color: #66cc66;">&#41;</span>
status<span style="color: #66cc66;">&#40;</span>inList: <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;New&quot;</span>, <span style="color: #ff0000;">&quot;Accepted&quot;</span>, <span style="color: #ff0000;">&quot;Closed&quot;</span>, <span style="color: #ff0000;">&quot;Won't Fix&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>
bounty<span style="color: #66cc66;">&#40;</span>range:0..12<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>En los siguientes enlaces puede encontrarse información mucho más detallada sobre el funcionamiento de <strong>GORM:</strong><br />
<strong>Mapeo de Entidades: </strong><a href="http://www.grails.org/GORM+-+Mapping+DSL">http://www.grails.org/GORM+-+Mapping+DSL</a><br />
<strong>Relaciones: </strong><a href="http://www.grails.org/GORM+-+Defining+relationships">http://www.grails.org/GORM+-+Defining+relationships</a><br />
<strong>Colecciones: </strong> <a href="http://www.grails.org/GORM+-+Collection+Types">http://www.grails.org/GORM+-+Collection+Types</a><br />
<strong>Operaciones de Crud: </strong> <a href="http://www.grails.org/GORM+-+CRUD">http://www.grails.org/GORM+-+CRUD</a></p>
<h2>Creación de Datos de Prueba</h2>
<p>Muchas veces se requieren datos de ejemplo para realizar pruebas al sistema.<br />
Grails nos permite la creación inicial de datos de la siguiente forma:</p>
<p>Ubicar el archivo    %PROJECT_HOME%\grails-app\conf\BootStrap.groovy   y modificarlo de la siguiente forma:</p>
<p style="padding-left: 30px;"><span style="color: #000080;">class BootStrap {</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">def init = { servletContext -&gt;<br />
// Create some test data<br />
new Project(name:&#8221;Widget para Facebook&#8221;).save()<br />
new Project(name:&#8221;Simple Issue Tracker&#8221;).save()<br />
new Project(name:&#8221;Extensión para Openlayers&#8221;).save()<br />
}<br />
def destroy = {<br />
}<br />
}</span></p>
<p>En este ejemplo creamos tres objetos Project como datos de prueba.</p>
<h2>Creación de Controladores y Vistas</h2>
<p>Dado que ya disponemos de nuestras clases de dominio, podemos ejecutar los siguientes comandos que se<br />
encargarán de generar los controladores y vistas para nuestras entidades:</p>
<p style="padding-left: 30px;"><span style="color: #0000ff;">&gt;D:\dev\issuetracker&gt;grails generate-all Project<br />
&gt;D:\dev\issuetracker&gt;grails generate-all Component<br />
&gt;D:\dev\issuetracker&gt;grails generate-all Issue</span></p>
<p>El comando <strong>generate-all</strong> genera el código necesario para habilitar el CRUD de las entidades Project, Component e Issue.</p>
<p>Para ejecutar la aplicación podemos utilizar el comando:</p>
<p style="padding-left: 30px;"><span style="color: #0000ff;">&gt; D:\dev\issuetracker&gt;grails run-app</span></p>
<p>Una vez  se ha inicializado el servidor, puede ingresar a la aplicación a través del siguiente url:  <span style="color: #0000ff;">http://localhost:8080/issuetracker</span></p>
<p>En la pantalla de inicio podrá ver lo siguiente:<br />
<img class="aligncenter" title="http://pwp.007mundo.com/jcmendez/kudos/WelcomeGrails_1243741628743.png" src="http://pwp.007mundo.com/jcmendez/kudos/WelcomeGrails_1243741628743.png" alt="" width="591" height="242" /></p>
<p>Si selecciona la opción ProjectController podrá ver el listado de los proyectos:<br />
<img class="aligncenter" title="http://pwp.007mundo.com/jcmendez/kudos/Project_List.png" src="http://pwp.007mundo.com/jcmendez/kudos/Project_List.png" alt="" width="332" height="281" /></p>
<p>A continuación la pantalla donde se muestra el detalle de un Component:</p>
<p style="text-align: center;"><img class="aligncenter" title="http://pwp.007mundo.com/jcmendez/kudos/Show_Component.png" src="http://pwp.007mundo.com/jcmendez/kudos/Show_Component.png" alt="" width="364" height="341" /></p>
<p>Si desea crear un nuevo Issue, grails ha generado para usted la siguiente pantalla:<br />
<img class="aligncenter" title="http://pwp.007mundo.com/jcmendez/kudos/CreateIssue.png" src="http://pwp.007mundo.com/jcmendez/kudos/CreateIssue.png" alt="" width="446" height="634" /></p>
<p>Nótese que con muy poco esfuerzo hemos logrado crear una aplicación completa de CRUD para administrar nuestras entidades Project, Component e Issue.  En las siguientes partes del tutorial se incluirán  funcionalidades adicionales y personalización de la visualización.</p>
<p>Puede descargar el código completo de la parte 2 desde <a href="http://pwp.007mundo.com/jcmendez/kudos/issuetracker_parte_2.zip">esta ubicación</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gkudos.com/2009/05/31/introduccion-al-desarrollo-de-aplicaciones-con-groovy-y-grails-parte-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducción al Desarrollo de Aplicaciones con Groovy y Grails (Parte 1)</title>
		<link>http://blog.gkudos.com/2009/05/30/introduccion-al-desarrollo-de-aplicaciones-con-groovy-y-grails-parte-1/</link>
		<comments>http://blog.gkudos.com/2009/05/30/introduccion-al-desarrollo-de-aplicaciones-con-groovy-y-grails-parte-1/#comments</comments>
		<pubDate>Sun, 31 May 2009 04:39:45 +0000</pubDate>
		<dc:creator>juanmendez</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://blog.gkudos.com/?p=73</guid>
		<description><![CDATA[
Introducción:
Grails es un marco de trabajo para el desarrollo de aplicaciones web que se basa en las ideas de
&#8220;Codificación a través de Convenciones&#8221; (coding by convention) y DRY (don&#8217;t repeat yourself) utilizando el lenguaje de programación Groovy.
Grails se ejecuta sobre una máquina virtual de Java, teniendo acceso completo a la plataforma y librerías Java.
Con Grails [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter" title="http://www.grails.org/images/grails-logo.png" src="http://www.grails.org/images/grails-logo.png" alt="" width="285" height="148" /></p>
<h2><strong>Introducción:</strong></h2>
<p>Grails es un marco de trabajo para el desarrollo de aplicaciones web que se basa en las ideas de<br />
&#8220;<em>Codificación a través de Convenciones</em>&#8221; (<em>coding by convention</em>) y DRY (<em>don&#8217;t repeat yourself</em>) utilizando el lenguaje de programación Groovy.</p>
<p>Grails se ejecuta sobre una máquina virtual de Java, teniendo acceso completo a la plataforma y librerías Java.</p>
<p>Con Grails pueden crearse fácilmente aplicaciones web gracias a:</p>
<ul>
<li> Ofrece un Entorno completo para el desarrollo y publicación de aplicaciones: Todas las dependencias y configuración requeridas para ejecutar las aplicaciones web son proporcionadas por Grails.  Usted debe solamente preocuparse por el código particular de su aplicación.</li>
<li>Incluye un servidor Jetty embebido.</li>
<li>El modo de desarrollo automáticamente recarga los cambios realizados al código de la aplicación sin tener que reiniciar el servidor web.</li>
<li>Ofrece mapeo de persistencia automàtico para las clases del Dominio del problema, así como también manejo automàtico de las relaciones entre las entidades.</li>
<li>Ofrece <a href="http://technologysource.org/extra/389/definition/2/">scaffolding</a> para el acceso a datos, ofreciendo posibilidades para el desarrollo rápido de operaciones CRUD (Create, Read, Update, Delete).</li>
<li>Soporte de tecnologías para la implementación de vistas de datos utilizando &#8220;dynamic tag libraries&#8221; y &#8220;Groovy Server Pages (GSP)&#8221;</li>
<li>Extensibilidad a través de la utilización de plugins.</li>
</ul>
<p><span id="more-73"></span></p>
<p>Grails puede usarse como un entorno de desarrollo autónomo que esconde todos los detalles de configuración así como también permite integrar lógica de negocio escrita en Java.  Entre los objetivos de Grails está el hacer el desarrollo web lo más simple y atractivo posible de tal forma que un amplio segmento de desarrolladores puedan utilizarlo.</p>
<h2>Tutorial &#8220;Escribir un Manejador de Incidencias Utilizando Grails&#8221;</h2>
<p>El tutorial a desarrollar a continuación se basa en el artículo &#8220;<em>Writing a Simple Issue Tracker in Grails</em>&#8221; <a href="http://josh-in-antarctica.blogspot.com/2008/04/writing-simple-issue-tracker-in-grails.html">Part 1</a> y   <a href="http://josh-in-antarctica.blogspot.com/2008/05/writing-simple-issue-tracker-in-grails.html">Part 2<br />
</a></p>
<h2>Cómo Obtener el Framework Grails?</h2>
<p>Usted puede descargar la última versión del framework desde la siguiente ubicación: <a href="http://www.grails.org/Download">http://www.grails.org/Download</a></p>
<h2>Instalación</h2>
<p>Una vez ha obtenido y descomprimido el framework debe adicionar a su sistema operativo la variable de entorno GRAILS_HOME.</p>
<p>Si utiliza windows puede configurar las variables de entorno de la siguiente forma:</p>
<p style="padding-left: 30px;"><span style="color: #0000ff;">&gt; set GRAILS_HOME=C:\download\grails<br />
&gt; echo %GRAILS_HOME%<br />
C:\download\grails<br />
&gt; set PATH=%GRAILS_HOME%\bin;%PATH%</span></p>
<p>(Información adicional:  <a href="http://support.microsoft.com/kb/310519/es">Administrar variables de entorno en Windows XP</a> )</p>
<p><img class="aligncenter" title="http://static.gkudos.com/blog/eclipse_grails/win_env_variab.jpg" src="http://static.gkudos.com/blog/eclipse_grails/win_env_variab.jpg" alt="" width="440" height="520" /></p>
<p><img class="aligncenter" title="http://static.gkudos.com/blog/eclipse_grails/win_env_variab_2.jpg" src="http://static.gkudos.com/blog/eclipse_grails/win_env_variab_2.jpg" alt="" width="413" height="506" /></p>
<p>O si utiliza sistemas basados en linux puede utilizar los siguientes comandos:</p>
<p style="padding-left: 30px;"><span style="color: #0000ff;">&gt; set GRAILS_HOME=~/download/grails<br />
&gt; export GRAILS_HOME<br />
&gt; echo ${GRAILS_HOME}<br />
~/download/grails<br />
&gt; cd ${GRAILS_HOME}<br />
&gt; chmod a+x bin/grails<br />
&gt; set PATH=${GRAILS_HOME}/bin:${PATH}<br />
&gt; export PATH</span></p>
<p>(No olvide configurar también la variable JAVA_HOME apuntando a la carpeta donde reside su instalación<br />
particular de Java (JDK <a href="http://java.sun.com/javase/downloads/index.jsp">http://java.sun.com/javase/downloads/index.jsp</a>).<br />
<a href="http://www.it.uc3m.es/tlp/guia/guiaWinXP.html"> Configuración de Java en Windows</a><br />
<a href="http://www.keopx.net/ubuntu/configurar-java_home-en-gnulinux/"> Configuración de Java en Unix</a>)</p>
<p>para comprobar su instalación de grails puede digitar el siguiente comando</p>
<p style="padding-left: 30px;"><span style="color: #0000ff;">&gt; grails</span></p>
<p>debe aparecer como respuesta un mensaje similar al siguiente:</p>
<p style="padding-left: 30px;"><span style="color: #0000ff;">&gt; C:\Documents and Settings\user&gt;grails<br />
&gt; Welcome to Grails 1.1.1 &#8211; http://grails.org/<br />
&gt; Licensed under Apache Standard License 2.0<br />
&gt; Grails home is set to: C:\dev\grails-1.1.1<br />
&gt; No script name specified. Use &#8216;grails help&#8217; for more info or &#8216;grails interactive&#8217; to enter interactive mode</span></p>
<h2>Creando el proyecto Con Grails</h2>
<p>Para crear nuestro  proyecto Grails debe utilizar el siguiente comando</p>
<p style="padding-left: 30px;"><span style="color: #0000ff;">&gt; D:\dev&gt;grails  create-app issuetracker</span></p>
<p>este comando creará una carpeta con la siguiente estructura de directorios:<br />
(Para nuestro ejemplo la carpeta <strong>%PROJECT_HOME% </strong>es representada por la carpeta <strong>D:\dev\issuetracker</strong>)</p>
<p><img class="alignleft" title="http://pwp.007mundo.com/jcmendez/kudos/grails_estructura_proyecto.jpg" src="http://pwp.007mundo.com/jcmendez/kudos/grails_estructura_proyecto.jpg" alt="" width="702" height="385" /></p>
<h2>Configuración de la Base de Datos</h2>
<p>Para nuestro ejemplo utilizaremos el motor de bases de datos relacionales PostgreSql. (Debemos crear<br />
una instancia y usuario en la base de datos. Para este caso creamos la base de datos &#8220;issues&#8221; con<br />
su usuario relacionado &#8220;issuetracker&#8221; con clave &#8220;issuetracker&#8221;)</p>
<p>Primero necesitamos descargar el driver Jdbc disponible en la siguiente ubicación: <a href="http://jdbc.postgresql.org/download.html">http://jdbc.postgresql.org/download.html</a><br />
(Para nuestro ejemplo descargamos el jar <em>postgresql-8.3-604.jdbc4.jar</em> )<br />
El jar obtenido debe ser copiado en la carpeta %PROJECT_HOME%/lib</p>
<h2>Configuración del Datasource</h2>
<p>Una de las grandes ventajas de Grails es la facilidad para el manejo de la configuración del proyecto.</p>
<p>Por ejemplo el comando ejecutado &#8220;create-app&#8221;  entre otros archivos crea uno llamado  DataSource.groovy (En la carpeta %PROJECT_HOME%grails-app/conf/ ).<br />
Este archivo nos permite especificar diferentes ambientes (<em>Development, TestData y Production</em>)<br />
para el manejo de la fuente de datos del proyecto.  Como opción por omisión utiliza el manejador de datos<br />
<em>HSQLDB</em>.</p>
<p>Para modificar la configuración del entorno &#8220;<em>Development</em>&#8221; utilizando postgresql debemos modificar el archivo DataSource.groovy de la siguiente forma:</p>
<p><code>development {<br />
dataSource {<br />
driverClassName = "org.postgresql.Driver"<br />
dbCreate = "create-drop" // one of 'create', 'create-drop','update'<br />
url = "jdbc:postgresql://localhost:5432/issues"<br />
dialect = org.hibernate.dialect.PostgreSQLDialect<br />
username = "issuetracker"<br />
password = "issuetracker"<br />
}<br />
}</code></p>
<p>(Más información en <a href="http://hartsock.blogspot.com/2008/07/postgresql-and-grails.html">http://hartsock.blogspot.com/2008/07/postgresql-and-grails.html</a> )</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gkudos.com/2009/05/30/introduccion-al-desarrollo-de-aplicaciones-con-groovy-y-grails-parte-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
