<?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>Jair Rillo Junior's blog</title>
	<atom:link href="http://www.jairrillo.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jairrillo.com/blog</link>
	<description>Articles and tutorials about technology</description>
	<lastBuildDate>Mon, 25 Jul 2011 16:50:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>IOS &#8211; Object C OO principles. Class, Interface, Instance Variables and Methods</title>
		<link>http://www.jairrillo.com/blog/2011/07/06/ios-object-c-oo-principles-class-interface-instance-variables-and-methods/</link>
		<comments>http://www.jairrillo.com/blog/2011/07/06/ios-object-c-oo-principles-class-interface-instance-variables-and-methods/#comments</comments>
		<pubDate>Wed, 06 Jul 2011 15:13:49 +0000</pubDate>
		<dc:creator>Jair Rillo Junior</dc:creator>
				<category><![CDATA[IOS]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[Instance Variables]]></category>
		<category><![CDATA[Interface]]></category>
		<category><![CDATA[Methods]]></category>
		<category><![CDATA[Object C]]></category>

		<guid isPermaLink="false">http://www.jairrillo.com/blog/?p=829</guid>
		<description><![CDATA[This is the second post about IOS that I am writing out. You can read the first one over here. In this post I am going to talk about Object-C object oriented principles, such as: classes, interfaces, instance variables and methods. This is an important topic in object-c, therefore I advice you to read this [...]]]></description>
			<content:encoded><![CDATA[<p>This is the second post about IOS that I am writing out. You can read the first one <a href="http://www.jairrillo.com/blog/2011/06/18/getting-started-with-ios-binding-user-interface-and-controller/">over here</a>.<br />
In this post I am going to talk about Object-C object oriented principles, such as: classes, interfaces, instance variables and methods. This is an important topic in object-c, therefore I advice you to read this post carefully.</p>
<h3>Interfaces</h3>
<p>As you should know, Object-C is Object Oriented. In any OO language, we can use interface implicitly or explicitly.<br />
In Object-C the interface is implemented in a separated file with extension .h (header) and lives together with a class. To create an interface/class in XCode, simply right mouse click on Classes folder -> Add -> New File. On the new window, select Object-C class and subclass NSObject:<br />
<a href="http://www.jairrillo.com/blog/wp-content/uploads/2011/07/new_class.png" target="_blank"><img src="http://www.jairrillo.com/blog/wp-content/uploads/2011/07/new_class-150x150.png" alt="" title="new_class" width="150" height="150" class="alignnone size-thumbnail wp-image-837" /></a>.<br />
XCode is going to create two files, an interface (.h) and the class (.m).<br />
Let&#8217;s see an interface example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &lt;Foundation/Foundation.h&gt;</span>
&nbsp;
<span style="color: #a61390;">@interface</span> Shape <span style="color: #002200;">:</span> <span style="color: #400080;">NSObject</span> <span style="color: #002200;">&#123;</span>
<span style="color: #a61390;">@private</span>
	<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>color;
	CGPoint <span style="color: #002200;">*</span>position;
<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setColor<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>aColor;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>drawShape;
<span style="color: #a61390;">@end</span></pre></td></tr></table></div>

<p>Let&#8217;s study the code above.<br />
First of all, the interface has the directive @interface and <strong>ONLY</strong> on it we can create inheritance. In the example above, our interface Shape inherits from NSObject.<br />
<em>Note: 1 &#8211; Other languages, such as Java and C#, the inheritance occurs in the class. In Object C, only the interface has inheritance. 2 &#8211; NSObject is the most common object from Cocoa Touch Framework.</em><br />
In the interface, we have the #import statement. In our example, we imported the Foundation.h interface that belongs to Cocoa framework.<br />
Another weird behavior: Instance variables can be only defined in the interface and inside the { } signs. In our example, there are two instance variables (color and position). Also, both instance variables have the private visibility, in other words, nobody can access these variables outside of this interface/class.<br />
Finally, the method signature is defined outside the { } signs. Our example has two methods. </p>
<h3>Class</h3>
<p>A class, also known as implementation in object-c, has the extension <strong>.m</strong>. It implements all methods from its interface. See the example below:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &quot;Shape.h&quot;</span>
<span style="color: #a61390;">@implementation</span> Shape
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setColor<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>aColor <span style="color: #002200;">&#123;</span>
	color <span style="color: #002200;">=</span> aColor;
<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>drawShape <span style="color: #002200;">&#123;</span>
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Drawing a shape...&quot;</span><span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span>
<span style="color: #a61390;">@end</span></pre></td></tr></table></div>

<p>The implementation has the @implementation directive and imports the interface through #import &#8220;Shape.h&#8221; line. Different from other languages, if you do not implement ALL methods on the class, there will not be a compiler error.<br />
As you can see, the class does not have the { } signs and instance variables definitions. Also, there is no inheritance. All of this behaviors are implemented in the interface.</p>
<h3>Instance Variables</h3>
<p>As already said, instance variables are defined in the interface and within the { } signs. Another important point here is the pointer sign (*). ALL instance variables must be defined as a pointer. Also, all instance variables go to memory HEAP when created (we&#8217;ll see how it works in this post yet).<br />
Within the { } signs we also define the visibility. By default, the visibility is <strong>protected</strong>, but in OO, usually we define the instance variables as private and we use some methods to access those variables. If you have no idea what private, protected or public are, please, google about Object Oriented Visibility.</p>
<h3>Methods</h3>
<p>Certainly it is the weirdest thing in this topic. We&#8217;ve already showed two methods examples:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setColor<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>aColor;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>drawShape;</pre></td></tr></table></div>

<p>The first one receives a parameter and the second has no parameter. To define a parameter for a method, we use the following syntax: method name : (parameter type) parameter name; Weird? not so far, but what about multiples parameters? Let&#8217;s see another example from a war game:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>shipsAtPoint<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGPoint <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>bombLocation withDamage<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>damaged;</pre></td></tr></table></div>

<p>What&#8217;s the method name? How many parameters do we have? Looks like method&#8217;s name and parameters are messed up, right?. Yes, that&#8217;s right, you put the parameters inside the method name and read it directly. Thus the method&#8217;s name above is <strong>shipsAtPointWithDamage</strong> and it has <strong>two</strong> parameters.<br />
The most languages has the full method name and then the parameters split by comma, like example below in Java:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> AnyObject<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> shipsAtPointWithDamage<span style="color: #009900;">&#40;</span>CGPoint point, <span style="color: #003399;">Boolean</span> damaged<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>What about four parameters?</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>splitViewController<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UISplitViewController <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> svc 
	willHideViewController<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIViewController <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> aViewController 
	withBarButtonItem<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIBarButtonItem <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> barButtonItem 
	forPopoverController<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIPopoverController <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> popoverController;</pre></td></tr></table></div>

<p>Man, that&#8217;s really weird. Honestly, I did not get used with this syntax yet.<br />
Finally, let&#8217;s talk about the minus sign.<br />
Minus sign means that the methods are instance methods, in other words, it can access the instance variables. Plus means that the methods are class methods. It cannot access instance variables. Usually used for global methods. You do not need a class instance to access it (Similar, but not identical, to static in Java).</p>
<h3>Instantiating a Class</h3>
<p>Probably you already heard this phrase: Object is a class instantiated. But how can we instantiate a class in object-c?<br />
Usually we use a couple of methods: alloc and init. See example below:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;">shape <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>Shape alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>

<p>Do not worry about [ ] yet. Just see the alloc and init methods. To create an object, we must alloc it in the HEAP memory. It is done through the alloc message. Also, we need to initiate it. It is done through a method that starts with the first four letters &#8220;init&#8221;. It&#8217;s common see an init method called: initWithAnyValue&#8230;<br />
Init works like constructor of languages such as Java and C#.</p>
<h3>Sending message to a method</h3>
<p>Unlike Java or plain C, Objective-C works with messages. You don&#8217;t invoke a method on an object, instead, you send a message to it (like the Ruby language). Supposing our example SHAPE, we have the object shape (it&#8217;s the receiver) and we want to send a message to it to <strong>draw</strong> something (remember, we&#8217;ve got a draw method).</p>
<pre language="objc" line="1">
[shape drawShape];
</pre>
<p>You send messages inside the brackets [ ].<br />
What about the code below?</p>
<pre language="objc" line="1">
[shape transform]
</pre>
<p>We do not have the method transform, so we&#8217;ll get a compiler error, right? No, because we are not invoking a method to an object, we are sending a message to an object (or receiver). In this case, the message is &#8220;transform&#8221;, but we do not have the transform method, thus, the compiler will show up a warning, but not an error. (carefully with this behavior).</p>
<h3>Hands on</h3>
<p>Let&#8217;s create a simple example to practice the class creation, inheritance, instance variables and method. Actually, I&#8217;m not going to show up step-by-step, instead, I&#8217;m going to tell you what the exercise is and you&#8217;ll do it yourself alone (hopefully). In the end of this topic, there&#8217;s a link to download the exercise done. (Promise that you&#8217;ll download the exercise just for conference).<br />
The exercise looks simple. First: create more two classes (Circle and Rectangle) that inherits from Shape. Both classes must implement the drawShape method and print out the string &#8220;Circle or Rectangle&#8221;, also, first print out the content of the drawShape from superclass. To print out a content, use the NSLog method like the drawShape example.<br />
Note: To call a method in the superclass, send a message to it using [super drawShape];<br />
Create an User Interface that has two buttons (Circle and Rectangle). Each on acts a different method on the Controller. The controller instantiates the Circle or Rectangle class and call the drawShape method.<br />
To see the output of NSLog inside the Xcode, go to menu <strong>Run</strong> -> <strong>Console</strong>. A new window will be opened. Now, let&#8217;s get started.</p>
<h3>Conclusion</h3>
<p>Although there are many things to say about class, interface, instance variables and methods, I guess this topic is a good starting point. I advice you, look at Mac Developers site about these topics and read the official documentation carefully. Also, there&#8217;re many blogs on the web that talks about object-c.</p>
<p>The next topic we&#8217;re going to talk a little more about instance variables and methods. Actually, we&#8217;re going to talk about the @property and @synthesize directives. Also, we&#8217;re going to talk about another important concept: Dot Operation.</p>
<p>If you have any question, fell free to leave your comment below.</p>
<p><a href="http://www.jairrillo.com/files/ObjectCOOPrinciples.zip">Download the exercise here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jairrillo.com/blog/2011/07/06/ios-object-c-oo-principles-class-interface-instance-variables-and-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>android:onClick &#8211; Binding a UI directly to Controller.</title>
		<link>http://www.jairrillo.com/blog/2011/06/27/androidonclick-binding-a-ui-directly-to-controller/</link>
		<comments>http://www.jairrillo.com/blog/2011/06/27/androidonclick-binding-a-ui-directly-to-controller/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 02:00:33 +0000</pubDate>
		<dc:creator>Jair Rillo Junior</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.jairrillo.com/blog/?p=820</guid>
		<description><![CDATA[If you&#8217;re familiar with Android, probably you have already created a button on the user interface and implemented a controller method to respond to this button&#8217;s action. This can be done through the OnClickListener interface and its onClick(View) method. A example below: 1 2 3 4 5 6 7 8 9 10 11 12 13 [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re familiar with Android, probably you have already created a button on the user interface and implemented a controller method to respond to this button&#8217;s action. This can be done through the OnClickListener interface and its onClick(View) method. A example below:</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
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TesteApp <span style="color: #000000; font-weight: bold;">extends</span> Activity <span style="color: #000000; font-weight: bold;">implements</span> OnClickListener <span style="color: #009900;">&#123;</span>
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onCreate<span style="color: #009900;">&#40;</span>Bundle savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span><span style="color: #009900;">&#40;</span>savedInstanceState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        setContentView<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">layout</span>.<span style="color: #006633;">main</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">View</span> view <span style="color: #339933;">=</span> findViewById<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">button1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        view.<span style="color: #006633;">setOnClickListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onClick<span style="color: #009900;">&#40;</span><span style="color: #003399;">View</span> v<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    	<span style="color: #666666; font-style: italic;">//Implements the action over here.</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>On line 1, we used OnClickListener interface. This interface provides us the onClick(View) method. Also, on line 6 and 7, we set up the Listener to the Button widget.<br />
Since Android version 1.6 (API level 4), Android offers us an android:onClick UI Method. Using this approach, you do not need to implement the OnClickListener interface and also you do not need to implement the static onClick(View) method. Rather than, you can bind the android:onClick method directly to a method on the Activity. See the example below:<br />
<strong>User Interface &#8211; main.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;Button</span> <span style="color: #000066;">android:text</span>=<span style="color: #ff0000;">&quot;Click me&quot;</span> <span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/button1&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span> <span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span> <span style="color: #000066;">android:onClick</span>=<span style="color: #ff0000;">&quot;buttonPressed&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/Button<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>In the UI above, we set up the onClick to a method called <em>buttonPressed</em>.<br />
<strong>Java class &#8211; Activity</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TesteApp <span style="color: #000000; font-weight: bold;">extends</span> Activity <span style="color: #009900;">&#123;</span>
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onCreate<span style="color: #009900;">&#40;</span>Bundle savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span><span style="color: #009900;">&#40;</span>savedInstanceState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        setContentView<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">layout</span>.<span style="color: #006633;">main</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> buttonPressed<span style="color: #009900;">&#40;</span><span style="color: #003399;">View</span> v<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    	<span style="color: #666666; font-style: italic;">//Implements the action over here.</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>As you can see, the Activity above does not implement the OnClickListener. Also, the widget does not need to set up its Listener pragmatically. This way you write less code and your class get cleaner.</p>
<p>As far as I know, both ways work similar. There&#8217;s no performance issue or anything else. However the OnClickListener interface provides more methods than onClick. So, if you only need the onClick function, I advice you to use the android:onClick. If you need anything else, I advice you to implement the OnClickListener interface.</p>
<p>If you have any question, fell free to leave your comment below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jairrillo.com/blog/2011/06/27/androidonclick-binding-a-ui-directly-to-controller/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Getting Started with IOS &#8211; Binding User Interface and Controller</title>
		<link>http://www.jairrillo.com/blog/2011/06/18/getting-started-with-ios-binding-user-interface-and-controller/</link>
		<comments>http://www.jairrillo.com/blog/2011/06/18/getting-started-with-ios-binding-user-interface-and-controller/#comments</comments>
		<pubDate>Sat, 18 Jun 2011 14:21:23 +0000</pubDate>
		<dc:creator>Jair Rillo Junior</dc:creator>
				<category><![CDATA[IOS]]></category>
		<category><![CDATA[Interface Builder]]></category>
		<category><![CDATA[Ipad]]></category>
		<category><![CDATA[Iphone]]></category>
		<category><![CDATA[Ipod]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.jairrillo.com/blog/?p=780</guid>
		<description><![CDATA[If you want to build Iphone,IPad or IPod touch applications, this can be a start pointing for you. I&#8217;m gonna write a series of posts about IOS as long as I am studying this platform. For a complete material, take a look at the apple&#8217;s developer area. In this first post, I&#8217;m gonna show you [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to build Iphone,IPad or IPod touch applications, this can be a start pointing for you.<br />
I&#8217;m gonna write a series of posts about IOS as long as I am studying this platform. For a complete material, take a look at the apple&#8217;s developer area.<br />
In this first post, I&#8217;m gonna show you how to get started with IOS, such as: showing the pre-requirements, downloading the tools and finally a simple example binding the User Interface (UI) and the controller (Object-c classes).</p>
<h3>Pre Requirement</h3>
<p>First of all, if you wanna build applications using IOS, you <strong>MUST</strong> have a MAC computer.<br />
For coding and designing, we&#8217;re gonna use the following tools: Xcode for coding and Interface Builder for designing. Basically you can choices either <a href="http://tinyurl.com/4jbngle" target="_blank">Xcode 3.2.6 for free</a> or <a href="http://tinyurl.com/5r4auez" target="_blank">Xcode 4.0 Free for Mac Developer</a> or purchase it from AppStore. In both, one single download will get Xcode and Interface Builder (Xcode 4 brings Interface Builder integrated within Xcode). In this topic, I&#8217;m gonna use version 3.2.6.<br />
Real Iphone, Ipad or IPod touch is not required, because Xcode has an emulator inside it. Furthermore, if you want to deploy your application on a real device, you must become a Mac Developer, otherwise you will test your application only on the emulator.</p>
<h3>Concepts</h3>
<p>IOS uses object-c as programming language. It is an OO language, but its structure looks weird for whom comes from another OO language such Java. Also, Object-C has some features similar to C and C++, such as: pointer, memory management and so on.<br />
By default, IOS uses the Cocoa Touch Framework. It&#8217;s obvious that all my posts are gonna talk just about this framework.<br />
IOS programming is based on MVC pattern (model &#8211; view &#8211; controller). If you have no idea what it is, please, google it.</p>
<h3>Creating a new project</h3>
<p>Click on Xcode icon to launch Xcode. Yo&#8217;re gonna see a splash screen like below:<br />
<a href="http://www.jairrillo.com/blog/wp-content/uploads/2011/06/splash_screen.png"><img class="alignnone size-medium wp-image-787" title="splash_screen" src="http://www.jairrillo.com/blog/wp-content/uploads/2011/06/splash_screen-300x196.png" alt="" width="300" height="196" /></a><br />
Choose the &#8220;Create a new Xcode Project&#8221;. On the next screen, choose &#8220;View Based Application&#8221; and click on Choose button. For this example, I have chosen the name &#8220;Class1&#8243; as project name.<br />
After these steps, the Xcode will be opened and some default files created. Image below show up the Xcode interface and the project files.<br />
<a href="http://www.jairrillo.com/blog/wp-content/uploads/2011/06/xcode_interface.png"><img class="alignnone size-thumbnail wp-image-789" title="xcode_interface" src="http://www.jairrillo.com/blog/wp-content/uploads/2011/06/xcode_interface-150x150.png" alt="" width="150" height="150" /></a><br />
For this post, we&#8217;re gonna work on in the following files: <em>Class1ViewController.h</em>, <em>Class1ViewController.m</em> and <em>Class1ViewController.xib</em>. Class1 is the name of my project, because of this Xcode has created the classes using this Class1* nomenclature.</p>
<h3>Editing the interface and implementations</h3>
<p>When you start a new application, you can start by different parts of the software. Someone prefer starting by the model, other by designing and so on. Usually I like starting by model, but for this example I&#8217;ll start by designing the UI. Thus, the first task to do is to create the objects within the Controller that will represent the UI widgets.<br />
Our first application is gonna be really simple. There will be one TextField where the user can put his name, a button to submit an action and a label that will print the name of the user. So, let&#8217;s get started it.</p>
<p>Open up the Class1ViewController.h file. It is the interface file. Write the following lines of code.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">#import 
&nbsp;
@<span style="color: #000000; font-weight: bold;">interface</span> Class1ViewController <span style="color: #339933;">:</span> UIViewController <span style="color: #009900;">&#123;</span>
	IBOutlet UITextField <span style="color: #339933;">*</span>fieldName<span style="color: #339933;">;</span>
	IBOutlet UILabel <span style="color: #339933;">*</span>displayName<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>IBAction<span style="color: #009900;">&#41;</span> submitPressed<span style="color: #339933;">;</span>
@end</pre></div></div>

<p>Different from other languages, such as Java, the interface is the unique local where you can define your instance variables (inside the { }). Everything out from { } are method signature. We&#8217;re gonna talk about interface, classes, methods and attribute in another post.<br />
In the code above, the important is to see that we have two instance variables that represent a TextField and Label from User Interface. Furthermore, there is a method called submitPressed. Note: both attributes uses pointer as well as all objects in Object-C must use too.<br />
What about IBOutlet and IBAction? Both are empty object that Interface Build can recognize them. Without this objects, would be impossible to binding the UI widget with our controller.</p>
<h3>Building Interface</h3>
<p>Before implement the controller (we just coded the controller&#8217;s interface), let&#8217;s draw our interface using Interface Builder. To do that, double click on Class1Controller.xib file. Interface Builder will be launched.<br />
<a href="http://www.jairrillo.com/blog/wp-content/uploads/2011/06/xcode_interface1.png"><img class="alignnone size-thumbnail wp-image-794" title="xcode_interface1" src="http://www.jairrillo.com/blog/wp-content/uploads/2011/06/xcode_interface1-150x150.png" alt="" width="150" height="150" /></a><br />
As you can see, some windows are opened. The Library window contains the UI widgets. The View window is the place where you are gonna draw the interface. Class1ViewController.xib window is where the bind occurs, as well as the View Attributes window is where you can change the UI widget behavior.<br />
Let&#8217;s create a screen using only the UITextField, UILabel and UIButton. Look at the image below:<br />
<a href="http://www.jairrillo.com/blog/wp-content/uploads/2011/06/screen.png"><img class="alignnone size-thumbnail wp-image-795" title="screen" src="http://www.jairrillo.com/blog/wp-content/uploads/2011/06/screen-150x150.png" alt="" width="150" height="150" /></a><br />
As I said, really simple.</p>
<h3>Binding the UI widgets and the Controller&#8217;s object</h3>
<p>This section is the main goal of the post. If you are familiar with Android, you&#8217;re gonna see that IOS is simpler than Android for binding.<br />
First, on Class1ViewController.xib window, click and hold the &#8220;File&#8217;s Owner&#8221; icon, hold Control button and go to the UITextField widget. A blue arrow will appear. When you release the mouse and control button, a pop-up will appear with the available options for binding. Choose the attribute &#8220;fieldName&#8221;.<br />
Repeat the process for the UILabel &#8220;Your name is&#8221; and binding it to the attribute &#8220;displayName&#8221;.<br />
<a href="http://www.jairrillo.com/blog/wp-content/uploads/2011/06/screen2.png"><img class="alignnone size-thumbnail wp-image-797" title="screen2" src="http://www.jairrillo.com/blog/wp-content/uploads/2011/06/screen2-150x150.png" alt="" width="150" height="150" /></a><br />
We do not have a attribute for the Submit button, however we have a method signature. Thus, we binding a button with its action, in this case, a method.<br />
Simply repeat the process, however clicking first in the button Submit and then go to the File&#8217;s owner.<br />
<a href="http://www.jairrillo.com/blog/wp-content/uploads/2011/06/class1viewcontroller.png"><img class="alignnone size-thumbnail wp-image-798" title="class1viewcontroller" src="http://www.jairrillo.com/blog/wp-content/uploads/2011/06/class1viewcontroller-150x150.png" alt="" width="150" height="150" /></a><br />
After that, the binding between the UI and the Controller is done.</p>
<h3>Implementing the Controller</h3>
<p>Now it is time to implement our controller. Open up the Class1ViewController.h file and implement the method &#8220;submitPressed&#8221; like code below:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">#import <span style="color: #0000ff;">&quot;Class1ViewController.h&quot;</span>
&nbsp;
@implementation Class1ViewController
<span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>IBAction<span style="color: #009900;">&#41;</span> submitPressed
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//Get the text from UIText</span>
	NSString <span style="color: #339933;">*</span>yourName <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>fieldName text<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//Prepare a static phrase</span>
	NSString <span style="color: #339933;">*</span>staticPhrase <span style="color: #339933;">=</span> @<span style="color: #0000ff;">&quot;Your name is: &quot;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//Put the staticPrase + yourName in the UILabel content</span>
	<span style="color: #009900;">&#91;</span>displayName setText<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>staticPhrase stringByAppendingString<span style="color: #339933;">:</span>yourName<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
@end</pre></div></div>

<p>It is not the goal of this topic explain how object-c works, however let&#8217;s take a look at the code above.<br />
First, only the method implementation is inside the class. As I said earlier, the attributes/instance variables stay in the interface.<br />
NSString is the String type used in the Cocoa Touch Framework. Also, as I said, all objects use pointer.<br />
The messages are send out through brackets ([ ]) in a object. It looks weird, but I promise, you will get used to it.<br />
Finally, the NSString API has a lot of useful methods. Different from other languages that uses the plus sign to concatenate two strings, NSString has a method called &#8220;stringByAppendingString&#8221;. If you want to create real applications for IPhone, Ipad or Ipod touch, you MUST take a deep look at the NSString API.</p>
<h3>Running the application</h3>
<p>Make sure you&#8217;re using the proper emulator. For this example, we&#8217;re using IPhone. Look at the right up corner of XCode.<br />
<a href="http://www.jairrillo.com/blog/wp-content/uploads/2011/06/xcode_emulator.png"><img class="alignnone size-thumbnail wp-image-801" title="xcode_emulator" src="http://www.jairrillo.com/blog/wp-content/uploads/2011/06/xcode_emulator-150x150.png" alt="" width="150" height="150" /></a><br />
After that, click on &#8220;Build and Run&#8221; button and the emulator will launch. It looks a Iphone device with its features. Now, you can test your first application.<br />
<a href="http://www.jairrillo.com/blog/wp-content/uploads/2011/06/iphone-emulator.png"><img class="alignnone size-thumbnail wp-image-802" title="iphone-emulator" src="http://www.jairrillo.com/blog/wp-content/uploads/2011/06/iphone-emulator-150x150.png" alt="" width="150" height="150" /></a></p>
<h3>Conclusion</h3>
<p>The major goal of this topic is to present you how to get started in IOS development. After read this topic, you will be able to create a new IPhone,Ipad,Ipod Touch application, create a simple UI and binding the widgets to the controller.<br />
In the next post, I&#8217;ll talk more about object-c, such as: interface, class, method, attributes, messages and so on.</p>
<p>If you have any question, fell free to leave your comment below. I hope this topic be useful for anyone.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jairrillo.com/blog/2011/06/18/getting-started-with-ios-binding-user-interface-and-controller/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to resize multiples images on Ubuntu</title>
		<link>http://www.jairrillo.com/blog/2010/11/16/how-to-resize-multiples-images-on-ubuntu/</link>
		<comments>http://www.jairrillo.com/blog/2010/11/16/how-to-resize-multiples-images-on-ubuntu/#comments</comments>
		<pubDate>Wed, 17 Nov 2010 00:51:55 +0000</pubDate>
		<dc:creator>Jair Rillo Junior</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.jairrillo.com/blog/?p=777</guid>
		<description><![CDATA[This is a short and useful link for whom wants to resize multiples images on Ubuntu. First of all, back up your images file before read/run the tips from this tutorial. The simplest way to resize multiples files is through command line using a tool called mogrify. On Ubuntu 10.04 this tool is installed by [...]]]></description>
			<content:encoded><![CDATA[<p>This is a short and useful link for whom wants to resize multiples images on Ubuntu. First of all, back up your images file before read/run the tips from this tutorial.</p>
<p>The simplest way to resize multiples files is through command line using a tool called <strong>mogrify</strong>. On Ubuntu 10.04 this tool is installed by default, however if you&#8217;re using an older version, you can install it through the command</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> imagemagick</pre></div></div>

<p>After that, the command to resize multiples files is really simple:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mogrify <span style="color: #660033;">-resize</span> <span style="color: #000000;">1024</span> <span style="color: #000000; font-weight: bold;">*</span>.jpg</pre></div></div>

<p>Of course you can use more parameters, however the command above will resize all pictures to 1024 pixels.</p>
<p>If you have any comment or question about this topic, fell free to leave your comment below. I hope this topic be useful for anyone else.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jairrillo.com/blog/2010/11/16/how-to-resize-multiples-images-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use the combination: JQuery + Ajax + PHP + JSON</title>
		<link>http://www.jairrillo.com/blog/2010/09/26/how-to-use-the-combination-jquery-ajax-php-json/</link>
		<comments>http://www.jairrillo.com/blog/2010/09/26/how-to-use-the-combination-jquery-ajax-php-json/#comments</comments>
		<pubDate>Sun, 26 Sep 2010 21:11:36 +0000</pubDate>
		<dc:creator>Jair Rillo Junior</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.jairrillo.com/blog/?p=761</guid>
		<description><![CDATA[After a long time, I have decided to write a simple but useful post for whom is working in a WEB 2 application using PHP as script language. Certainly you have already heard about JQuery. In this topic we&#8217;re going to show up how to use AJAX with PHP. Furthermore, we&#8217;re going to show up [...]]]></description>
			<content:encoded><![CDATA[<p>After a long time, I have decided to write a simple but useful post for whom is working in a <em>WEB 2</em> application using PHP as script language.<br />
Certainly you have already heard about <a href="http://jquery.com/">JQuery</a>. In this topic we&#8217;re going to show up how to use AJAX with PHP. Furthermore, we&#8217;re going to show up an example using JQuery + AJAX + PHP + JSON. </p>
<h2>First Example &#8211; JQuery + AJAX + PHP</h2>
<p>In the first example, we&#8217;re going to create a simple page (index.php) with a single text field and a button. When the user clicks on the button, an ajax call will be fired.<br />
The content of the text field will be sent out to a PHP file (ajaxExample.php) and it will return the content in uppercase. Finally, the new content will be displayed in the first page (index.php).<br />
All of those actions are going to be performed in an AJAX way. Hands on.</p>
<h3>index.php</h3>
<p>As said, there will be a text field and a button in the index.php. Check it out the code below:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;head&gt;
	&lt;script type='text/javascript' src='js/jquery.js'&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;h2&gt;JQuery + AJAX + PHP - First Example&lt;/h2&gt;
	&lt;form&gt;
		Name: &lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;name&quot; /&gt;&lt;br /&gt;
		&lt;input type=&quot;button&quot; id=&quot;button&quot; value=&quot;Click me&quot; /&gt;	
	&lt;/form&gt;
        &lt;div id=&quot;loading&quot;&gt;Loading...&lt;/div&gt;
	&lt;div id=&quot;result&quot; /&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p>Nothing special on the code above. On line 3 we have added the JQuery file. Also, we have the form with the text field and the button and two DIVs: one to show the loading string and the other one to show the result. Now, go to the next step.</p>
<h3>ajaxExample.php</h3>
<p>This is the simplest file. Basically it gets the value from the name attribute, wait for 2 seconds and return the name in uppercase mode.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">strtoupper</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h3>JQuery and AJAX Code</h3>
<p>Finally, let&#8217;s the see cool part, where the JQuery call the ajax function. Let&#8217;s see the code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">	$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#loading&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#button&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			$.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
				type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'POST'</span><span style="color: #339933;">,</span>
				data<span style="color: #339933;">:</span> <span style="color: #3366CC;">'name='</span> <span style="color: #339933;">+</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#name&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">,</span>
				url<span style="color: #339933;">:</span> <span style="color: #3366CC;">'ajaxExample.php'</span><span style="color: #339933;">,</span>
				success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#loading&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#result&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
				beforeSend<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#loading&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The code above makes the ajax call. As you can see, the code is straightforward, but If you need more information about the parameters, please check the JQuery AJAX API.<br />
Now, run the application and you&#8217;re gonna see how the code works.</p>
<p>If you prefer, <a href="http://www.jairrillo.com/files/jquery_ajax_php.zip">you can download the example above here</a>.</p>
<h2>JSON</h2>
<p>If you&#8217;re not familiar with JSON, please <a href="http://www.json.org/" target="_blank">check this site out</a>.<br />
JQuery handles JSON usando the JSON.parse method. In the PHP side, there are two methods: encode_json and decode_json. Let&#8217;s see another example:</p>
<h3>index.php</h3>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;head&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;js/jquery.js&quot;&gt;&lt;/script&gt;
	&lt;script type=&quot;text/javascript&quot;&gt;
		$(function() {
			$(&quot;#result&quot;).hide();
			$(&quot;#json_anchor&quot;).click(function() {				
				json_call();
			});
		});	
&nbsp;
		function json_call() {
			$.ajax({
				type: 'POST',
				url: 'json.php',
				success: function(data) {										
					var myObject = JSON.parse(data);
					$(&quot;#name&quot;).text(myObject.name);
					$(&quot;#age&quot;).text(myObject.age);			
					$(&quot;#result&quot;).show();		
				}
			});
		}
	&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;h2&gt;Hello JSON + PHP World&lt;/h2&gt;
	&lt;a href=&quot;#&quot; id=&quot;json_anchor&quot;&gt;Click here&lt;/a&gt;
	&lt;div id=&quot;result&quot;&gt;
		&lt;table border=&quot;0&quot;&gt;
			&lt;tr&gt;
				&lt;td width=&quot;50px&quot;&gt;&lt;strong&gt;Name&lt;/strong&gt;&lt;/td&gt;
				&lt;td id=&quot;name&quot;&gt;&lt;/td&gt;		
			&lt;/tr&gt;
			&lt;tr&gt;
				&lt;td&gt;&lt;strong&gt;Age&lt;/strong&gt;&lt;/td&gt;
				&lt;td id=&quot;age&quot;&gt;&lt;/td&gt;		
			&lt;/tr&gt;
		&lt;/table&gt;
	&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<h3>json.php</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Customer.class.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$customer</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Customer<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Jair'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">28</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$customer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>See above, we&#8217;re using the json_encode method to transform an object (Customer) into a JSON object.</p>
<h3>Customer.class.php</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> Customer <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$name</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$age</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$age</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$name</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">age</span>	<span style="color: #339933;">=</span> <span style="color: #000088;">$age</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Running the example you&#8217;re gonna see a link. When the user clicks on the Link a table with the name and age will be displayed. This call is made by AJAX.<br />
<a href="http://www.jairrillo.com/files/php_json.zip">You can download this example here</a>.</p>
<p>As you can see, use JQuery is useful for AJAX call. The biggest advance of JQuery, is that you can use JQuery with almost any language: PHP, Ruby, Java and so on. I hope this topic be useful for anyone.<br />
If you have any question or comment, fell free to let your message below</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jairrillo.com/blog/2010/09/26/how-to-use-the-combination-jquery-ajax-php-json/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JPA 2 and Netbeans Guide &#8211; Part 3 &#8211; Querying</title>
		<link>http://www.jairrillo.com/blog/2010/03/13/jpa-2-and-netbeans-guide-part-3-querying/</link>
		<comments>http://www.jairrillo.com/blog/2010/03/13/jpa-2-and-netbeans-guide-part-3-querying/#comments</comments>
		<pubDate>Sat, 13 Mar 2010 23:21:07 +0000</pubDate>
		<dc:creator>Jair Rillo Junior</dc:creator>
				<category><![CDATA[JPA]]></category>
		<category><![CDATA[Netbeans]]></category>
		<category><![CDATA[Criteria]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JEE]]></category>
		<category><![CDATA[JPA 2]]></category>
		<category><![CDATA[JPAQL]]></category>

		<guid isPermaLink="false">http://www.jairrillo.com/blog/?p=750</guid>
		<description><![CDATA[This is the third part of a series of posts about JPA 2 and Netbeans 6. This series has the goal to show up how to get started with JPA 2, as well as creating complex model using relationship and inheritance. Part three is gonna use the same example than Part 1, but now we’re [...]]]></description>
			<content:encoded><![CDATA[<p>This is the third part of a series of posts about JPA 2 and Netbeans 6. This series has the goal to show up how to get started with JPA 2, as well as creating complex model using relationship and inheritance.<br />
Part three is gonna use the same example than <a href="http://www.jairrillo.com/blog/2010/02/23/getting-started-with-jpa-2-and-netbeans-part-1/" target="_blank">Part 1</a>, but now we’re going to use the query mechanism to retrieve values from database.</p>
<h2>Requirement</h2>
<ul>
<li>Understand JPA concepts &#8211; If you have no idea what JPA is, please google it first</li>
<li>Netbeans 6.8 and glassfish v3 installed</li>
<li>MySQL database installed &#8211; If you have another one, make sure you have the JDBC driver</li>
<li>Read <a href="http://www.jairrillo.com/blog/2010/02/23/getting-started-with-jpa-2-and-netbeans-part-1/" target="_blank">Part 1</a> and have the database and POJO already created.</li>
</ul>
<h2>Querying strategy</h2>
<p>The most common way to retrieve values from relational databases is through an SQL Select Query, probably you have already wrote a lot of them. JPA has this ability and much more.<br />
Since version one, JPA allows you to retrieve values from native query, JPA-QL and NamedQuery, which uses JPA-QL. In version 2, JPA brings us another great API, Criteria API.</p>
<h2>Native Query</h2>
<p>Let&#8217;s get started with the most popular, but less used in JPA: Native Query.<br />
This kind of query must be used <strong>only</strong> when you need a specific command/resource from the database. Creating many specific queries, your application is going to be dependent from the database, it can be a disadvantage.<br />
To use the native query, simply use the <strong>createNativeQuery</strong> method from EntityManager. Let&#8217;s see the same example from part 1, but using the Native Query.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        EntityManagerFactory emFactory <span style="color: #339933;">=</span> Persistence.<span style="color: #006633;">createEntityManagerFactory</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;JPAExample01PU&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        EntityManager em <span style="color: #339933;">=</span> emFactory.<span style="color: #006633;">createEntityManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        List<span style="color: #339933;">&lt;</span>Products<span style="color: #339933;">&gt;</span> listProducts <span style="color: #339933;">=</span> em.<span style="color: #006633;">createNativeQuery</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;select * from products&quot;</span>, Products.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getResultList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>Products product <span style="color: #339933;">:</span> listProducts<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Product: &quot;</span> <span style="color: #339933;">+</span> product.<span style="color: #006633;">getDescription</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Price: &quot;</span> <span style="color: #339933;">+</span> product.<span style="color: #006633;">getPrice</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;---------------------------------------&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>The change happened on line 4. We have added the <strong>createNativeQuery</strong> method. The first parameter is the Select Query itself and the second one is the class where the result must be mapped.</p>
<h2>JPA-QL</h2>
<p>This is the query language for JPA. It is similar than SQL, but it uses object approach. There is a method called <strong>createQuery</strong> that returns a list of objects. See the example</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">List<span style="color: #339933;">&lt;</span>Products<span style="color: #339933;">&gt;</span> listProducts <span style="color: #339933;">=</span> em.<span style="color: #006633;">createQuery</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;select p from Products p&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getResultList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The example above seems similar than the NativeQuery, but the biggest difference appear when you use JOIN. Supposing our Products table has a relationship with another table called Categories. We could create a JPA Query like this:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">List<span style="color: #339933;">&lt;</span>Products<span style="color: #339933;">&gt;</span> listProducts <span style="color: #339933;">=</span> em.<span style="color: #006633;">createQuery</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;select p from Products p inner join p.categories&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getResultList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>We&#8217;re going to talk about relationship in Part 5.</p>
<h2>NamedQuery</h2>
<p>NamedQuery is the kind of querying that we used in part 1 of this guide. The NamedQuery is written using JPA-HQ and we use the <strong>createNamedQuery</strong> method to call it. The NamedQuery lives in the Entity class and has the annotation @NamedQuery.<br />
If you understand JPA-QL, certainly you&#8217;ll not find any problem to use NamedQuery.</p>
<h2>Criteria</h2>
<p>Criteria API is the newest API in JPA 2. If you&#8217;re familiar with Hibernate, like me, certainly you liked this API in JPA 2.<br />
As Criteria API is new, it deserves an unique post for it. Part 4 of this guide is exclusive for Criteria.</p>
<h2>Best Practices</h2>
<p>One of the most common question regarding querying in JPA is where to use them. The simple answer could be:</p>
<ul>
<li>Native Qurery: When you need a specific command/resource from the database that a JPA-QL doesn&#8217;t offer</li>
<li>JPA-QL: When you have a static query</li>
<li>NamedQuery: When you have a static query that doesn&#8217;t change, use it instead Criteria</li>
<li>Criteria: When you have a dynamic query</li>
</ul>
<p>This post ends here, but in the Part 4 we&#8217;re going to keep talking about querying, but we&#8217;re only talk about Criteria API.<br />
If you have any question or comment, fell free to leave your message below. I hope this topic be useful for anyone else.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jairrillo.com/blog/2010/03/13/jpa-2-and-netbeans-guide-part-3-querying/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>JPA 2 and Netbeans Guide &#8211; Part 2 &#8211; JPA in a web environment</title>
		<link>http://www.jairrillo.com/blog/2010/02/28/jpa-2-and-netbeans-guide-part-2-jpa-in-a-web-environment/</link>
		<comments>http://www.jairrillo.com/blog/2010/02/28/jpa-2-and-netbeans-guide-part-2-jpa-in-a-web-environment/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 23:40:47 +0000</pubDate>
		<dc:creator>Jair Rillo Junior</dc:creator>
				<category><![CDATA[Glassfish]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[Netbeans]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JPA 2]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.jairrillo.com/blog/?p=736</guid>
		<description><![CDATA[This is the second part of a series of posts about JPA 2 and Netbeans 6. This series has the goal to show up how to get started with JPA 2, as well as creating complex model using relationship and inheritance. Part two is gonna use the same example than Part 1, but now we&#8217;re [...]]]></description>
			<content:encoded><![CDATA[<p>This is the second part of a series of posts about JPA 2 and Netbeans 6. This series has the goal to show up how to get started with JPA 2, as well as creating complex model using relationship and inheritance.<br />
Part two is gonna use the same example than <a href="http://www.jairrillo.com/blog/2010/02/23/getting-started-with-jpa-2-and-netbeans-part-1/" target="_blank">Part 1</a>, but now we&#8217;re going to work on a web environment. </p>
<h3>Requirement</h3>
<ul>
<li>Understand JPA concepts &#8211; If you have no idea what JPA is, please google it first</li>
<li>Netbeans 6.8 and glassfish v3 installed</li>
<li>MySQL database installed &#8211; If you have another one, make sure you have the JDBC driver</li>
<li>Read <a href="http://www.jairrillo.com/blog/2010/02/23/getting-started-with-jpa-2-and-netbeans-part-1/" target="_blank">Part 1</a> and have the database and POJO already created.</li>
</ul>
<h3>Creating the project within Netbeans</h3>
<p>Let&#8217;s getting started through the project creation. Within Netbeans, go to <em>File -> New Project -> Java Web -> Web Application</em>. Choose a name, like <em>JPAWebExample01</em> and Glassfish v3 as Server. On third screen, select JavaServer Faces and accept the default.<br />
<a href="http://www.jairrillo.com/blog/wp-content/uploads/2010/02/jpa02_01.png" target="_blank"><img src="http://www.jairrillo.com/blog/wp-content/uploads/2010/02/jpa02_01-300x175.png" alt="" title="jpa02_01" width="300" height="175" class="alignnone size-medium wp-image-738" /></a><br />
Note: don&#8217;t worry if you aren&#8217;t familiar with JSF. For this example we&#8217;ll focus on JPA only.</p>
<h3>Creating the DataSource</h3>
<p>Different than Stand-Alone application, in web application we could create a datasource to obtain and manage the database connection. This datasource lives in the Server, in our case, Glassfish.<br />
Fortunately we can create it directly inside Netbeans in an easy way. Let&#8217;s do that now.<br />
Similar than the post 1, let&#8217;s open the screen to create a entity class from the database. To do that, right mouse click on the project name and go to New -> Other -> Persistence -> Entity Classes from Database. On the new screen, you&#8217;re gonna see the <em>Data Source</em> field. Click on it and select <em>New Data Source</em>.<br />
<a href="http://www.jairrillo.com/blog/wp-content/uploads/2010/02/jpa02_02.png" target="_blank"><img src="http://www.jairrillo.com/blog/wp-content/uploads/2010/02/jpa02_02-300x72.png" alt="" title="jpa02_02" width="300" height="72" class="alignnone size-medium wp-image-741" /></a><br />
On the JNDI Name, fill up the field with the value <em>jdbc/MySQL_jpatutorial</em>.  Database Connection select the previous connection you&#8217;ve done in Part 1. Click OK and the DataSource will be created.</p>
<h2>Creating the Model and persistence.xml</h2>
<p>After you have created the datasource, you should see the table <em>products</em> listed. Now, you can follow exactly the same step from Part 1 to create the persistence.xml and the model.</p>
<h2>Creating a Manged-Bean</h2>
<p>Our application uses JSF 2.0 and because of this we can create a Managed Bean to handle the requests coming from view. If you don&#8217;t know what Managed Bean is, think he is a Java class that handles requests from view. It is similar a Controller from MVC, but it is directly binding with the view.<br />
In our example, the ManagedBean will obtain the EntityManager and call the NamedQuery.<br />
To create a ManagedBean with Netbeans, follow the following steps:<br />
Right mouse click on the project&#8217;s name <em>New -> Other -> JavaServer Faces -> JSF Managed Bean</em>. In the <em>Class Name</em> put <em>JPATutorialBean</em> and the <em>Package</em> put <em>mbeans</em>.<br />
<a href="http://www.jairrillo.com/blog/wp-content/uploads/2010/02/jpa02_3.png" target="_blank"><img src="http://www.jairrillo.com/blog/wp-content/uploads/2010/02/jpa02_3-300x238.png" alt="" title="jpa02_3" width="300" height="238" class="alignnone size-medium wp-image-744" /></a><br />
In th JPATutorialBean.java, let&#8217;s add a method called <em>listAllProducts</em>. The content looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">mbeans</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">entities.Products</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.faces.bean.ManagedBean</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.faces.bean.RequestScoped</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.EntityManager</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.PersistenceContext</span><span style="color: #339933;">;</span>
&nbsp;
@ManagedBean<span style="color: #009900;">&#40;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;jpaTutorialBean&quot;</span><span style="color: #009900;">&#41;</span>
@RequestScoped
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> JPATutorialBean <span style="color: #009900;">&#123;</span>
&nbsp;
    @PersistenceContext
    <span style="color: #000000; font-weight: bold;">private</span> EntityManager em<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> listAllProducts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       List<span style="color: #339933;">&lt;</span>Products<span style="color: #339933;">&gt;</span> listProducts <span style="color: #339933;">=</span> em.<span style="color: #006633;">createNamedQuery</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Products.findAll&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getResultList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>Products product <span style="color: #339933;">:</span> listProducts<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Product: &quot;</span> <span style="color: #339933;">+</span> product.<span style="color: #006633;">getDescription</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Price: &quot;</span> <span style="color: #339933;">+</span> product.<span style="color: #006633;">getPrice</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;---------------------------------------&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The method listAllProducts has no mistery. It is similar than the first post. Simply create a named query and prints out the result. However, <strong>pay attention</strong> on the lines:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    @PersistenceContext
    <span style="color: #000000; font-weight: bold;">private</span> EntityManager em<span style="color: #339933;">;</span></pre></div></div>

<p>We&#8217;ve used an annotation called @PersistenceContext. Different than StandAlone application, where we had to obtain a EntityManagerFactory and after that create the EntityManager, in a <strong>web based application, the container is responsible to inject the EntityManager for us</strong>. Really simple, doesn&#8217;t it?</p>
<h3>Editing the index.xhtml</h3>
<p>How can we call the method listAllProducts from ManagedBean? We can do that editing the index.xhtml and creating a link to access this method. Edit the current index.xhtml and add the following:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;?xml version='1.0' encoding='UTF-8' ?&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;
      xmlns:h=&quot;http://java.sun.com/jsf/html&quot;&gt;
    &lt;h:head&gt;
        &lt;title&gt;Facelet Title&lt;/title&gt;
    &lt;/h:head&gt;
    &lt;h:body&gt;
        Hello from Facelets
        &lt;h:form&gt;
            &lt;h:commandLink action=&quot;#{jpaTutorialBean.listAllProducts}&quot;&gt;
                &lt;h:outputText value=&quot;List All Products&quot; /&gt;
            &lt;/h:commandLink&gt;
        &lt;/h:form&gt;
    &lt;/h:body&gt;
&lt;/html&gt;</pre></div></div>

<p>The code above is HTML and JSF stuff. Look at the h:commandLink and you&#8217;re gonna see where we bind the link with the method. JSF also makes our life easier.</p>
<h3>Running and Testing the code</h3>
<p>Now all changes are done, right mouse click on the project and select the <em>Run</em> option. A new page is gonna be opened in your browser and then click on the link.<br />
Look at Netbeans console and you should see an output like below:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">INFO: Product: product <span style="color: #000000;">1</span>
INFO: Price: <span style="color: #000000;">100.0</span>
INFO: <span style="color: #660033;">---------------------------------------</span>
INFO: Product: product <span style="color: #000000;">2</span>
INFO: Price: <span style="color: #000000;">200.0</span>
INFO: <span style="color: #660033;">---------------------------------------</span>
INFO: Product: product <span style="color: #000000;">3</span>
INFO: Price: <span style="color: #000000;">200.5</span>
INFO: <span style="color: #660033;">---------------------------------------</span></pre></div></div>

<h3>Conclusion</h3>
<p>Doesn&#8217;t matter if you&#8217;re in a standalone or web application, the model (entity) is gonna be the same and the code to handle the JPA also, the biggest diffrence is the way to obtain the EntityManager. In a web application, the container is responsible to inject the EntityManager for us.</p>
<p>In the next topic we&#8217;re going talk about the strategies to retrieve values from JPA, such as: NamedQuery (already used), JPAQL and the newest feature, Criteria.</p>
<p>If you have any comment or question about this post, fell free to leave your message below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jairrillo.com/blog/2010/02/28/jpa-2-and-netbeans-guide-part-2-jpa-in-a-web-environment/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>JPA 2 and Netbeans Guide &#8211; Part 1 &#8211; Getting Started</title>
		<link>http://www.jairrillo.com/blog/2010/02/23/getting-started-with-jpa-2-and-netbeans-part-1/</link>
		<comments>http://www.jairrillo.com/blog/2010/02/23/getting-started-with-jpa-2-and-netbeans-part-1/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 23:06:52 +0000</pubDate>
		<dc:creator>Jair Rillo Junior</dc:creator>
				<category><![CDATA[Glassfish]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[Netbeans]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JPA 2]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.jairrillo.com/blog/?p=719</guid>
		<description><![CDATA[This is the first part of a series of posts about JPA 2 and Netbeans 6. This series has the goal to show up how to get started with JPA 2, as well as creating complex model using relationship and inheritance. This part one is going to show up the steps to create your first [...]]]></description>
			<content:encoded><![CDATA[<p>This is the first part of a series of posts about JPA 2 and Netbeans 6. This series has the goal to show up how to get started with JPA 2, as well as creating complex model using relationship and inheritance.<br />
This part one is going to show up the steps to create your first application that access the database using JPA 2 (Stand alone application). Using Netbeans 6, this process is easy and takes less than five minutes.</p>
<h3>Requirement</h3>
<ul>
<li>Understand JPA concepts &#8211; If you have no idea what JPA is, please google it first</li>
<li>Netbeans 6.8 and glassfish v3 installed</li>
<li>MySQL database installed &#8211; If you have another one, make sure you have the JDBC driver</li>
</ul>
<h3>Preparing the database</h3>
<p>Before we get started with Netbeans, let&#8217;s prepare our database. The instructions below are regarding MySQL, but if you&#8217;re using another database, you may need to change the scripts to work out.<br />
Firstly, connect to your database:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysql <span style="color: #660033;">-u</span> root <span style="color: #660033;">-p</span></pre></div></div>

<p>Then, create the database and select it. Let&#8217;s call it as &#8220;jpatutorial&#8221;</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">create database jpatutorial;
use jpatutorial;</pre></div></div>

<p>Now, run the script below. Basically it creates a table called &#8220;products&#8221; and insert three products by default.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">create table products <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">id</span> int not null auto_increment, description varchar<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">40</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, price double, primary key<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">id</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;
insert into products <span style="color: #7a0874; font-weight: bold;">&#40;</span>description, price<span style="color: #7a0874; font-weight: bold;">&#41;</span> values <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'product 1'</span>,<span style="color: #000000;">100</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; 
insert into products <span style="color: #7a0874; font-weight: bold;">&#40;</span>description, price<span style="color: #7a0874; font-weight: bold;">&#41;</span> values <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'product 2'</span>,<span style="color: #000000;">200</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; 
insert into products <span style="color: #7a0874; font-weight: bold;">&#40;</span>description, price<span style="color: #7a0874; font-weight: bold;">&#41;</span> values <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'product 3'</span>,<span style="color: #000000;">200.50</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;</pre></div></div>

<h3>Creating the project within Netbeans</h3>
<p>Now the &#8220;magic&#8221; starts. Open up Netbeans and create a simple Java program called &#8220;JPAExample01&#8243;. Netbeans also creates a &#8220;Main&#8221; class for you.<br />
<a href="http://www.jairrillo.com/blog/wp-content/uploads/2010/02/jpa1_01.png" target="_blank"><img src="http://www.jairrillo.com/blog/wp-content/uploads/2010/02/jpa1_01-300x185.png" alt="" title="jpa1_01" width="300" height="185" class="alignnone size-medium wp-image-723" /></a></p>
<h3>Creating the Model and persistence.xml</h3>
<p>After the project is created, right mouse click on it and go to <em>New -> Other -> Persistence -> Entity Classes from Database</em>. On next screen, select <em>Database Connection -> New Database Connection</em> and type the information from your database. After that, the table &#8220;products&#8221; should appear on the screen.<br />
<a href="http://www.jairrillo.com/blog/wp-content/uploads/2010/02/jpa2_01.png" target="_blank"><img src="http://www.jairrillo.com/blog/wp-content/uploads/2010/02/jpa2_01-300x179.png" alt="" title="jpa2_01" width="300" height="179" class="alignnone size-medium wp-image-724" /></a><br />
Select &#8220;products&#8221; and click on &#8220;Add&#8221; and then &#8220;Next&#8221;.<br />
On third screen, you must create our &#8220;Persistence Unit&#8221;. Click on <em>Create Persistence Unit&#8230;</em> button. Now, we must select the provider we want. By default, Netbeans brings the EclipseLink, but you&#8217;re free to change it. Also, you can change the Unit name and table generation strategy, but let&#8217;s keep the default so far.<br />
<a href="http://www.jairrillo.com/blog/wp-content/uploads/2010/02/jpa3_01.png" target="_blank"><img src="http://www.jairrillo.com/blog/wp-content/uploads/2010/02/jpa3_01-300x131.png" alt="" title="jpa3_01" width="300" height="131" class="alignnone size-medium wp-image-726" /></a><br />
The persistence.xml file has created, now click next until the end and finish the process (you can accept all the default options).<br />
Take a look at the Project and you&#8217;re gonna see a new folder called &#8220;META-INF&#8221; with the file persistence.xml and the file &#8220;Products.java&#8221; created.</p>
<h3>Examining the Products.java</h3>
<p>Usually a model is a simple POJO. With JPA, the POJO has annotations that define the primary key, columns, relationship and so on. Netbeans has already done these annotations for us. Open the Products.java and have a look.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@<span style="color: #003399;">Entity</span>
@Table<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;products&quot;</span><span style="color: #009900;">&#41;</span>
@NamedQueries<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    @NamedQuery<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Products.findAll&quot;</span>, query <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT p FROM Products p&quot;</span><span style="color: #009900;">&#41;</span>,
    @NamedQuery<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Products.findById&quot;</span>, query <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT p FROM Products p WHERE p.id = :id&quot;</span><span style="color: #009900;">&#41;</span>,
    @NamedQuery<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Products.findByDescription&quot;</span>, query <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT p FROM Products p WHERE p.description = :description&quot;</span><span style="color: #009900;">&#41;</span>,
    @NamedQuery<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Products.findByPrice&quot;</span>, query <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT p FROM Products p WHERE p.price = :price&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Products <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399;">Serializable</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">long</span> serialVersionUID <span style="color: #339933;">=</span> 1L<span style="color: #339933;">;</span>
    @Id
    @GeneratedValue<span style="color: #009900;">&#40;</span>strategy <span style="color: #339933;">=</span> GenerationType.<span style="color: #006633;">IDENTITY</span><span style="color: #009900;">&#41;</span>
    @Basic<span style="color: #009900;">&#40;</span>optional <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
    @Column<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Integer</span> id<span style="color: #339933;">;</span>
    @Column<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;description&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> description<span style="color: #339933;">;</span>
    @Column<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;price&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Double</span> price<span style="color: #339933;">;</span></pre></div></div>

<p>Attention: The netbeans has already generated some NamedQueries for us too, Thanks Netbeans team <img src='http://www.jairrillo.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>Running and testing the JPA</h3>
<p>To test JPA, we must a EntityManager. In a stand-alone application, to get it, we must a EntityManagerFactory. Let&#8217;s change our Main class and initialize a EntityManager and call a simple NamedQuery. The Main class looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">jpaexample01</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">entities.Products</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.EntityManager</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.EntityManagerFactory</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Persistence</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        EntityManagerFactory emFactory <span style="color: #339933;">=</span> Persistence.<span style="color: #006633;">createEntityManagerFactory</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;JPAExample01PU&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        EntityManager em <span style="color: #339933;">=</span> emFactory.<span style="color: #006633;">createEntityManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        List<span style="color: #339933;">&lt;</span>Products<span style="color: #339933;">&gt;</span> listProducts <span style="color: #339933;">=</span> em.<span style="color: #006633;">createNamedQuery</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Products.findAll&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getResultList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>Products product <span style="color: #339933;">:</span> listProducts<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Product: &quot;</span> <span style="color: #339933;">+</span> product.<span style="color: #006633;">getDescription</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Price: &quot;</span> <span style="color: #339933;">+</span> product.<span style="color: #006633;">getPrice</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;---------------------------------------&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Pay attention on main method. We get a EntityManagerFactory, then an EntityManager, we call a NamedQuery already done and finally we iterate over the list and print out the description and price of the product.<br />
<strong>Before</strong> run the code, you must add the JDBC driver into the project&#8217;s classpath. To do that right mouse click on the project <em>Properties -> Libraries -> Add Library -> MySQL JDBC Driver</em><br />
Now you can run the application and if everything is fine, you are gonna see in the console:</p>
<pre>
Product: product 1
Price: 100.0
---------------------------------------
Product: product 2
Price: 200.0
---------------------------------------
Product: product 3
Price: 200.5
---------------------------------------
</pre>
<h3>Conclusion</h3>
<p>As you can see, Netbeans has a great support for JPA 2. You were able to create your first application in few minutes.</p>
<p>This post finishes here, in the next one we are going to talk about <a href="http://www.jairrillo.com/blog/2010/02/28/jpa-2-and-netbeans-guide-part-2-jpa-in-a-web-environment/">JPA 2 in a web environment</a>. You&#8217;re gonna see the code is similar, but the way to obtain the EntityManager is different.<br />
If you have any comment or question about this post, fell free to leave your message below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jairrillo.com/blog/2010/02/23/getting-started-with-jpa-2-and-netbeans-part-1/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Enabling USB on Sun VirtualBox v3 on Ubuntu step-by-step</title>
		<link>http://www.jairrillo.com/blog/2010/02/21/enabling-usb-on-sun-virtualbox-v3-on-ubuntu-step-by-step/</link>
		<comments>http://www.jairrillo.com/blog/2010/02/21/enabling-usb-on-sun-virtualbox-v3-on-ubuntu-step-by-step/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 22:45:15 +0000</pubDate>
		<dc:creator>Jair Rillo Junior</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[USB]]></category>
		<category><![CDATA[VirtualBox]]></category>
		<category><![CDATA[VM]]></category>

		<guid isPermaLink="false">http://www.jairrillo.com/blog/?p=709</guid>
		<description><![CDATA[VirtualMachine is a reality nowadays. If you have a base operating system (called host) and want to use another one on the base (called guest), you can use a VM to do that.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.virtualbox.org/graphics/vbox_logo2_gradient.png" alt="Sun VirtualBox" align="left" />VirtualMachine is a reality nowadays. If you have a base operating system (called host) and want to use another one on the base (called guest), you can use a VM to do that.<br />
<a href="http://www.virtualbox.org/" target="_blank'>Sun VirtualBox</a> is a great free tool to do that in an easy and fast way. However, by default on Ubuntu, the USB doesn&#8217;t work properly. Inside the guest operating system, the USB is not accessible at all.<br />
In this topic, I&#8217;ll show up how to setup Ubuntu to enable the USB on guest operating system. Fortunately it is straightforward and doesn&#8217;t hurt <img src='http://www.jairrillo.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>Downloading and installing Sun VirtualBox</h2>
<p><a href="http://www.virtualbox.org/wiki/Downloads">Downloading the Sun VirtualBox directly from its website.</a>For Ubuntu, there&#8217;s a .deb file. Simply download it and double click on it install it. After that the VirtualBox is installed. Now, you can install the Operating system that you want.</p>
<h2>Setup Ubuntu</h2>
<p>If you have already run Sun VirtualBox, probably you notified that USB didn&#8217;t appear. It happens because you need to make some changes on Ubuntu. Let&#8217;s do that now.<br />
First, open the terminal and type the following:</p>
<pre class="bash">
grep vboxusers /etc/group
</pre>
<p>Memorize the number that appear for you. In my example, the number is <strong>121</strong>.<br />
<a href="http://www.jairrillo.com/blog/wp-content/uploads/2010/02/imagem1.png" target="_blank"><img src="http://www.jairrillo.com/blog/wp-content/uploads/2010/02/imagem1-300x44.png" alt="" title="imagem1" width="300" height="44" class="alignnone size-medium wp-image-712" /></a><br />
Now, go to <em>System -> Administration -> Users and Groups</em>. After that, click on &#8220;Change button&#8221; and enter your password.<br />
<a href="http://www.jairrillo.com/blog/wp-content/uploads/2010/02/imagem2.png" target="_blank"><img src="http://www.jairrillo.com/blog/wp-content/uploads/2010/02/imagem2-300x145.png" alt="" title="imagem2" width="300" height="145" class="alignnone size-medium wp-image-710" /></a><br />
After that, click on <em>Manage Groups</em>. Find and select the <strong>vboxusers</strong> and click on <em>Properties</em> button. On the screen, select your user and type the Group ID that you picked early.<br />
<a href="http://www.jairrillo.com/blog/wp-content/uploads/2010/02/imagem3.png" target="_blank"><img src="http://www.jairrillo.com/blog/wp-content/uploads/2010/02/imagem3-300x214.png" alt="" title="imagem3" width="300" height="214" class="alignnone size-medium wp-image-714" /></a><br />
The changes are done. Now restart the Ubuntu and in the next time you run VM, the USB are gonna appear for you.<br />
<a href="http://www.jairrillo.com/blog/wp-content/uploads/2010/02/imagem4.png" target="_blank"><img src="http://www.jairrillo.com/blog/wp-content/uploads/2010/02/imagem4-300x61.png" alt="" title="imagem4" width="300" height="61" class="alignnone size-medium wp-image-716" /></a><br />
<strong>PS</strong>: When you start the USB on guest machine, the USB port on host machine is closed and vice-versa.</p>
<p>This is a simple post but I hope it be helpful for anyone else. If you have any question or comment, fell free to leave your comment below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jairrillo.com/blog/2010/02/21/enabling-usb-on-sun-virtualbox-v3-on-ubuntu-step-by-step/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Long time&#8230; 2010 has began</title>
		<link>http://www.jairrillo.com/blog/2010/02/12/long-time-2010-has-began/</link>
		<comments>http://www.jairrillo.com/blog/2010/02/12/long-time-2010-has-began/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 13:51:39 +0000</pubDate>
		<dc:creator>Jair Rillo Junior</dc:creator>
				<category><![CDATA[Pessoal]]></category>

		<guid isPermaLink="false">http://www.jairrillo.com/blog/?p=707</guid>
		<description><![CDATA[O meu último post no blog foi no dia 12 de Novembro de 2009, ou seja, exatos 3 meses sem escrever aqui. Certamente os meses de Novembro, Dezembro e início de Janeiro foram os mais desafiadores dentro da IBM para mim. Tinhamos algumas atividades monstruosas para desenvolvermos em tempo recorde. Eu fiz o papel de [...]]]></description>
			<content:encoded><![CDATA[<p>O meu último post no blog foi no dia 12 de Novembro de 2009, ou seja, exatos 3 meses sem escrever aqui.<br />
Certamente os meses de Novembro, Dezembro e início de Janeiro foram os mais desafiadores dentro da IBM para mim. Tinhamos algumas atividades monstruosas para desenvolvermos em tempo recorde. Eu fiz o papel de liderar o time técnico e felizmente, graças ao grande trabalho do meu time (Gustavo Oliva, Victor, Gisele, Renato, Gustavo Castellano e Marcela), conseguimos atingir o objetivo com excelente qualidade.<br />
Esse foi um dos motivos que não tive tempo para postar novidades no blog, mas isso não significa que nesse tempo eu não tenha acompanhado as novidades no mundo de TI.<br />
Cheguei a fazer alguns exemplos do JSF 2.0 e JPA 2.0, a princípio gostei bastante de ambos. Dentro do projeto fiz algumas coisas com o Hibernate que nunca tinha feito antes, utilizei alguns design patterns que ajudaram muito no projeto, implantamos testes unitários úteis utilizando JUnit e EasyMock, enfim foram meses de pura tecnologia.<br />
2010 começa e eu vou tentar ser mais ativo no blog. Alguns posts já estão na cabeça, mas ainda falta pique para iniciá-los. No próximo dia 22 eu tiro férias de 13 dias e isso certamente vai servir para carregar as pilhas e ter mais um ano cheio de desafios.<br />
Uma coisa que já voltei a fazer com mais frequência é acessar o <a href="http://www.guj.com.br" target="_blank">GUJ.com.br</a> diariamente.<br />
Esse ano vou voltar de fato estudar Ruby e Scala, duas grandes linguagens que eu abandonei um tempo atrás. Internamente na empresa será o ano de entregar o segmento 1 do projeto e também pretendo tirar a certificação interna de IT Specialist.<br />
Enfim, 2010 será cheio de desafios, mas nós da área de TI sempre temos que arrumar tempo para estudar tecnologias novas e também compartilhar nosso conhecimento, seja através de blog, fórum, palestras, eventos, etc etc etc<br />
Bom 2010 para todos.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jairrillo.com/blog/2010/02/12/long-time-2010-has-began/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

