<?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>It's Just a Bunch of Stuff That Happens &#187; GWT</title>
	<atom:link href="http://stuffthathappens.com/blog/category/gwt/feed/" rel="self" type="application/rss+xml" />
	<link>http://stuffthathappens.com/blog</link>
	<description>Technology and Geek Stuff by Eric Burke</description>
	<lastBuildDate>Fri, 04 Jun 2010 14:44:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Custom HTTP Headers with GWT RPC</title>
		<link>http://stuffthathappens.com/blog/2009/12/22/custom-http-headers-with-gwt-rpc/</link>
		<comments>http://stuffthathappens.com/blog/2009/12/22/custom-http-headers-with-gwt-rpc/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 20:09:36 +0000</pubDate>
		<dc:creator>Eric Burke</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[HOWTO]]></category>

		<guid isPermaLink="false">http://stuffthathappens.com/blog/?p=1593</guid>
		<description><![CDATA[Prior to GWT 2.0, there was no easy way to add custom HTTP headers when making remote procedure calls. The new RpcRequestBuilder in GWT 2.0 makes it easy to add custom headers.
// start with a custom RpcRequestBuilder
RpcRequestBuilder reqBuilder = new RpcRequestBuilder() {
  @Override
  protected RequestBuilder doCreate(String serviceEntryPoint) {
    RequestBuilder rb [...]]]></description>
			<content:encoded><![CDATA[<p>Prior to GWT 2.0, there was no easy way to add custom HTTP headers when making remote procedure calls. The new <a href="http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/gwt/user/client/rpc/RpcRequestBuilder.html">RpcRequestBuilder</a> in GWT 2.0 makes it easy to add custom headers.</p>
<pre class="prettyprint">// start with a custom RpcRequestBuilder
RpcRequestBuilder reqBuilder = new RpcRequestBuilder() {
  @Override
  protected RequestBuilder doCreate(String serviceEntryPoint) {
    RequestBuilder rb = super.doCreate(serviceEntryPoint);
    rb.setHeader("username", "sookie_stackhouse");
    return rb;
  }
};

// as with any other RPC, use GWT.create(...) to generate the client proxy
MyServiceAsync service = (MyServiceAsync) GWT.create(MyService.class);

// all client proxies also implement ServiceDefTarget
((ServiceDefTarget) service).setRpcRequestBuilder(reqBuilder);

// make calls as normal
service.doFunAndInterestingThings();</pre>
]]></content:encoded>
			<wfw:commentRss>http://stuffthathappens.com/blog/2009/12/22/custom-http-headers-with-gwt-rpc/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>GWT Glass Pane</title>
		<link>http://stuffthathappens.com/blog/2009/10/03/gwt-glass-pane/</link>
		<comments>http://stuffthathappens.com/blog/2009/10/03/gwt-glass-pane/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 14:25:45 +0000</pubDate>
		<dc:creator>Eric Burke</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[HTML and CSS]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://stuffthathappens.com/blog/?p=1466</guid>
		<description><![CDATA[This code darkens the entire screen, allowing you to create lightbox effects when showing dialogs. For example, here is the normal screen:

And here is how the screen looks with a glass pane and dialog:

There are GWT component libraries that do this sort of thing, for example GlassPanel, but I prefer to minimize external dependencies. Instead, [...]]]></description>
			<content:encoded><![CDATA[<p>This code darkens the entire screen, allowing you to create lightbox effects when showing dialogs. For example, here is the normal screen:</p>
<p><a href="http://stuffthathappens.com/blog/wp-content/uploads/2009/10/lightbox1.png"><img src="http://stuffthathappens.com/blog/wp-content/uploads/2009/10/lightbox1-300x225.png" alt="Lightbox 1" title="Lightbox 1" width="300" height="225" class="alignnone size-medium wp-image-1467" /></a></p>
<p>And here is how the screen looks with a glass pane and dialog:</p>
<p><a href="http://stuffthathappens.com/blog/wp-content/uploads/2009/10/lightbox2.png"><img src="http://stuffthathappens.com/blog/wp-content/uploads/2009/10/lightbox2-300x225.png" alt="Lightbox 2" title="Lightbox 2" width="300" height="225" class="alignnone size-medium wp-image-1468" /></a></p>
<p>There are GWT component libraries that do this sort of thing, for example <a href="http://code.google.com/p/google-web-toolkit-incubator/wiki/GlassPanel">GlassPanel</a>, but I prefer to minimize external dependencies. Instead, I decided to try <a href="http://groups.google.com/group/google-web-toolkit/msg/1bbc660dbb6a1a6d">this code example</a> by Evaldas Taroza.</p>
<h3>My Changes</h3>
<p>I made a few changes to the original code:</p>
<ul>
<li>Since I&#8217;m using GWT 1.7, I implement <code>ResizeHandler</code> instead of <code>WindowResizeListener</code>, which is deprecated.</li>
<li>I&#8217;m removing the <a href="https://developer.mozilla.org/en/CSS/opacity">-moz-opacity</a> since it is specific to older versions of Mozilla and no longer seems relevant.</li>
</ul>
<h3>The Final Code</h3>
<p>First, here is the CSS file:</p>
<pre class="prettyprint">.gcomp-GlassPanel {
    background-color: black;
    filter: alpha(opacity=50);
    opacity: .50;
}</pre>
<p>Next, here is the JavaDoc comment, listed separately because syntax highlighting wasn&#8217;t working here on my blog.</p>
<pre style="prettyprint">/**
 * This panel is positioned absolutely and covers the whole client
 * area of the browser. It can be used to disable everything
 * underneath it with appropriate z-index.
 * &lt;p/>
 * For instance a dialog can attach it to the root panel during
 * opening, and remove it during closing.
 * &lt;p/>
 * CSS:&lt;br>
 * .gcomp-GlassPanel
 * &lt;p/>
 * Example:&lt;br>
 * Add and remove this widget whenever you want, and style it as
 * follows:
 * &lt;pre>
 * .gcomp-GlassPanel{
 *   background-color: black;
 *   filter:alpha(opacity=50);
 *   opacity:.50;
 * }
 * &lt;/pre>
 */</pre>
<p>And here is the code&#8230;</p>
<pre class="prettyprint">public class GlassPanel extends Composite implements ResizeHandler {
    public static final String STYLE = "gcomp-GlassPanel";

    private SimplePanel panel = new SimplePanel();

    public GlassPanel() {
        initWidget(panel);

        panel.setStylePrimaryName(STYLE);
        Window.addResizeHandler(this);
        resize();
    }

    public void onResize(ResizeEvent event) {
        resize();
    }

    public void show() {
        // Override the styles explicitly, because it's needed
        // every time the widget is detached
        Element elem = panel.getElement();
        DOM.setStyleAttribute(elem, "left", "0");
        DOM.setStyleAttribute(elem, "top", "0");
        DOM.setStyleAttribute(elem, "position", "absolute");
        RootPanel.get().add(this);
    }

    public void hide() {
        RootPanel.get().remove(this);
    }

    private void resize() {
        panel.setSize(Window.getClientWidth() + "px",
                Window.getClientHeight() + "px");
    }
}</pre>
<p>I&#8217;ve only done minimal testing, on the latest Firefox and IE7.</p>
]]></content:encoded>
			<wfw:commentRss>http://stuffthathappens.com/blog/2009/10/03/gwt-glass-pane/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.243 seconds -->

