<?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>Faddie bloggt - schon wieder! &#187; english content</title>
	<atom:link href="http://blog.sonores.de/category/english-content/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sonores.de</link>
	<description>Faddie - die eleganteste Steigerung von Grün</description>
	<lastBuildDate>Wed, 10 Sep 2008 14:04:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>Drawing oldschool backgrounds for Adventure Games</title>
		<link>http://blog.sonores.de/2008/09/10/drawing-oldschool-backgrounds-for-adventure-games/</link>
		<comments>http://blog.sonores.de/2008/09/10/drawing-oldschool-backgrounds-for-adventure-games/#comments</comments>
		<pubDate>Wed, 10 Sep 2008 13:32:42 +0000</pubDate>
		<dc:creator>faddie</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[english content]]></category>
		<category><![CDATA[art]]></category>
		<category><![CDATA[background]]></category>
		<category><![CDATA[drawing]]></category>
		<category><![CDATA[lowres]]></category>
		<category><![CDATA[lucasarts]]></category>
		<category><![CDATA[pixel]]></category>
		<category><![CDATA[scumm]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.sonores.de/?p=257</guid>
		<description><![CDATA[<br/>Tutorial Time (again)! I just finished a background for my new game and recorded the steps. So if you&#8217;re interested to draw things like this (this is a motel room): Keep on reading First of all: This is not a tutorial about how to use paint programs, some basic knowledge in whatever application you use [...]]]></description>
			<content:encoded><![CDATA[<br/><p>Tutorial Time (again)! I just finished a background for my new game and recorded the steps. So if you&#8217;re interested to draw things like this (this is a motel room):</p>
<p>
<a  href="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tutx2.png" onclick="javascript:pageTracker._trackPageview('/downloads/wp-content/uploads/2008/09/motel_tutx2.png');" ><img class="alignnone size-medium wp-image-246" title="motel_tut11_noise" src="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut11_noise-300x133.png" alt="" width="300" height="133" /></a></p>
<p>Keep on reading <img src='http://blog.sonores.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-257"></span></p>
<p>First of all: This is not a tutorial about how to use paint programs, some basic knowledge in whatever application you use is needed.</p>
<p>There&#8217;re two common methods to start on low res background &#8211; you begin with a hand drawn sketch and scan it. Or you directly start from the scratch &#8211; without a template.</p>
<p>For this screen, I made a rough sketch on paper but drew it completely on the computer (no tablet). For the first 2 steps, I&#8217;ve used Pro Motion, but shading and anti aliasing has been done in Photoshop 6 (which runs fast enough on this old machine). If you need  8-bit color depth, then keep sticking to ProMotion (or whatever you like), otherwise Photoshop (or Gimp) is a real time saver.</p>
<p><strong>1. Step &#8211; Outline the scene</strong></p>
<p>
<a  href="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut1.png" onclick="javascript:pageTracker._trackPageview('/downloads/wp-content/uploads/2008/09/motel_tut1.png');" ><img class="alignnone size-medium wp-image-247" title="motel_tut1" src="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut1-300x133.png" alt="" width="600" height="266" /></a></p>
<p>I&#8217;ve tried to chose an interesting perspective with lot&#8217;s of sloping lines. The blue line&#8217;s the horizont, the red dots are the two vanishing points. Because it&#8217;s a quite boring to just look in a corner, I&#8217;ve added a ledge to the wall (maybe there&#8217;s a chimney on the other side or whatever <img src='http://blog.sonores.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ).</p>
<p>
<a  href="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut2.png" onclick="javascript:pageTracker._trackPageview('/downloads/wp-content/uploads/2008/09/motel_tut2.png');" ><img class="alignnone size-medium wp-image-248" title="motel_tut2" src="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut2-300x133.png" alt="" width="600" height="266" /></a></p>
<p>Now I&#8217;ve moved the scenery a little and added a ceiling &#8211; since this is going to be motel room and not a hallway. There&#8217;s also a window with curtains.</p>
<p>
<a  href="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut3.png" onclick="javascript:pageTracker._trackPageview('/downloads/wp-content/uploads/2008/09/motel_tut3.png');" ><img class="alignnone size-medium wp-image-249" title="motel_tut3" src="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut3-300x133.png" alt="" width="600" height="266" /></a></p>
<p>Now there&#8217;s also a table and a bed. I&#8217;ve used flashy colors to see if the composing is good and making painting over it easier.</p>
<p>
<a  href="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut4.png" onclick="javascript:pageTracker._trackPageview('/downloads/wp-content/uploads/2008/09/motel_tut4.png');" ><img class="alignnone size-medium wp-image-250" title="motel_tut4" src="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut4-300x133.png" alt="" width="600" height="266" /></a></p>
<p>The next station is a tv and a little detail on the carpet (at this point it also could have been a wooden floor). All the objects I&#8217;ve outlined so far are static objects. In the later game you can&#8217;t move them aroung, pick them up or anything alse. This is important for the shading because if you would have been able to move the table, you also had to move its shadow.</p>
<p><strong>Step 2 &#8211; Basic coloring</strong></p>
<p>
<a  href="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut5.png" onclick="javascript:pageTracker._trackPageview('/downloads/wp-content/uploads/2008/09/motel_tut5.png');" ><img class="alignnone size-medium wp-image-251" title="motel_tut5" src="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut5-300x133.png" alt="" width="600" height="266" /></a></p>
<p>Let&#8217;s bring some colors to the scene. First I&#8217;ve added a lamp to have a primary lightsource. ProMotion is really good in adding old school gradients and so I&#8217;ve chosen a goldish yellow and colored the wall. Unfortunately I did it wrong <img src='http://blog.sonores.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Note the light on the ledge and the left wall. It&#8217;s impossible for the lamp to create that shadow &#8211; fortunately this has been fixed on the next image. Finding a color (and a texture) for the carpet gave me a hard time, so I ended up searching google for motel rooms. Most of them had red ones, so I also chose it until I realized that it&#8217;s damn ugly &#8211; so where the motel rooms btw <img src='http://blog.sonores.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>
<a  href="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut5-1.png" onclick="javascript:pageTracker._trackPageview('/downloads/wp-content/uploads/2008/09/motel_tut5-1.png');" ><img class="alignnone size-medium wp-image-259" title="motel_tut5-1" src="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut5-1-300x133.png" alt="" width="600" height="266" /></a></p>
<p>So for the next version I&#8217;ve used red for the table and a more convenient grayish blue for the carpet. Those color ideas were from an Ikea catalog <img src='http://blog.sonores.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I&#8217;ve also fixed the gradients on the wall to look more natural and colored the bed and the TV. The bedsheet is actually the one I&#8217;ve currently use. As a hint &#8211; be creative choosing colors and textures. Here&#8217;s how you shouldn&#8217;t do it: White wallpaper, brown table, white bed, gray sheets, no curtains at the window and an inconspicuous color for the carpet.</p>
<p>Even if realitiy isn&#8217;t that colorful &#8211; most of us play games to forget about reality <img src='http://blog.sonores.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Those white parts in the image are actually transparent, so the carpet doesn&#8217;t get white on the bottom of the screen.</p>
<p><strong>Step 3 &#8211; Objects</strong></p>
<p>I&#8217;ve added a new layer in ProMotion and added some objects to this quite naked room. Here are the objects without their background.</p>
<p>
<a  href="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut6.png" onclick="javascript:pageTracker._trackPageview('/downloads/wp-content/uploads/2008/09/motel_tut6.png');" ><img class="alignnone size-medium wp-image-252" title="motel_tut6" src="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut6-300x187.png" alt="" width="600" height="374" /></a></p>
<p>In case you don&#8217;t know what to add in a room, just think. A TV need something so you can watch it &#8211; voila: armchair in front of the TV and so on.</p>
<p>So here we have a door, some pictures, a pile of dirt, an armchair and a phone with a clipboard. For those objects I&#8217;ve created outlines again, just like in step 1 and some basic coloring.</p>
<p><strong>Step 4 &#8211; Details, shading and the finishing touch</strong></p>
<p>
<a  href="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut7_obj.png" onclick="javascript:pageTracker._trackPageview('/downloads/wp-content/uploads/2008/09/motel_tut7_obj.png');" ><img class="alignnone size-medium wp-image-253" title="motel_tut7_obj" src="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut7_obj-300x133.png" alt="" width="600" height="266" /></a></p>
<p>Here&#8217;s how it looks, if the objects are on the background. I also adjusted the color a little. Since I&#8217;m now in Photoshop, this is rather easy.</p>
<p>
<a  href="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut8_vgn.png" onclick="javascript:pageTracker._trackPageview('/downloads/wp-content/uploads/2008/09/motel_tut8_vgn.png');" ><img class="alignnone size-medium wp-image-254" title="motel_tut8_vgn" src="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut8_vgn-300x133.png" alt="" width="600" height="266" /></a></p>
<p>I&#8217;ve now added a slight vignette to draw the attention more to the center of the room. Note that the lamp is now lighter and the corners get darker.</p>
<p>
<a  href="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut9_strp.png" onclick="javascript:pageTracker._trackPageview('/downloads/wp-content/uploads/2008/09/motel_tut9_strp.png');" ><img class="alignnone size-medium wp-image-255" title="motel_tut9_strp" src="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut9_strp-300x133.png" alt="" width="600" height="266" /></a></p>
<p>Also the wallpaper looked quite boring, so I&#8217;ve decided to add some stripes &#8211; it&#8217;s never good to have large areas in the same color (search for a &#8220;tv lines&#8221; tutorial, if you don&#8217;t know how to do it).</p>
<p>There&#8217;s also glas in the window frame now.</p>
<p>
<a  href="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut10_shadow.png" onclick="javascript:pageTracker._trackPageview('/downloads/wp-content/uploads/2008/09/motel_tut10_shadow.png');" ><img class="alignnone size-medium wp-image-256" title="motel_tut10_shadow" src="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut10_shadow-300x133.png" alt="" width="600" height="266" /></a></p>
<p>The next part might be the hardest part for some of you &#8211; adding shadows. Just look at the light source and try to imagine where the light might hit the ground or where it might be blocked. Adding shadows in photoshop is quite easy (and there are a lot tutorials about it). I&#8217;ve used an additional layer, positioned it under the object layer and drew 100% black areas. Then I&#8217;ve applied a slight motion blur and set the layer&#8217;s opacity to about 30%. For the shadow on the carpet (it gets darker, the more it&#8217;s away from the lamp) I&#8217;ve used a seperate layer and made it completely black. Then I&#8217;ve added a layer mask and added a gradient from black to white on it &#8211; done <img src='http://blog.sonores.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>But as I&#8217;ve written above, there are far more better tutorials, covering shadows.</p>
<p>
<a  href="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut11_noise.png" onclick="javascript:pageTracker._trackPageview('/downloads/wp-content/uploads/2008/09/motel_tut11_noise.png');" ><img class="alignnone size-medium wp-image-246" title="motel_tut11_noise" src="http://blog.sonores.de/wp-content/uploads/2008/09/motel_tut11_noise-300x133.png" alt="" width="600" height="266" /></a></p>
<p>The last thing I did is to add some noise on rough surfaces &#8211; like the carpet and the arm chair.</p>
<p>And that&#8217;s it &#8211; it might not be perfect and there&#8217;s always room for improvements. But try not to dissipate your energies just to one screen. I&#8217;m sure, there will be a lot more you have to draw and in my oppinion it&#8217;s better to have some mediocre screens but a finished game instead of 2 perfects screens and a canceled project <img src='http://blog.sonores.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>So long, I hope you liked it!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonores.de/2008/09/10/drawing-oldschool-backgrounds-for-adventure-games/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dojo Tutorial with a grid: part 3 &#8211; english version</title>
		<link>http://blog.sonores.de/2008/03/14/dojo-tutorial-with-a-grid-part-3-english-version/</link>
		<comments>http://blog.sonores.de/2008/03/14/dojo-tutorial-with-a-grid-part-3-english-version/#comments</comments>
		<pubDate>Fri, 14 Mar 2008 10:22:47 +0000</pubDate>
		<dc:creator>faddie</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[english content]]></category>
		<category><![CDATA[geeked]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[Grid]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[XHR]]></category>
		<category><![CDATA[xhttprequest]]></category>

		<guid isPermaLink="false">http://blog.sonores.de/2008/03/14/dojo-tutorial-with-a-grid-part-3-english-version/</guid>
		<description><![CDATA[<br/>Now we&#8217;re dealing with that grid. Finally, since we&#8217;ve been kept busy with the basics so far 3.6 dojo.grid in javascript After search for the name &#8220;Petersen&#8221;, the webserver returns a JSON-String, containing all people with this name. Our goal is now to process this data into a grid . So let&#8217;s have a look [...]]]></description>
			<content:encoded><![CDATA[<br/><p>Now we&#8217;re dealing with that grid. Finally, since we&#8217;ve been kept busy with the basics so far <img src='http://blog.sonores.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h2><span id="more-168"></span> 3.6 dojo.grid in javascript</h2>
<p>After search for the name &#8220;Petersen&#8221;, the webserver returns a JSON-String, containing all people with this name. Our goal is now to process this data into a grid .</p>
<p>So let&#8217;s have a look at gridtut.js again.</p>
<p>Using the command &#8220;var result = eval(&#8216;(&#8216;+data+&#8217;)');&#8221; an array (or better a javascript object) is beeing created from the JSON-string and been saved in the variable &#8220;result&#8221;.</p>
<p>With this array, we can now populate the grid&#8230; but wait, there definately missing a grid :-O<span><span></span></span></p>
<p>Firstof all, we have to tell the grid, how many columns we want to use. This is called view in the world of dojo. Here&#8217;s the example for our view:</p>
<pre name="code" class="js">var view1 = {
	cells: [
		[
			{name: 'Customer_ID', field:'id'},
			{name: 'Given Name', field:'givname'},
			{name: 'Name', field:'surname'},
			{name: 'Job', field:'job'},
			{name: 'Age', field:'age'},
			{name: 'Action', get: linkInGrid}
		]
	]
};</pre>
<p>The property cells contains an array (that why we use square brackets), containing small objects (curly brackets). The property &#8220;name&#8221; of those objects contains the title for the column header, the property &#8220;field&#8221; contains the name field of the data array we&#8217;re going to display.</p>
<p>Lazyness wants us to use global variables so we can access the grid (and the datastore) from all functions and we need a some sample data.</p>
<pre name="code" class="js">var ddata;
var grid;
var store;
var layout = [ view1 ];</pre>
<pre name="code" class="js">var dummydata = { "identifier": 'id',
				   "items":[
				     {	"id": 0,
				     	"givname":"There is",
				      	"surname":"no data ",
				      	"job": "-",
				      	"age": 0}
				   ]
};</pre>
<p>The dojo grid ist very flexible and supports rows, subrows and even subgrids.  The column-layout is defined by the variable &#8220;layout &#8220;(obviously <img src='http://blog.sonores.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ) and we use our just created view for that. The square brackets are mandatory by the way, because we have to use an array again.</p>
<p>The dummy data is usefull in two ways:</p>
<p>1) we can test the grid and exclude the webserver as an error source</p>
<p>2) the sample data is used an a message, that no data has been found. Also the grid only needs to be updated in the future, the creation has been done during the first call of the page.</p>
<p>For the sample data, we need the property &#8220;identifier&#8221; to tell the grid about our dataset&#8217;s primary key (or better: unique identifier)</p>
<p>The property &#8220;items&#8221; contains the datasets in an array.</p>
<p>Following function is going to create the grid:</p>
<pre name="code" class="js">function createGrid(myData) {</pre>
<pre name="code" class="js">	store = new dojo.data.ItemFileReadStore({jsId: 'jsonStore',data: myData});</pre>
<pre name="code" class="js">	ddata = new dojox.grid.data.DojoData(null,store,{jsId: 'model', clientSort: true, query: { id: '*' }});</pre>
<pre name="code" class="js">	grid = new dojox.Grid({id: "OurGrid", model: ddata, onRowMouseOver: keepPopup});</pre>
<pre name="code" class="js">	dojo.byId("gridContainer").appendChild(grid.domNode);</pre>
<pre name="code" class="js">	grid.setStructure(layout);</pre>
<pre name="code" class="js">	grid.startup();
}</pre>
<p>A lot of stuff has been done here, so we better take a close look.</p>
<p><strong>Line 2: </strong><br />
The first thing we do, is to create an ItemFileReadStore using the dojo data model. It gets the javascript id &#8220;jsonStore&#8221; (as I&#8217;ve told you, Dojo likes ids) . For the second parameter we pass our data array &#8211; to keep the function flexible, we use the variable mydata (the parameter in the function call).</p>
<p><strong>Line </strong><strong>3:</strong><br />
Since we now have an ItemFileReadStore, we have to connect it with the grid. The grid knows two ways for the data connection: grid.data.DojoData and grid.data.Table.</p>
<p>Using the table object could be easier: Just pass some sample data without encapsulation in identifier and items. Just plain data, even an ItemFileReadStore isn&#8217;t necessary.</p>
<pre name="code" class="js">// easy but not userful for us...

ddata = new dojox.grid.data.Table(null, dummydaten);</pre>
<p>Well, this is not too hard, but unfortunately not too useful <img src='http://blog.sonores.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  So we have to use DojoData and pass our store to it. The property &#8220;clientSort&#8221;allows the user to sort the data locally with the browser. Looking at the property &#8220;query&#8221; show us it&#8217;s relationship to the database world. We&#8217;re telling the model to collect all unique record sets, using id as a primary key &#8211; somehow a client-side &#8220;SELECT *&#8221;.</p>
<p><strong>Line </strong><strong>4:</strong><br />
Finally we create the grid itself. It gets an Id and we pass the store, as well as the model.</p>
<p><strong>Line </strong><strong>5:</strong><br />
We also have the define the layout und use &#8220;setStructure&#8221; for that.</p>
<p><strong>Line </strong><strong>6:</strong><br />
In part 1  we already defined a placeholder for the grid (that &lt;div&gt;-Container) and here we attach the grid to it.</p>
<p><strong>Line </strong><strong>7:<br />
</strong>At last it&#8217;s time to start the grid. Our just created function might come handy for this task <img src='http://blog.sonores.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<pre name="code" class="js">createGrid(dummydaten);</pre>
<p>Only a little  bit of CSS is needed, we add to our html-file:</p>
<pre name="code" class="css">&lt;style type="text/css"&gt;

 div.gridDiv {

 width: 600px;

 height: 450px;

 }

&lt;/style&gt;</pre>
<p>It is necessary to define the grid&#8217;s width, otherwise nothing is shown &#8211; this is a popular error source by the way.</p>
<p>If we&#8217;ve been good, the following is shown (depending on your language, of course):</p>
<p><img src="http://blog.sonores.de/wp-content/uploads/2008/02/gridtut-step6.JPG" alt="Unser erstes Grid" /></p>
<p>More to come in the next part.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonores.de/2008/03/14/dojo-tutorial-with-a-grid-part-3-english-version/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Dojo Tutorial with a grid: part 2 &#8211; english version</title>
		<link>http://blog.sonores.de/2008/03/05/dojo-tutorial-with-a-grid-part-2-english-version/</link>
		<comments>http://blog.sonores.de/2008/03/05/dojo-tutorial-with-a-grid-part-2-english-version/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 11:34:28 +0000</pubDate>
		<dc:creator>faddie</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[english content]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[Grid]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[XHR]]></category>
		<category><![CDATA[xmlHttprequest]]></category>

		<guid isPermaLink="false">http://blog.sonores.de/2008/03/05/dojo-tutorial-with-a-grid-part-2-english-version/</guid>
		<description><![CDATA[<br/>Here&#8217;s the second part of the dojo tutorial &#8211; covering an AJAX call and the answer from the webserver in PHP. 3.2 Step-2 Create a HTML-Form Let&#8217;s have a closer look at the following code &#60;form name="form_search" id="form_search" action="gridtut_request.php" method="post"&#62; &#60;input type="text" name="txt_name" id="txt_name" value="" dojoType="dijit.form.TextBox" trim="true" propercase="true" /&#62; &#60;input type="submit" id="find" value="Find!" /&#62; &#60;/form&#62; [...]]]></description>
			<content:encoded><![CDATA[<br/><p>Here&#8217;s the second part of the dojo tutorial &#8211; covering an AJAX call and the answer from the webserver in PHP.</p>
<h2><span id="more-165"></span>3.2 Step-2 Create a HTML-Form</h2>
<p>Let&#8217;s have a closer look at the following code</p>
<pre name="code" class="html">&lt;form name="form_search" id="form_search" action="gridtut_request.php" method="post"&gt;

&lt;input type="text"
		name="txt_name"
		id="txt_name"
		value=""
        <strong>dojoType="dijit.form.TextBox"</strong>
        trim="true"
        propercase="true" /&gt; 

&lt;input type="submit" id="find" value="Find!" /&gt;
&lt;/form&gt;

&lt;br /&gt;

&lt;div id="gridContainer" class="gridDiv"&gt;&lt;/div&gt;</pre>
<p>As you can see, we just use a textfield and a search button. Everything looks like we&#8217;re used to (well, except the textfield), and that&#8217;s good because the site is usable without javascript. We only use typical html element like &lt;form&gt; or &lt;input&gt;. When the browser loads the site, the dojo parser looks for the attribute &#8220;dojoType&#8221; (case sensitive) and decides which elements to be included. Dojo calls these elements dijits (Dojo Widgets).</p>
<p>Because those html elements are changed by the dojo parser, you could also use &lt;div&gt; or &lt;span&gt; tags. And it would be even faster, not to parse for html tags, but to generate them directly via Javascript. But in both ways the site wouldn&#8217;t be usable without javascript. And robots would find anything too.</p>
<p>Allright, back to the topic <img src='http://blog.sonores.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  The form is followed by a &lt;div&gt;-Container, which is meant to be a placeholder for the grid.</p>
<p>We&#8217;re done for html, time to see some javascript!</p>
<h2>3.3 Step-3 First javascript</h2>
<p>Up for now, our tutorial looks a little disappointing. The file gridtut.js is totally empty, but we already called the function &#8220;init&#8221; from it, thus creating an error. We&#8217;re going to change that now!</p>
<pre name="code" class="js">// This function is called first</pre>
<pre name="code" class="js">function init() {
	searchbutton = dojo.byId("find");
	// connect the submit button with the proper function
	searchbuttonConnection = dojo.connect(searchbutton, 'onclick', null, my_submit);

}</pre>
<pre name="code" class="js">function my_submit(event) {

 dojo.stopEvent(event);

 alert('Yohoo!');

}</pre>
<p>The function &#8220;init()&#8221; is called by dojo, as soon as the parser finished loading the site. By the way, the more code you have in your html-file, the longer it takes to parse it.</p>
<p>We now use the init-Function to replace the form&#8217;s standard submit with our own custom function. For this, dojo likes to use element ids, not names.</p>
<p>dojo.connect is used to connect the search button and the browser event &#8220;onclick&#8221; with our custom function, the last command &#8220;dojo.stopEvent(event)&#8221; is used to disable the standard submit.</p>
<p>For getting this to work, we need an additional parameter (I used &#8220;event&#8221;) in the parentheses of our new submit function.</p>
<p>Dojo.connects uses the parameter automatically,</p>
<p>Now if we did everything right, we should get an alert with &#8220;Yohoo!&#8221; instead of the submit</p>
<h2>3.4 Step-4 Time for some AJAX.</h2>
<p>Of course we want to use Ajax! Since it is one of the main reasons we use dojo and you can&#8217;t present a new project without it.</p>
<pre name="code" class="js">function my_submit (event) {

  dojo.stopEvent(event);

  var kw = {

    url: "gridtut_request.php",

    load: function(data){

   var result = eval('('+data+')');

  	  alert ("There is some data: " + data);

    },

    error: function(data){

   alert("An error occured: " + data);

    },

    form: "form_search"

  };

  dojo.xhrPost(kw);

}</pre>
<p>Now this looks more complicated than it is.</p>
<p>First of all, KW is just a shortcut for keywords, but you can freely choose a different name.  Most dojo functions accept javascript objects as parameter, so it&#8217;s very convenient to create an object with all needed parameters and pass it to &#8220;dojo.xhrPost&#8221; afterwards.</p>
<p>Here&#8217;s what we need to make an AJAX call.</p>
<p>URL:<br />
Here we specify the location of our dynamic web site. This could also be .jsp or .asp &#8211; I try to keep the php specific part a small as possible.</p>
<p>LOAD:<br />
When the webserver sends a response, this function is being called. Out of laziness I used an anonymous function without an own name. But you&#8217;re free to call a function which is buried somewhere else in the code. <img src='http://blog.sonores.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  The parameter &#8220;data&#8221; contains the responded payload &#8211; for this example a JSON string.</p>
<p>ERROR:<br />
Same as load, if we get an error, this function is being called.</p>
<p>FORM:<br />
The form, we&#8217;re going to transmit (referenced by its id)</p>
<p>All these parameters are now packed in a single object (kw), which we are passing to &#8220;dojo.xhrPost&#8221;.</p>
<p>So what we did now, would have been already possible with pure html: sending a form to the webserver. But much more complicated <img src='http://blog.sonores.de/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /> </p>
<p>Being asynchronous and having error-handling makes the difference. Not to mention, that this code is very expandable.</p>
<h2>3.5 PHP &#8211; Generate some JSON</h2>
<p>For all friends of php, here&#8217;s some code creating a JSON string for us.</p>
<p>JSON, btw. means Javascript Object Notation and is one way, to exchange data between client and server (XML is the other popular way. Actually JSON is just a piece of javascript code which creates a javascript object once it is executed. So our PHP array is going to converted into a construction plan for a javascript object.</p>
<p>Important: The JSON string has to returned by echo, not by return. This is because the string has to be the response of the server.</p>
<pre name="code" class="php">&lt;?php

	// some sample data
	$data = array ();

	$data[] = array ('id' =&gt;1,
					 'surname' =&gt;'Petersen',
					 'givname' =&gt;'Bob',
					 'job' =&gt;'cop',
					 'age' =&gt;32);

	$data[] = array ('id' =&gt;2,
					 'surname' =&gt;'Petersen',
					 'givname' =&gt;'Elvis',
					 'job' =&gt;'dog catcher',
					 'age' =&gt;25);

	$data[] = array ('id' =&gt;3,
					 'surname' =&gt;'Petersen',
					 'givname' =&gt;'Peter',
					 'job' =&gt;'	photographer',
					 'age' =&gt;52);

	$data[] = array ('id' =&gt;4,
					 'surname' =&gt;'Petersen',
					 'givname' =&gt;'Joe',
					 'job' =&gt;'dike reeve',
					 'age' =&gt;61);

	$data[] = array ('id' =&gt;5,
					 'surname' =&gt;'Schröder',
					 'givname' =&gt;'Petra',
					 'job' =&gt;'baker',
					 'age' =&gt;31);

	$data[] = array ('id' =&gt;6,
					 'surname' =&gt;'Schröder',
					 'givname' =&gt;'Elvira',
					 'job' =&gt;'meat salesperson',
					 'age' =&gt;23);

	$data[] = array ('id' =&gt;7,
					 'surname' =&gt;'Schröder',
					 'givname' =&gt;'Martin',
					 'job' =&gt;'cook',
					 'age' =&gt;37);

	// the searchresult
	$result = false;
	// Array counter, since the JSON function need a clearly ordered array from zero on
	$counter = 0;

// main part
if (!empty($_REQUEST['txt_name'])) {

	// search for the data
	foreach ($data as $row =&gt; $value) {
		if ($value['surname'] == html_entity_decode($_REQUEST['txt_name'])){

			// first search hit
			if (!$result) $result = array();

			// put the search result into an array
			$result[$counter]['id'] = $data[$row]['id'];
			$result[$counter]['surname'] = htmlentities($data[$row]['surname']);
			$result[$counter]['givname'] = htmlentities($data[$row]['givname']);
			$result[$counter]['job'] = htmlentities($data[$row]['job']);
			$result[$counter]['age'] = $data[$row]['age'];
			$counter++;
		}
	}

	// empty search result
	if (!$result) $result[] = array ('id' =&gt;0,
					'surname'=&gt;'found',
					'givname'=&gt;'No data',
					'job' =&gt;' ',
					'age' =&gt;0);

        $temp = Array ('identifier'=&gt;'id', 'items'=&gt;$result);
	echo json_encode($temp);

}
?&gt;</pre>
<p>So we&#8217;re searching for the given name and return the result as JSON. Of course this looks a little different in jsp or asp.</p>
<p>It&#8217;s good to know, that PHP&#8217;s JSON function can&#8217;t handle foreign characters, so I convert everything html entities (auml instead of ä).</p>
<p>If you start a new project (or are already using it), converting to UTF-8 makes your dojo life a lot easier. Unfortunately I still have to work with ISO-885-91.</p>
<p>Here&#8217;s how a JSON string should look like (having searched for Petersen):</p>
<pre name = "code" class="js">{"identifier":"id","items":[{"id":1,"surname":"Petersen","givname":"Bob","job":"cop","age":32},{"id":2,"surname":"Petersen","givname":"Elvis","job":"dog catcher","age":25},{"id":3,"surname":"Petersen","givname":"Peter","job":"\tphotographer","age":52},{"id":4,"surname":"Petersen","givname":"Joe","job":"dike reeve","age":61}]}</pre>
<p>I you don&#8217;t have a webserver handy, you can also copy and paste this string to a textfile and using it as the response.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonores.de/2008/03/05/dojo-tutorial-with-a-grid-part-2-english-version/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dojo Tutorial with a grid: part 1 &#8211; english version</title>
		<link>http://blog.sonores.de/2008/02/29/dojo-tutorial-with-a-grid-part-1-english-version/</link>
		<comments>http://blog.sonores.de/2008/02/29/dojo-tutorial-with-a-grid-part-1-english-version/#comments</comments>
		<pubDate>Fri, 29 Feb 2008 08:53:30 +0000</pubDate>
		<dc:creator>faddie</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[english content]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[Grid]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[XHR]]></category>
		<category><![CDATA[xhttprequest]]></category>

		<guid isPermaLink="false">http://blog.sonores.de/2008/02/29/dojo-tutorial-with-a-grid-part-1-english-version/</guid>
		<description><![CDATA[<br/>Hi there, this tutorial is about the dojo toolkit and how to generate a grid. Since I haven&#8217;t found a guide which covers all the basics from including dojo, over AJAX to server-side communication, I&#8217;ve decided to write it myself. Okay then, let&#8217;s start. 1. Ingredients We&#8217;re going to need 3 to 4 files: a [...]]]></description>
			<content:encoded><![CDATA[<br/><p><img src="http://blog.sonores.de/wp-content/uploads/2008/02/dojo.thumbnail.gif" alt="Dojo Toolkit Logo" /> Hi there, this tutorial is about the dojo toolkit and how to generate a grid. Since I haven&#8217;t found a guide which covers all the basics from including dojo, over AJAX to server-side communication, I&#8217;ve decided to write it myself.</p>
<p>Okay then, let&#8217;s start.</p>
<p><span id="more-161"></span></p>
<h1>1. Ingredients</h1>
<p>We&#8217;re going to need 3 to 4 files:</p>
<ul>
<li>a HTML file</li>
<li>a javascript file for organization and code seperation</li>
<li>a dynamic web language file (I&#8217;m only good at PHP) for the data to be loaded into the grid</li>
<li>optional: a html-Datei for a popup</li>
</ul>
<p>Furthermore need the current version of the dojo toolkit (v.1.02). Also friends of IE better fetch a nightly build, but don&#8217;t worry, we&#8217;ll do that together.</p>
<p>btw. As dojo 1.1 is released, you won&#8217;t need the nightly build anymore</p>
<h2>2. Preparation</h2>
<h2>2.1 Download dojo</h2>
<p>Here&#8217;s the download 
<a  href="http://dojotoolkit.org/downloads" title="Dojotoolkit download" target="_blank" onclick="javascript:pageTracker._trackPageview('/external/dojotoolkit.org/downloads');" >&lt;klick&gt;</a>. If version 1.02 is still the current version, we need a nightly build in order to deal with some nasty bugs (grid&#8217;s not shown in IE): 
<a  href="http://archive.dojotoolkit.org/nightly/" title="Dojotoolkit nightly build download" target="_blank" onclick="javascript:pageTracker._trackPageview('/external/archive.dojotoolkit.org/nightly/');" >&lt;klick&gt;</a>.</p>
<h2>2.2 Folderstructure</h2>
<p>First we create a main folder, which is accessible to Apache (or iis).</p>
<p>We extract the dojo&#8217;s archive in a sub folder, e.g.  dojotoolkit-release-1.0.2.</p>
<p>It has proven itself in practice (okay, in my practise <img src='http://blog.sonores.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ) to keep the release number in the foldername. So if you want to switch the release later on, it much easier to manage.</p>
<p>Now extract the nightly build somewhere else and copy the folder called dojox into the dojotoolkit-release-1.0.2 folder. That&#8217;s how it looks like:</p>
<pre>/gridtutorial</pre>
<pre>|---+ dojo-release-1.0.2</pre>
<pre>       |--- dijit</pre>
<pre>       |--- dojo</pre>
<pre>       |--- dojox <em>   (from the nightly build)</em></pre>
<pre>       |--- util</pre>
<p>Let&#8217;s create our 4 file then:</p>
<p>gridtut.html</p>
<p>gridtut.js</p>
<p>gridtut_request.php</p>
<p>gridtut_pop.html</p>
<p>Okay,  popups are clearly out of style and the dojo.dialog would be a very nice replacement, but a big challenge is to integrate dojo into existing projects. Furthermore, this is example should be still usable without javascript.</p>
<h1>3.1 Step-1  Setup Dojo</h1>
<p>I think it&#8217;s time to see some code <img src='http://blog.sonores.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I suppose, everybody knows how to create a HTML file, so we start directly including dojo to our site.</p>
<p>First, we nees CSS files for the &lt;head&gt; Tag:</p>
<pre name="code" class="html">&lt;link rel="stylesheet" href="./dojo-release-1.0.2/dijit/themes/tundra/tundra.css" type="text/css"&gt;

&lt;link rel="stylesheet" href="./dojo-release-1.0.2/dojo/resources/dojo.css" type="text/css"&gt;

&lt;link rel="stylesheet" href="./dojo-release-1.0.2/dojox/grid/_grid/tundraGrid.css" type="text/css"&gt;</pre>
<p>Hereby we&#8217;ve defined the look of all dojo widgets.. err dijits. In order to have the grid look like the rest, we also include tundraGrid.css.</p>
<p>Second, we include dojo itself as javascript files.</p>
<pre name="code" class="html">&lt;script type="text/javascript" src="./dojo-release-1.0.2/dojo/dojo.js"

 djConfig="parseOnLoad: true,debugAtAllCosts: true"&gt;&lt;/script&gt;</pre>
<p>All depending files are included by dojo itself, but we have some parameters to configure:</p>
<pre>parseOnLoad - in order to create dojo widgets by html markup, we need a parser</pre>
<pre>debugAtAllCosts - for development, debugging can't be wrong, although you should disable it in a production environment</pre>
<p>The next things is to tell dojo, what modules we&#8217;re going to use for our example.</p>
<pre name="code" class="js">&lt;script  type="text/javascript"&gt;

 dojo.require('dojo.parser');

 dojo.require("dojo.data.ItemFileReadStore");

 dojo.require('dijit.form.Button');

 dojo.require("dijit.form.TextBox");

 dojo.require("dijit.form.NumberTextBox");

 dojo.require("dijit.form.FilteringSelect");

 dojo.require("dojox.grid.Grid");

 dojo.require("dojox.grid._data.model");

&lt;/script&gt;</pre>
<p>Unfortunately this portion of javascript cannot be included in the .js file we reserved for that, otherwise the path for inclusion of those files gets messed up.  You can already see, that we&#8217;re also cover some form dijits later on</p>
<p>The final part:</p>
<pre name="code" class="html">&lt;script type="text/javascript" src="gridtut.js"&gt;&lt;/script&gt;</pre>
<pre name="code" class="html">&lt;script type="text/javascript"&gt;

 dojo.addOnLoad(init);

&lt;/script&gt;</pre>
<p>Okay, we&#8217;re ready. The order of those ports is quit important, by the way. The file gridtut.js is going to contain the function &#8220;addOnLoad&#8221; and so we can only call the function after it has been loaded.</p>
<p>So, that&#8217;s it for the first part. Thanks for reading.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonores.de/2008/02/29/dojo-tutorial-with-a-grid-part-1-english-version/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Dojo Tutorial with a grid &#8211; english version</title>
		<link>http://blog.sonores.de/2008/02/29/dojo-tutorial-with-a-grid-english-version/</link>
		<comments>http://blog.sonores.de/2008/02/29/dojo-tutorial-with-a-grid-english-version/#comments</comments>
		<pubDate>Fri, 29 Feb 2008 07:34:19 +0000</pubDate>
		<dc:creator>faddie</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[english content]]></category>
		<category><![CDATA[Dojo tutorial grid english]]></category>

		<guid isPermaLink="false">http://blog.sonores.de/2008/02/29/dojo-tutorial-with-a-grid-english-version/</guid>
		<description><![CDATA[<br/>UNDER CONSTRUCTION This tutorial is separated into six parts and is going to explain how to setup dojo, fill a grid from the server side and open popups from the grid. In addition the site is kept usable without javascript. Here&#8217;s an example how it should look like. If this is not what you&#8217;ve been [...]]]></description>
			<content:encoded><![CDATA[<br/><p><strong>UNDER CONSTRUCTION</strong></p>
<p>This tutorial is separated into six parts and is going to explain how to setup dojo, fill a grid from the server side and open popups from the grid. In addition the site is kept usable without javascript.</p>
<p>Here&#8217;s an example how it should look like. If this is not what you&#8217;ve been looking for, there&#8217;s still time to leave <img src='http://blog.sonores.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>
<a  href="http://www.sonores.de/dojo_tutorial/gridtut_en/gridtut.html" title="Dojo Tutorial Demo" target="_blank" onclick="javascript:pageTracker._trackPageview('/external/www.sonores.de/dojo_tutorial/gridtut_en/gridtut.html');" >http://www.sonores.de/dojo_tutorial/gridtut_en/gridtut.html</a><br />
(search for Petersen or Schröder if you have that char)</p>
<p>I tried to keep the tutorial very common, so that you don&#8217;t need much dojo experience. However a glimpse into the documentation won&#8217;t hurt you.<br />

<a  href="http://dojotoolkit.org/book/dojo-book-1-0" title="Dojo Book 1.0" target="_blank" onclick="javascript:pageTracker._trackPageview('/external/dojotoolkit.org/book/dojo-book-1-0');" >http://dojotoolkit.org/book/dojo-book-1-0</a></p>
<p>Here&#8217;s the result of what the code will look like after the tutorial (dojo has still to be downloaded), the code is fully commented (and translated <img src='http://blog.sonores.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  )</p>
<p>
<a  href="http://blog.sonores.de/wp-content/uploads/2008/02/gridtut_en.zip" title="Grid Tutorial en" onclick="javascript:pageTracker._trackPageview('/downloads/wp-content/uploads/2008/02/gridtut_en.zip');" >Grid Tutorial en.zip</a></p>
<p>But now enjoy the show</p>
<p><span id="more-160"></span></p>
<p>Part 1:<br />
We&#8217;ll cover the basics here: downloading dojo and including it into our site<br />

<a  href="http://blog.sonores.de/2008/02/01/dojo-tutorial-mit-grid/">http://blog.sonores.de/2008/02/29/dojo-tutorial-with-a-grid-part-1-english-version/ </a></p>
<p>Part 2:<br />
We&#8217;ll create a form and connect the HTML-Elements with the event-system. After that we talk to the server via AJAX and let it answer in JSON (done in PHP)<br />

<a  href="http://blog.sonores.de/2008/02/11/dojo-tutorial-mit-grid-teil-2/">http://blog.sonores.de/2008/03/05/dojo-tutorial-with-a-grid-part-2-english-version/</a></p>
<p>Part 3:<br />
Now we put some sample data into the grid (and create it before that)<a href="http://blog.sonores.de/2008/03/14/dojo-tutorial-with-a-grid-part-3-english-version/"></p>
<p>http://blog.sonores.de/2008/03/14/dojo-tutorial-with-a-grid-part-3-english-version/</a></p>
<p>Part 4:<br />
Having the sampledata shown in the grid, it&#8217;s time to populate it with server-side data. Also we try to avoid problems with foreign characters and AJAX<br />
(not translated yet)<a href="http://blog.sonores.de/2008/02/12/dojo-tutorial-mit-grid-teil-4/"></p>
<p>http://blog.sonores.de/2008/02/12/dojo-tutorial-mit-grid-teil-4/</a></p>
<p>Part 5:<br />
We add an activity-indicator and make use of the event system&#8217;s listener-conecpt.<br />
(not translated yet)<a href="http://blog.sonores.de/2008/02/13/dojo-tutorial-mit-grid-teil-5-events/"></p>
<p>http://blog.sonores.de/2008/02/13/dojo-tutorial-mit-grid-teil-5-events/</a></p>
<p>Part 6:<br />
Last but not least we generate links with grid&#8217;s get-function<br />
(not translated yet)<a href="http://blog.sonores.de/2008/02/13/dojo-tutorial-mit-grid-teil-6-links-im-grid/"></p>
<p>http://blog.sonores.de/2008/02/13/dojo-tutorial-mit-grid-teil-6-links-im-grid/</a></p>
<p>Part 6 1/2:<br />
In order to keep our example working with PHP &lt; 5.2.0. here&#8217;s the solution<br />
(not translated yet)<br />

<a  href="http://blog.sonores.de/2008/02/13/dojo-tutorial-mit-grid-teil-6-12-json-mit-php-4/"> http://blog.sonores.de/2008/02/13/dojo-tutorial-mit-grid-teil-6-12-json-mit-php-4/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sonores.de/2008/02/29/dojo-tutorial-with-a-grid-english-version/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

