<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>IgorShare Weblog &#187; GWT</title>
	<atom:link href="http://igorshare.wordpress.com/category/java/gwt/feed/" rel="self" type="application/rss+xml" />
	<link>http://igorshare.wordpress.com</link>
	<description>Practical Engineering</description>
	<lastBuildDate>Thu, 31 Dec 2009 16:39:30 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='igorshare.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/3e81c82619fe2ddae5ef1340b5d57788?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>IgorShare Weblog &#187; GWT</title>
		<link>http://igorshare.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://igorshare.wordpress.com/osd.xml" title="IgorShare Weblog" />
		<item>
		<title>XML/JSON symmetric REST web services providers for Jersey</title>
		<link>http://igorshare.wordpress.com/2009/07/27/xmljson-symmetric-rest-web-services-provider-for-jersey/</link>
		<comments>http://igorshare.wordpress.com/2009/07/27/xmljson-symmetric-rest-web-services-provider-for-jersey/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 14:49:39 +0000</pubDate>
		<dc:creator>igormoochnick</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Jersey]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XStream]]></category>

		<guid isPermaLink="false">http://igorshare.wordpress.com/2009/07/27/xmljson-symmetric-rest-web-services-provider-for-jersey/</guid>
		<description><![CDATA[Many times I’ve been asked to provide a set of Web Services interfaces where both JSON and XML clients can communicate with the server. Primarily it’s done for a set of reasons:

XML is very convenient to use for inter-service communication. 
JSON is great for AJAX (web) clients. It’s perfect for GWT too. 

In the recent [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=igorshare.wordpress.com&blog=2434376&post=291&subd=igorshare&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Many times I’ve been asked to provide a set of Web Services interfaces where both JSON and XML clients can communicate with the server. Primarily it’s done for a set of reasons:</p>
<ol>
<li>XML is very convenient to use for inter-service communication. </li>
<li>JSON is great for AJAX (web) clients. It’s perfect for GWT too. </li>
</ol>
<p>In the recent project we’ve been using XStream for all serialization aspects and, since it can serialize both to XML and JSON, it was plugged into Jersey as a provider too. Following you can see XML and JSON providers implemented using XStream library.</p>
<p>XML Provider (annotated to be a default provider, it&#8217;ll be used if no Content-Type or Accept headers provided):</p>
<p> <span id="more-291"></span>
<pre>
<pre class="brush: java;">
package com.igorshare.myserver.ws;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.Provider;
import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.CompactWriter;

@Produces({ MediaType.APPLICATION_XML, MediaType.TEXT_XML, MediaType.WILDCARD})
@Consumes({ MediaType.APPLICATION_XML, MediaType.TEXT_XML, MediaType.WILDCARD})
@Provider
public class XStreamXmlProvider extends AbstractMessageReaderWriterProvider&lt;Object&gt; {
    private static final Set&lt;Class&lt;?&gt;&gt; processed = new HashSet&lt;Class&lt;?&gt;&gt;();
    private static final XStream xstream = new XStream();
    private static final String DEFAULT_ENCODING = &quot;utf-8&quot;;

    // Static initializer
    {
        xstream.setMode(XStream.NO_REFERENCES);
        xstream.autodetectAnnotations(true);
    }

    @Override
    public boolean isReadable(Class&lt;?&gt; type, Type genericType, Annotation[] annotations, MediaType arg3) {
        return true;
    }

    @Override
    public boolean isWriteable(Class&lt;?&gt; type, Type genericType, Annotation[] annotations, MediaType arg3) {
	return true;
    }

    protected static String getCharsetAsString(MediaType m) {
        if (m == null) {
            return DEFAULT_ENCODING;
        }
        String result = m.getParameters().get(&quot;charset&quot;);
        return (result == null) ? DEFAULT_ENCODING : result;
    }

    protected XStream getXStream(Class&lt;?&gt; type) {
        synchronized (processed) {
            if (!processed.contains(type)) {
                xstream.processAnnotations(type);
                processed.add(type);
            }
        }
        return xstream;
    } 

    public Object readFrom(Class&lt;Object&gt; aClass, Type genericType, Annotation[] annotations,
            MediaType mediaType, MultivaluedMap&lt;String, String&gt; map, InputStream stream)
            throws IOException, WebApplicationException  {
        String encoding = getCharsetAsString(mediaType);
        XStream xStream = getXStream(aClass);
        return xStream.fromXML(new InputStreamReader(stream, encoding));
    }

    public void writeTo(Object o, Class&lt;?&gt; aClass, Type type, Annotation[] annotations,
            MediaType mediaType, MultivaluedMap&lt;String, Object&gt; map, OutputStream stream)
            throws IOException, WebApplicationException {
        String encoding = getCharsetAsString(mediaType);
        XStream xStream = getXStream(o.getClass());
        xStream.marshal(o, new CompactWriter(new OutputStreamWriter(stream, encoding)));
    }
}
</pre>
</pre>
<p>&#160;</p>
<p>JSON Provider (Note: it uses different formats for in-stream and out-stream to simplify the AJAX eval() structure):</p>
<pre>
<pre class="brush: java;">
package package com.igorshare.myserver.ws;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.Provider;
import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
import com.thoughtworks.xstream.io.json.JsonHierarchicalStreamDriver;
import com.thoughtworks.xstream.io.json.JsonWriter;

@Produces({MediaType.APPLICATION_JSON })
@Consumes({MediaType.APPLICATION_JSON })
@Provider
public class XStreamJsonProvider extends AbstractMessageReaderWriterProvider&lt;Object&gt;
{
    private static final Set&lt;Class&lt;?&gt;&gt; processed = new HashSet&lt;Class&lt;?&gt;&gt;();
    private static final XStream xstreamIn = new XStream(new JettisonMappedXmlDriver());
    private static final XStream xstreamOut = new XStream(new JsonHierarchicalStreamDriver() {
	    public HierarchicalStreamWriter createWriter(Writer writer) {
	        return new JsonWriter(writer, new char[0], &quot;&quot;, JsonWriter.DROP_ROOT_MODE);
	    }
	});
    private static final String DEFAULT_ENCODING = &quot;utf-8&quot;;

    // Static Initializer
    {
        xstreamIn.setMode(XStream.NO_REFERENCES);
        xstreamOut.setMode(XStream.NO_REFERENCES);
        xstreamOut.autodetectAnnotations(true);
    }

    @Override
    public boolean isReadable(Class&lt;?&gt; type, Type genericType, Annotation[] annotations, MediaType arg3) {
    	return true;
    }

    @Override
    public boolean isWriteable(Class&lt;?&gt; type, Type genericType, Annotation[] annotations, MediaType arg3) {
	return true;
    }

    protected static String getCharsetAsString(MediaType m) {
        if (m == null) {
            return DEFAULT_ENCODING;
        }
        String result = m.getParameters().get(&quot;charset&quot;);
        return (result == null) ? DEFAULT_ENCODING : result;
    }

    protected XStream getXStreamIn(Class&lt;?&gt; type) {
        synchronized (processed) {
            if (!processed.contains(type)) {
                xstreamIn.processAnnotations(type);
                processed.add(type);
            }
        }
        return xstreamIn;
    }

    public Object readFrom(Class&lt;Object&gt; aClass, Type genericType, Annotation[] annotations,
            MediaType mediaType, MultivaluedMap&lt;String, String&gt; map, InputStream stream)
            throws IOException, WebApplicationException {
        String encoding = getCharsetAsString(mediaType);
        XStream xStream = getXStreamIn(aClass);
        return xStream.fromXML(new InputStreamReader(stream, encoding));
    }	

    public void writeTo(Object o, Class&lt;?&gt; aClass, Type type, Annotation[] annotations,
            MediaType mediaType, MultivaluedMap&lt;String, Object&gt; map, OutputStream stream)
            throws IOException, WebApplicationException {
        String encoding = getCharsetAsString(mediaType);
        xstreamOut.toXML(o, new OutputStreamWriter(stream, encoding));
    }
}</pre>
</pre>
<p>&#160;</p>
<p>Note: XStream is rapidly falling out of my favor and&#160; many people I’ve recently talked too because of it’s quirks and a limited control over the serialized structure. Recently I’ve started using JAXB as a primary serialization mechanism. Stay tuned – I’ll post the JAXB examples too.</p>
<p>Reference: I’ve found another reference that covers the same topic &#8211; <a href="http://www.kentlai.name/2009/03/digging-into-jersey-jax-rs-2-custom.html">XML Provider on XStream and JSON provider on Json-lib</a>.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/igorshare.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/igorshare.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/igorshare.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/igorshare.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/igorshare.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/igorshare.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/igorshare.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/igorshare.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/igorshare.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/igorshare.wordpress.com/291/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=igorshare.wordpress.com&blog=2434376&post=291&subd=igorshare&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://igorshare.wordpress.com/2009/07/27/xmljson-symmetric-rest-web-services-provider-for-jersey/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/96b0fd2825bdeb9f9039b1259156b91b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">IgorM</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding Watermark to GWT Textbox widget</title>
		<link>http://igorshare.wordpress.com/2009/06/30/adding-watermark-to-gwt-textbox-widget/</link>
		<comments>http://igorshare.wordpress.com/2009/06/30/adding-watermark-to-gwt-textbox-widget/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 17:48:22 +0000</pubDate>
		<dc:creator>igormoochnick</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[GWT]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://igorshare.wordpress.com/2009/06/30/adding-watermark-to-gwt-textbox-widget/</guid>
		<description><![CDATA[Let’s see how we can improve our UI by adding some watermarked “spice”:

Let’s define the primary style for the text box (textInput) and the dependent style for the watermark (textInput-watermark):



.textInput {
	border: 1px solid #C9C7BA;
	font-family:Tahoma, Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
	padding-left: 2px;
	padding-top: 2px;
}

.textInput-watermark {
   /* background-image: url('images/overlay.gif');
   background-repeat: no-repeat;
   padding-left: 20px;
 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=igorshare.wordpress.com&blog=2434376&post=287&subd=igorshare&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Let’s see how we can improve our UI by adding some watermarked “spice”:</p>
<p><a href="http://igorshare.files.wordpress.com/2009/06/clip_image0011.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="clip_image001" border="0" alt="clip_image001" src="http://igorshare.files.wordpress.com/2009/06/clip_image001_thumb1.png?w=224&#038;h=45" width="224" height="45" /></a></p>
<p>Let’s define the primary style for the text box (<strong>textInput</strong>) and the dependent style for the watermark (<strong>textInput-watermark</strong>):</p>
</p>
<pre>
<pre class="brush: css;">
.textInput {
	border: 1px solid #C9C7BA;
	font-family:Tahoma, Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
	padding-left: 2px;
	padding-top: 2px;
}

.textInput-watermark {
   /* background-image: url('images/overlay.gif');
   background-repeat: no-repeat;
   padding-left: 20px;
   vertical-align: middle; */
   font-style: italic;
   color: DarkGray;
}
</pre>
</pre>
<p>Note that the watermark style can contain images as well (see the commented out piece).</p>
<p>After the styles were defined we need to add some code that will apply it to the text box. To do this I’m going to extend the default GWT TextBox. The trick is to hijack the OnBlur and OnFocus events. When the OnBlur is occurring, we’re going to show the watermark and OnFocus – hide it:</p>
<pre>
<pre class="brush: java;">
public class WatermarkedTextBox extends TextBox implements BlurHandler, FocusHandler
{
	String watermark;
	HandlerRegistration blurHandler;
	HandlerRegistration focusHandler;

	public WatermarkedTextBox( )
	{
		super();
		this.setStylePrimaryName(&quot;textInput&quot;);
	}

	public WatermarkedTextBox(String defaultValue)
	{
		this();
		setText(defaultValue);
	}

	public WatermarkedTextBox(String defaultValue, String watermark)
	{
		this(defaultValue);
		setWatermark(watermark);
	}

	/**
	 * Adds a watermark if the parameter is not NULL or EMPTY
	 *
	 * @param watermark
	 */
	public void setWatermark(final String watermark)
	{
		this.watermark = watermark;

		if ((watermark != null) &amp;&amp; (watermark != &quot;&quot;))
		{
			blurHandler = addBlurHandler(this);
			focusHandler = addFocusHandler(this);
			EnableWatermark();
		}
		else
		{
			// Remove handlers
			blurHandler.removeHandler();
			focusHandler.removeHandler();
		}
	}

	@Override
	public void onBlur(BlurEvent event)
	{
		EnableWatermark();
	}

	void EnableWatermark()
	{
		String text = getText();
		if ((text.length() == 0) || (text.equalsIgnoreCase(watermark)))
		{
			// Show watermark
			setText(watermark);
			addStyleDependentName(&quot;watermark&quot;);
		}
	}

	@Override
	public void onFocus(FocusEvent event)
	{
		removeStyleDependentName(&quot;watermark&quot;);

		if (getText().equalsIgnoreCase(watermark))
		{
			// Hide watermark
			setText(&quot;&quot;);
		}
	}
}
</pre>
</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/igorshare.wordpress.com/287/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/igorshare.wordpress.com/287/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/igorshare.wordpress.com/287/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/igorshare.wordpress.com/287/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/igorshare.wordpress.com/287/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/igorshare.wordpress.com/287/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/igorshare.wordpress.com/287/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/igorshare.wordpress.com/287/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/igorshare.wordpress.com/287/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/igorshare.wordpress.com/287/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=igorshare.wordpress.com&blog=2434376&post=287&subd=igorshare&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://igorshare.wordpress.com/2009/06/30/adding-watermark-to-gwt-textbox-widget/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/96b0fd2825bdeb9f9039b1259156b91b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">IgorM</media:title>
		</media:content>

		<media:content url="http://igorshare.files.wordpress.com/2009/06/clip_image001_thumb1.png" medium="image">
			<media:title type="html">clip_image001</media:title>
		</media:content>
	</item>
		<item>
		<title>Job trends for GWT and jQuery on a sharp rise</title>
		<link>http://igorshare.wordpress.com/2009/06/11/job-trends-for-gwt-and-jquery-on-a-sharp-rise/</link>
		<comments>http://igorshare.wordpress.com/2009/06/11/job-trends-for-gwt-and-jquery-on-a-sharp-rise/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 04:15:19 +0000</pubDate>
		<dc:creator>igormoochnick</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://igorshare.wordpress.com/2009/06/11/job-trends-for-gwt-and-jquery-on-a-sharp-rise/</guid>
		<description><![CDATA[Gotta love this …

       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=igorshare.wordpress.com&blog=2434376&post=284&subd=igorshare&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Gotta love this …</p>
<p><a href="http://igorshare.files.wordpress.com/2009/06/jobgraph1.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="jobgraph[1]" border="0" alt="jobgraph[1]" src="http://igorshare.files.wordpress.com/2009/06/jobgraph1_thumb.png?w=589&#038;h=328" width="589" height="328" /></a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/igorshare.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/igorshare.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/igorshare.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/igorshare.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/igorshare.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/igorshare.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/igorshare.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/igorshare.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/igorshare.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/igorshare.wordpress.com/284/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=igorshare.wordpress.com&blog=2434376&post=284&subd=igorshare&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://igorshare.wordpress.com/2009/06/11/job-trends-for-gwt-and-jquery-on-a-sharp-rise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/96b0fd2825bdeb9f9039b1259156b91b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">IgorM</media:title>
		</media:content>

		<media:content url="http://igorshare.files.wordpress.com/2009/06/jobgraph1_thumb.png" medium="image">
			<media:title type="html">jobgraph[1]</media:title>
		</media:content>
	</item>
		<item>
		<title>Building GWT web clients [Part 4] &#8211; How to connect GWT client to Azure web service?</title>
		<link>http://igorshare.wordpress.com/2009/06/08/building-gwt-web-clients-part-4-how-to-connect-gwt-client-to-azure-web-service/</link>
		<comments>http://igorshare.wordpress.com/2009/06/08/building-gwt-web-clients-part-4-how-to-connect-gwt-client-to-azure-web-service/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 20:20:07 +0000</pubDate>
		<dc:creator>igormoochnick</dc:creator>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[GWT]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[S+S]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://igorshare.wordpress.com/2009/06/08/building-gwt-web-clients-part-4-how-to-connect-gwt-client-to-azure-web-service/</guid>
		<description><![CDATA[Stay tuned … 

       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=igorshare.wordpress.com&blog=2434376&post=275&subd=igorshare&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Stay tuned … </p>
<p><img style="border-width:0;" border="0" src="http://igorshare.files.wordpress.com/2008/02/image4.png?w=213&amp;h=37&amp;h=37" /></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/igorshare.wordpress.com/275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/igorshare.wordpress.com/275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/igorshare.wordpress.com/275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/igorshare.wordpress.com/275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/igorshare.wordpress.com/275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/igorshare.wordpress.com/275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/igorshare.wordpress.com/275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/igorshare.wordpress.com/275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/igorshare.wordpress.com/275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/igorshare.wordpress.com/275/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=igorshare.wordpress.com&blog=2434376&post=275&subd=igorshare&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://igorshare.wordpress.com/2009/06/08/building-gwt-web-clients-part-4-how-to-connect-gwt-client-to-azure-web-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/96b0fd2825bdeb9f9039b1259156b91b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">IgorM</media:title>
		</media:content>

		<media:content url="http://igorshare.files.wordpress.com/2008/02/image4.png?w=213&#38;h=37&#38;h=37" medium="image" />
	</item>
		<item>
		<title>Building GWT web clients [Part 3] &#8211; How to connect GWT client to JAX-RS Jersey server?</title>
		<link>http://igorshare.wordpress.com/2009/06/08/building-gwt-web-clients-part-3-how-to-connect-gwt-client-to-jax-rs-jersey-server/</link>
		<comments>http://igorshare.wordpress.com/2009/06/08/building-gwt-web-clients-part-3-how-to-connect-gwt-client-to-jax-rs-jersey-server/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 20:15:23 +0000</pubDate>
		<dc:creator>igormoochnick</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[JAX-RS]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Jersey]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[S+S]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://igorshare.wordpress.com/2009/06/08/building-gwt-web-clients-part-3-how-to-connect-gwt-client-to-jax-rs-jersey-server/</guid>
		<description><![CDATA[Stay tuned … 

       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=igorshare.wordpress.com&blog=2434376&post=272&subd=igorshare&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Stay tuned … </p>
<p><img style="border-width:0;" border="0" src="http://igorshare.files.wordpress.com/2008/02/image4.png?w=213&amp;h=37&amp;h=37" /></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/igorshare.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/igorshare.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/igorshare.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/igorshare.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/igorshare.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/igorshare.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/igorshare.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/igorshare.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/igorshare.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/igorshare.wordpress.com/272/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=igorshare.wordpress.com&blog=2434376&post=272&subd=igorshare&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://igorshare.wordpress.com/2009/06/08/building-gwt-web-clients-part-3-how-to-connect-gwt-client-to-jax-rs-jersey-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/96b0fd2825bdeb9f9039b1259156b91b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">IgorM</media:title>
		</media:content>

		<media:content url="http://igorshare.files.wordpress.com/2008/02/image4.png?w=213&#38;h=37&#38;h=37" medium="image" />
	</item>
		<item>
		<title>Building fat GWT web clients [Intro] &#8211; How to create a GWT RPC client?</title>
		<link>http://igorshare.wordpress.com/2009/05/18/building-fat-gwt-web-clients-intro-how-to-create-a-gwt-rpc-client/</link>
		<comments>http://igorshare.wordpress.com/2009/05/18/building-fat-gwt-web-clients-intro-how-to-create-a-gwt-rpc-client/#comments</comments>
		<pubDate>Tue, 19 May 2009 01:00:47 +0000</pubDate>
		<dc:creator>igormoochnick</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[S+S]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://igorshare.wordpress.com/2009/05/18/building-fat-gwt-web-clients-intro-how-to-create-a-gwt-rpc-client/</guid>
		<description><![CDATA[After months of working (mainly fighting with quirks of Java) with GWT I’ve accumulated so much knowledge on the topic so, I feel, it starts spilling over. I’m planning to convert this spill into a series of articles on how to build fat REST-full GWT web fat clients both on Java and .NET.
Here is the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=igorshare.wordpress.com&blog=2434376&post=266&subd=igorshare&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>After months of working (mainly fighting with quirks of Java) with GWT I’ve accumulated so much knowledge on the topic so, I feel, it starts spilling over. I’m planning to convert this spill into a series of articles on how to build fat REST-full GWT web fat clients both on Java and .NET.</p>
<p>Here is the list of topics I’ll cover:</p>
<ol>
<li>Building GWT fat client </li>
<li>Java REST-full Web services </li>
<li>.NET REST-full Web services </li>
<li>Internationalization and localization </li>
<li>IOC/DI </li>
<li>Unit testing and integration testing of all the components of the system </li>
<li>Build automation </li>
<li>and much, much more … </li>
</ol>
<p>Here is a draft list of technologies I’ll be using:</p>
<ol>
<li>GWT </li>
<li>Eclipse </li>
<li>Spring </li>
<li>Jersey </li>
<li>Tomcat </li>
<li>XStream </li>
<li>AJAX </li>
<li>JSON/XML </li>
<li>WCF </li>
<li>JUnit/TestND/NUnit </li>
<li>Selenium </li>
<li>Ant </li>
<li>TeamCity </li>
<li>and much, much more … </li>
</ol>
<p>For starters, let’s see how to create a simple GWT fat client that talks to the REST-full Web services. As an example,</p>
<p> <span id="more-266"></span>
<p>let’s think about contact management scenario where we’re going to create a web client that will be used to browse all your existing contacts.</p>
<p>We’re going to use:</p>
<ol>
<li>GWT 1.6 + GWT RPC </li>
<li>Eclipse Ganymede + GWT Eclipse plugin </li>
</ol>
<p>After creating a basic GWT project (in Eclipse you can use “Create GWT Project” icon on the toolbar), create a simple client (see the attached source code).</p>
<p>The client I’ll be using in my examples is very simple, but there are a couple of key points you should note. To make the GWT client to connect to the back end via GWT RPC you need to create 3 different classes:</p>
<ol>
<li>ContactManagerService – Client side RPC stub </li>
<li>ContactManagerServiceAsync &#8211; The asyncronous counterpart of GreetingService </li>
<li>ContactManagerServiceImpl &#8211; The server side implementation of the RPC service </li>
</ol>
<pre>
<pre class="brush: java;">package com.igorshare.client;
@RemoteServiceRelativePath(&quot;contacts&quot;)
public interface ContactManagerService extends RemoteService {
	List&lt;ContactInfo&gt; getContacts(String filter);
}

package com.igorshare.client;
public interface ContactManagerServiceAsync {
	void getContacts(String filter, AsyncCallback&lt;List&lt;ContactInfo&gt;&gt; callback);
}

package com.igorshare.server;
public class ContactManagerServiceImpl extends RemoteServiceServlet implements
		ContactManagerService {
	public List&lt;ContactInfo&gt; getContacts(String filter) { ... }
}
</pre>
</pre>
<p>Note that only serializable types can go over the wire. To make your own structure serializable, inherit it from IsSerializable interface. This will notify GWT generator to create a JSNI representation for this structure and an appropriate proxy.</p>
<p>This is how the ContactInfo class looks like:</p>
<pre>
<pre class="brush: java;">package com.igorshare.client;
public class ContactInfo implements IsSerializable {

	public String FirstName;
	public String LastName;
	public String Company;

	...
}
</pre>
</pre>
<p>This is as much ceremony as need to make sure that there is a REST-full communication between the server side and the client side.</p>
<p>To make a call to our new server, on the client side, a reference to the server proxy is needed as well as definition an asynchronous callback which&#160; will handle a success and a failure of the execution. In our example the failure is not really handled – only an error message logged. On success – the contact table is cleaned and populated with the new data that came from the server.</p>
<pre>
<pre class="brush: java;">private final ContactManagerServiceAsync greetingService = GWT
		.create(ContactManagerService.class);

...

// Add a handler to send the search criteria to the server
sendButton.addClickHandler(new ClickHandler() {
	/**
	 * Fired when the user clicks on the sendButton.
	 */
	public void onClick(ClickEvent event) {
		sendNameToServer();
	}

	/**
	 * Send the name from the nameField to the server and wait for a
	 * response.
	 */
	private void sendNameToServer() {
		greetingService.getContacts(filterField.getText(),
				new AsyncCallback&lt;List&lt;ContactInfo&gt;&gt;() {
					public void onFailure(Throwable caught) {
						// Show the RPC error message to the user
						GWT.log(&quot;Remote Procedure Call - Failure&quot;, caught);
					}

					public void onSuccess(List&lt;ContactInfo&gt; result) {
						contacts = result;
						updateContactTable();
					}

					private void updateContactTable()
					{
						// Clean contacts table
						for(int i=contactsTable.getRowCount()-1; i&gt;0; i--)
							contactsTable.removeRow(i);

						// Fill the table with the data from the server
						for(ContactInfo contact : contacts)
						{
							int row = contactsTable.getRowCount();
							contactsTable.setText(row, 0, contact.FirstName);
							contactsTable.setText(row, 1, contact.LastName);
							contactsTable.setText(row, 2, contact.Company);
						}
					}
				});
	}
});
</pre>
</pre>
<p>&#160;</p>
<p>One more thing you should remember is that the relative path to the service (See the&#160; @RemoteServiceRelativePath(&quot;contacts&quot;)&#160; annotation on the ContactManagerService) should correspond to the path in the web.xml file:</p>
<pre>
<pre class="brush: xml;">&lt;servlet&gt;
	&lt;servlet-name&gt;contactsServlet&lt;/servlet-name&gt;
	&lt;servlet-class&gt;com.igorshare.server.ContactManagerServiceImpl&lt;/servlet-class&gt;
&lt;/servlet&gt;
&lt;servlet-mapping&gt;
	&lt;servlet-name&gt;contactsServlet&lt;/servlet-name&gt;
	&lt;url-pattern&gt;/contactmanager/contacts&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;
</pre>
</pre>
<p>&#160;</p>
<p>On the next post I’ll show how to make this GWT client to talk to a JAX-RS REST-full web service. I’ll use <a href="https://jersey.dev.java.net/">Jersey</a> to enable our back-end service.&#160; Stay tuned …</p>
<p><a href="http://cid-49af16156c2594a4.skydrive.live.com/self.aspx/Public/Blog%20Source%20Code/GWT%20fat%20Client/ContactManager%20-%20part%201.zip"><img style="border-width:0;" border="0" src="http://igorshare.files.wordpress.com/2008/02/image4.png?w=213&amp;h=37&amp;h=37" /></a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/igorshare.wordpress.com/266/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/igorshare.wordpress.com/266/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/igorshare.wordpress.com/266/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/igorshare.wordpress.com/266/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/igorshare.wordpress.com/266/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/igorshare.wordpress.com/266/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/igorshare.wordpress.com/266/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/igorshare.wordpress.com/266/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/igorshare.wordpress.com/266/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/igorshare.wordpress.com/266/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=igorshare.wordpress.com&blog=2434376&post=266&subd=igorshare&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://igorshare.wordpress.com/2009/05/18/building-fat-gwt-web-clients-intro-how-to-create-a-gwt-rpc-client/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/96b0fd2825bdeb9f9039b1259156b91b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">IgorM</media:title>
		</media:content>

		<media:content url="http://igorshare.files.wordpress.com/2008/02/image4.png?w=213&#38;h=37&#38;h=37" medium="image" />
	</item>
		<item>
		<title>Tree event handler in GWT 1.6</title>
		<link>http://igorshare.wordpress.com/2009/04/28/tree-event-handler-in-gwt-16/</link>
		<comments>http://igorshare.wordpress.com/2009/04/28/tree-event-handler-in-gwt-16/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 23:56:28 +0000</pubDate>
		<dc:creator>igormoochnick</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://igorshare.wordpress.com/2009/04/28/tree-event-handler-in-gwt-16/</guid>
		<description><![CDATA[The documentation was a little sparse so, if you’d like to subscribe to the click events on the tree nodes you need to add a selection handler.
This is how you add a selection handler to the whole tree:

Tree optionsTree = new Tree();
optionsTree.addSelectionHandler(new SelectionHandler()
{
    @Override
    public void onSelection(SelectionEvent event)
  [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=igorshare.wordpress.com&blog=2434376&post=261&subd=igorshare&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The documentation was a little sparse so, if you’d like to subscribe to the click events on the tree nodes you need to add a selection handler.</p>
<p>This is how you add a selection handler to the whole tree:</p>
<pre>
<pre class="brush: java;">Tree optionsTree = new Tree();
optionsTree.addSelectionHandler(new SelectionHandler()
{
    @Override
    public void onSelection(SelectionEvent event)
    {
        Window.alert(event.getSelectedItem().getText());
    }
});
</pre>
</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/igorshare.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/igorshare.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/igorshare.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/igorshare.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/igorshare.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/igorshare.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/igorshare.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/igorshare.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/igorshare.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/igorshare.wordpress.com/261/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=igorshare.wordpress.com&blog=2434376&post=261&subd=igorshare&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://igorshare.wordpress.com/2009/04/28/tree-event-handler-in-gwt-16/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/96b0fd2825bdeb9f9039b1259156b91b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">IgorM</media:title>
		</media:content>
	</item>
		<item>
		<title>Deploying GWT applications on Tomcat</title>
		<link>http://igorshare.wordpress.com/2009/04/19/deploying-gwt-applications-on-tomcat/</link>
		<comments>http://igorshare.wordpress.com/2009/04/19/deploying-gwt-applications-on-tomcat/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 04:35:09 +0000</pubDate>
		<dc:creator>igormoochnick</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tomcat]]></category>

		<guid isPermaLink="false">http://igorshare.wordpress.com/2009/04/19/deploying-gwt-applications-on-tomcat/</guid>
		<description><![CDATA[If you’re looking for some guidance about deploying GWT applications on Tomcat, I found these articles helpful:

Deploy Google Web Toolkit(GWT) Applications using Tomcat
gwt-examples &#8211; tomcat6 Documentation

       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=igorshare.wordpress.com&blog=2434376&post=259&subd=igorshare&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>If you’re looking for some guidance about deploying GWT applications on Tomcat, I found these articles helpful:</p>
<ol>
<li><a href="http://designandcode.blogspot.com/2006/09/deploy-google-web-toolkitgwt.html">Deploy Google Web Toolkit(GWT) Applications using Tomcat</a></li>
<li><a href="http://code.google.com/p/gwt-examples/wiki/gwtTomcat">gwt-examples &#8211; tomcat6 Documentation</a></li>
</ol>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/igorshare.wordpress.com/259/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/igorshare.wordpress.com/259/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/igorshare.wordpress.com/259/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/igorshare.wordpress.com/259/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/igorshare.wordpress.com/259/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/igorshare.wordpress.com/259/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/igorshare.wordpress.com/259/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/igorshare.wordpress.com/259/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/igorshare.wordpress.com/259/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/igorshare.wordpress.com/259/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=igorshare.wordpress.com&blog=2434376&post=259&subd=igorshare&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://igorshare.wordpress.com/2009/04/19/deploying-gwt-applications-on-tomcat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/96b0fd2825bdeb9f9039b1259156b91b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">IgorM</media:title>
		</media:content>
	</item>
	</channel>
</rss>