<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8731204716250805449</id><updated>2024-10-07T13:00:00.845+08:00</updated><category term="gwt"/><category term="GWT app"/><category term="dnd"/><category term="drag and drop"/><category term="GWT application"/><category term="Java Performance Tuning"/><category term="buttons"/><category term="demo"/><category term="google web toolkits"/><category term="gwt-ext"/><category term="integrate gwt to struts"/><category term="window"/><category term="GWT plugin for struts"/><category term="HyperV"/><category term="ICE Faces"/><category term="JSF"/><category term="Java Best Practices"/><category term="Java Collections"/><category term="Java Web Application"/><category term="Java object creation tips"/><category term="Struts2"/><category term="VMWare"/><category term="Xen"/><category term="ajax"/><category term="best ajax tool"/><category term="enterprise gwt"/><category term="google maps"/><category term="gwt-ext download"/><category term="gwt-ext tutorial"/><category term="javascript tips"/><category term="javascript tutorial"/><category term="minimize"/><category term="source code"/><category term="struts 2 gwt"/><category term="virtualization"/><category term="window size and scrolling"/><title type='text'>Happy GWT</title><subtitle type='html'>&lt;b&gt;&lt;i&gt;&quot;I created this blog to share/develop/discuss some of the works that I can contribute to all developers around the world.. Hopefully my little contributions here are helpful..&quot;&lt;/i&gt;&lt;/b&gt;</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://happygwt.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://happygwt.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8731204716250805449.post-109095870483610910</id><published>2009-10-04T02:21:00.002+08:00</published><updated>2009-10-04T02:24:08.456+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="HyperV"/><category scheme="http://www.blogger.com/atom/ns#" term="virtualization"/><category scheme="http://www.blogger.com/atom/ns#" term="VMWare"/><category scheme="http://www.blogger.com/atom/ns#" term="Xen"/><title type='text'>irtualization: VMware vs. Microsoft vs. Xen, 2009</title><content type='html'>&lt;span style=&quot;font-size:78%;&quot;&gt;Article Source: http://itmanagement.earthweb.com/entdev/article.php/3815481/Virtualization-VMware-vs-Microsoft-vs-Xen-2009.htm&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;April 15, 2009&lt;br /&gt;By &lt;/span&gt;&lt;h3 style=&quot;margin: 0pt; padding: 0pt; font-size: 11px; display: inline;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt; David Strom&lt;/span&gt;&lt;/h3&gt;It is time once again for our annual look at what has happened and will happen in the server virtualization space. For the historical record, check out the comparison of &lt;a href=&quot;http://itmanagement.earthweb.com/netsys/article.php/3739281&quot;&gt;VMware vs. Microsoft vs. Xen&lt;/a&gt; from 2008 and the same &lt;a href=&quot;http://itmanagement.earthweb.com/netsys/article.php/3659286&quot;&gt;virtualization vendor comparison&lt;/a&gt; from 2007.   &lt;p&gt; In the past year, Microsoft has come out with &lt;a href=&quot;http://blogs.zdnet.com/virtualization/?p=465&quot;&gt;Hyper-V&lt;/a&gt;, a free add-on to Windows Server 2008 for its 64-bit versions only. VMware has revamped its pricing and also gone through a couple of releases of various products. And &lt;span class=&quot;__mozilla-findbar-search&quot; style=&quot;padding: 0pt; background-color: yellow; color: black; display: inline; font-size: inherit;&quot;&gt;Citrix&lt;/span&gt;, which owns Xensource, continued to expand its alliances.    &lt;/p&gt;&lt;p&gt;  Others, such as VirtualIron.com and &lt;a href=&quot;http://www.sun.com/software/products/virtualbox/&quot;&gt;Sun&#39;s Virtual Box&lt;/a&gt;, are still hanging in there. And Cisco is starting to compete in this space with its &lt;a href=&quot;http://www.cisco.com/en/US/netsol/ns151/networking_solutions_unified_communications_home.html&quot;&gt;Unified Communications platform&lt;/a&gt; that will run both HyperV and ESX on a new collection of hardware that integrates storage and switching.  &lt;/p&gt;&lt;p&gt; What makes the new Cisco gear interesting is that it will handle 384 GB of RAM and not require the purchase of 4 CPU licenses of the hypervisors that would be required on other platforms from traditional server vendors. This could save money in the long term, because many IT shops are overbuying on multiple-CPU servers just so they can get enough DIMM slots to install more RAM. &lt;/p&gt;&lt;p&gt; Let&#39;s review where the three biggest virtualization vendors are and give you a report card on how they measure up on various developments.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;We also updated our comparison chart too.&lt;/p&gt;&lt;h3&gt; 1) Pre-built appliances continue to grow &lt;/h3&gt; &lt;p&gt;  &lt;/p&gt;&lt;h3&gt;VMware: A&lt;/h3&gt; &lt;h3&gt;Microsoft: a solid C&lt;/h3&gt; &lt;h3&gt;&lt;span class=&quot;__mozilla-findbar-search&quot; style=&quot;padding: 0pt; background-color: yellow; color: black; display: inline; font-size: inherit;&quot;&gt;Citrix&lt;/span&gt;: F&lt;/h3&gt; &lt;p&gt; One of the big advantages of virtualization is the ease of creating new servers as guest virtual machines (VMs) – it just involves copying a few files and setting up a small number of configuration parameters. &lt;/p&gt;&lt;p&gt; Two of the three major virtualization vendors have pre-built &quot;appliances&quot; that they offer, and most of these are free for anyone to download and install. &lt;/p&gt;&lt;p&gt; The leader is still VMware,  &lt;a href=&quot;http://vmware.com/appliances/directory&quot;&gt;which has a list here&lt;/a&gt; of more than 1,000 appliances. There are more than &lt;a href=&quot;http://technet.microsoft.com/en-us/bb738372.aspx&quot;&gt;a dozen VDIs from Microsoft&lt;/a&gt;, but most of these are still just a collection of core Microsoft Windows products, such as SharePoint and SQL Server and different versions of Windows servers. And &lt;span class=&quot;__mozilla-findbar-search&quot; style=&quot;padding: 0pt; background-color: yellow; color: black; display: inline; font-size: inherit;&quot;&gt;Citrix&lt;/span&gt; XenServer doesn&#39;t yet have any listing of appliances but is working on having such a collection later this year.  &lt;/p&gt;&lt;h3&gt; 2) Enterprise-class VM management tools are still under development &lt;/h3&gt;  &lt;p&gt; &lt;/p&gt;&lt;h3&gt;VMware: B&lt;/h3&gt; &lt;h3&gt;Microsoft: C+&lt;/h3&gt; &lt;h3&gt;&lt;span class=&quot;__mozilla-findbar-search&quot; style=&quot;padding: 0pt; background-color: yellow; color: black; display: inline; font-size: inherit;&quot;&gt;Citrix&lt;/span&gt;: B&lt;/h3&gt; &lt;p&gt; As you get more experienced with VM creation, you find that you need all sorts of tools to manage your guest VMs and servers.  &lt;/p&gt;&lt;p&gt; The big three vendors have lots of add-on tools besides the basic hypervisor that can handle such things as:   &lt;/p&gt;&lt;p&gt;  • &lt;b&gt;dynamic provisioning&lt;/b&gt; of VMs (for such things as peak demand processing and load balancing) &lt;/p&gt;&lt;p&gt; • &lt;b&gt;role-based access controls&lt;/b&gt;  so that not everyone in your enterprise can modify or copy a VM instance (look at a new third-party tool called the &lt;a href=&quot;http://hytrust.com/&quot;&gt;Hytrust&#39;s Appliance&lt;/a&gt; for help here) &lt;/p&gt;&lt;p&gt; • &lt;b&gt;replication tools&lt;/b&gt;  to copy new guest VMs &lt;/p&gt;&lt;p&gt; • &lt;b&gt;high availability/cluster managers&lt;/b&gt;  (to enable automatic restarting of guest VMs and automatic failover) &lt;/p&gt;&lt;p&gt; • &lt;b&gt;patch management of guest VMs&lt;/b&gt;  (so you can install OS patches and upgrades across all the guest VMs) &lt;/p&gt;&lt;p&gt; • &lt;b&gt;P2V migration tools&lt;/b&gt;  &lt;/p&gt;&lt;p&gt; Many of these tools are included in the fee-based XenServer editions, while they are purchased separately from VMware. Microsoft has the fewest management tools for HyperV. &lt;/p&gt;&lt;h3&gt; 3) Hypervisors now come pre-installed with server hardware &lt;/h3&gt;  &lt;p&gt; &lt;/p&gt;&lt;h3&gt;VMware: B&lt;/h3&gt; &lt;h3&gt;Microsoft: D, but no one really cares because it’s Windows 2008&lt;/h3&gt; &lt;h3&gt;&lt;span class=&quot;__mozilla-findbar-search&quot; style=&quot;padding: 0pt; background-color: yellow; color: black; display: inline; font-size: inherit;&quot;&gt;Citrix&lt;/span&gt;: B&lt;/h3&gt; &lt;p&gt; Most of the major server manufacturers now sell their gear with a choice of hypervisors pre-installed and certified to run on their equipment. Both ESX and Xen Server come pre-installed from a number of vendors, including Dell PowerEdge R and M series, HP ProLiant DL and BL series, and IBM&#39;s BladeCenter HS21 XM. A few vendors are also looking at pre-installing Microsoft&#39;s HyperV. &lt;/p&gt;&lt;p&gt;To complicate matters even further, VMware makes two different versions of ESX, with a free version, ESXi, which has a smaller memory footprint and comes pre-installed on some servers and &lt;a href=&quot;http://www.virtualizationadmin.com/articles-tutorials/vmware-esx-articles/general/vmware-esxi-server-compare-esx-server.html&quot;&gt;lacks features found on the fee-based ESX version.&lt;/a&gt;  &lt;/p&gt;&lt;p&gt; Microsoft&#39;s HyperV comes in two versions as well, one that comes as part of its 64-bit Windows Server 2008 OS (which is the one that most people are currently using) and one called HyperV Server that is an independent free version. This free version is labeled as a bare-metal hypervisor but is basically just a command-line version of Windows to run its guest VMs on it. &lt;/p&gt; However, many people find that HyperV Server isn&#39;t much of an operating system, particularly for denser virtualized setups that require multiple network cards and storage adapters.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt; 4) Understand your guest VM licensing needs – and costs. &lt;/h3&gt;  &lt;p&gt; &lt;/p&gt;&lt;h3&gt;VMware: B-&lt;/h3&gt; &lt;h3&gt;Microsoft: A, because of Windows Enterprise licensing quirks&lt;/h3&gt; &lt;h3&gt;Citrix: B+&lt;/h3&gt; &lt;p&gt; Another balancing act is figuring out the costs of the licenses for your guest VMs versus the cost of the hypervisor or physical server pieces that you need to run them. &lt;/p&gt;&lt;p&gt; VMware in particular has one of the most complex licensing and pricing details, although they have taken steps to simplify it over the past couple of years. One of the advantages of going with Microsoft&#39;s HyperV running on the Enterprise version of Windows Server 2008 is that you can have unlimited free licenses for your guest Windows VMs, which can add up to a significant savings. Citrix&#39;s licensing is a bit easier to understand and price out than VMware&#39;s.&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Virtual Server product comparison: VMware vs Microsoft vs Xen: 2009&lt;/h3&gt;&lt;img src=&quot;http://itmanagement.earthweb.com/img/2009/04/vmware-vs-microsoft-vs-xen.jpg&quot; alt=&quot;windows&quot; align=&quot;center&quot; /&gt;</content><link rel='replies' type='application/atom+xml' href='http://happygwt.blogspot.com/feeds/109095870483610910/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8731204716250805449/109095870483610910' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/109095870483610910'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/109095870483610910'/><link rel='alternate' type='text/html' href='http://happygwt.blogspot.com/2009/10/irtualization-vmware-vs-microsoft-vs.html' title='irtualization: VMware vs. Microsoft vs. Xen, 2009'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8731204716250805449.post-434363099247123308</id><published>2009-08-05T23:44:00.001+08:00</published><updated>2009-08-06T00:02:22.676+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java object creation tips"/><title type='text'>Performance improvement techniques in Object creation</title><content type='html'>&lt;p class=&quot;headmain&quot; align=&quot;left&quot;&gt;&lt;span style=&quot;font-size:78%;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Reference: http://www.precisejava.com/javaperf/j2se/Objects.htm&lt;/span&gt;&lt;/span&gt;&lt;br /&gt; &lt;/p&gt;  &lt;p&gt;Note: This section assumes that reader has some basic knowledge of Java.&lt;/p&gt;        &lt;p class=&quot;head1&quot;&gt; &lt;a name=&quot;Objects102&quot;&gt;Optimization techniques in Object creation&lt;/a&gt;&lt;/p&gt;      &lt;span style=&quot;font-family:Arial;&quot;&gt;    &lt;/span&gt;&lt;ul&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt; &lt;li&gt;Avoid creating objects in a loop.                   &lt;/li&gt;     &lt;li&gt;Always try to use String literals instead of String objects.&lt;/li&gt;     &lt;/span&gt;&lt;/ul&gt;    &lt;p&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;Eg . &lt;span style=&quot;font-size:85%;color:#3366cc;&quot;&gt;String str1 = &quot;Hello I am here &quot;;    //String literal&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;span style=&quot;font-size:85%;color:#3366cc;&quot;&gt;        String str2= &quot;Hello  I am here &quot;;   //String literal&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;span style=&quot;font-size:85%;color:#3366cc;&quot;&gt;         String str3 = new (&quot;Hello  I  am here &quot;);  //String Object&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;When we create a String without the new operator and if the content is  already existing it uses a single instance of  the literal instead of creating a new object every time.&lt;/span&gt;&lt;/p&gt;  &lt;ul&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;  &lt;li&gt;Never create objects just for accessing a method.&lt;/li&gt;    &lt;li&gt;Whenever you are done with an object make that reference null so that it    is eligible for garbage collection.&lt;/li&gt;    &lt;li&gt;Never keep inheriting chains long since it  involves calling all the    parent constructors all along the chain until the constructor for    java.lang.Object is reached.&lt;/li&gt;    &lt;li&gt;Use primitive data types rather than using wrapper classes.&lt;/li&gt;    &lt;li&gt;Whenever possible avoid using class variables, use local  variables    since accessing local variables is faster than accessing class variables.&lt;/li&gt;    &lt;li&gt;Use techniques such as lazy evaluation. Lazy evaluation refers to the    technique of avoiding certain computations until they are absolutely    necessary. This way we put off certain computations that may never need to be    done at all.&lt;/li&gt;    &lt;li&gt;Another technique is Lazy object creation : i.e. delaying the memory    allocation to an object till it is  not being put into use. This way a    lot of memory is saved till the object is actually put in to use. &lt;/li&gt;  &lt;/span&gt;&lt;/ul&gt;  &lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;span style=&quot;font-family:Helvetica,Verdana,Geneva,Arial,sans-serif;&quot;&gt;    &lt;/span&gt;  &lt;/span&gt;&lt;p&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt; &lt;/span&gt;&lt;/p&gt;    &lt;p&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size:180%;&quot;&gt;&lt;a name=&quot;Objects103&quot;&gt;Key Points&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;                        &lt;span style=&quot;font-family:Arial;&quot;&gt;   &lt;/span&gt;&lt;ol&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;li&gt;Avoid creating objects in a loop.&lt;/li&gt;       &lt;li&gt;Use String literals instead of String objects (created using the &#39;new&#39;       keyword) if the content is same.&lt;/li&gt;       &lt;li&gt;Make used objects eligible for garbage  collection.&lt;/li&gt;       &lt;li&gt;Do not keep inheritance chains long.&lt;/li&gt;       &lt;li&gt;Accessing local variables is faster  than accessing class variables&lt;/li&gt;       &lt;li&gt;Use lazy evaluation, lazy object creation  whenever possible.&lt;/li&gt;  &lt;/span&gt;&lt;/ol&gt;</content><link rel='replies' type='application/atom+xml' href='http://happygwt.blogspot.com/feeds/434363099247123308/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8731204716250805449/434363099247123308' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/434363099247123308'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/434363099247123308'/><link rel='alternate' type='text/html' href='http://happygwt.blogspot.com/2009/08/performance-improvement-techniques-in_05.html' title='Performance improvement techniques in Object creation'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8731204716250805449.post-7521681164768471663</id><published>2009-08-05T23:38:00.001+08:00</published><updated>2009-08-05T23:44:14.499+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java Collections"/><category scheme="http://www.blogger.com/atom/ns#" term="Java Performance Tuning"/><title type='text'>Performance Improvement techniques in Java Collections</title><content type='html'>&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size:78%;&quot;&gt;Reference: http://www.precisejava.com/javaperf/j2se/Collections.htm&lt;/span&gt;&lt;br /&gt;Lists:&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family:Helvetica,Verdana,Geneva,Arial,sans-serif;&quot;&gt;  &lt;/span&gt;&lt;ol&gt;&lt;span style=&quot;font-family:Helvetica,Verdana,Geneva,Arial,sans-serif;&quot;&gt;  &lt;li&gt;      &lt;span style=&quot;font-family:Arial;&quot;&gt;Use ArrayList with proper initialization if you don&#39;t      want thread safe for the collection whenever you  add/remove/access      objects at end and middle of collection.&lt;/span&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;Use Vector with proper initialization if you want    thread safe for the collection whenever you  add/remove/access objects at    end and middle of collection.&lt;/span&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;Use LinkedList if you don&#39;t want thread safe for      the collection whenever you  add/remove/access objects at beginning of      collection.&lt;/span&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;Use synchronized LinkedList if you want thread safe      for the collection whenever you add/remove/access objects at beginning of      collection.&lt;/span&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;Use ListIterator than Iterator and Enumeration for      List types&lt;/span&gt;&lt;/li&gt;  &lt;/span&gt;&lt;/ol&gt;  &lt;span style=&quot;font-family:Helvetica,Verdana,Geneva,Arial,sans-serif;&quot;&gt;    &lt;/span&gt;&lt;p&gt;&lt;span style=&quot;font-family:Helvetica,Verdana,Geneva,Arial,sans-serif;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;Sets:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;font-family:Helvetica,Verdana,Geneva,Arial,sans-serif;&quot;&gt;    &lt;/span&gt;&lt;ol&gt;&lt;span style=&quot;font-family:Helvetica,Verdana,Geneva,Arial,sans-serif;&quot;&gt;      &lt;li&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;Use HashSet for maintaining unique objects if you      don&#39;t want thread safe for the collection for all basic(add/remove/access)      operations otherwise use synchronized HashSet for thread safe.&lt;/span&gt;&lt;/li&gt;        &lt;li&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;Use TreeSet for ordered and sorted set of unique      objects for non-thread safe collection otherwise use synchronized TreeSet      for thread safe&lt;/span&gt;&lt;/li&gt;  &lt;/span&gt;&lt;/ol&gt;  &lt;span style=&quot;font-family:Helvetica,Verdana,Geneva,Arial,sans-serif;&quot;&gt;    &lt;/span&gt;&lt;p&gt;&lt;span style=&quot;font-family:Helvetica,Verdana,Geneva,Arial,sans-serif;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;Maps:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style=&quot;font-family:Helvetica,Verdana,Geneva,Arial,sans-serif;&quot;&gt;    &lt;/span&gt;&lt;ol&gt;&lt;span style=&quot;font-family:Helvetica,Verdana,Geneva,Arial,sans-serif;&quot;&gt;      &lt;li&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;Use HashMap for non-thread safe map collection      otherwise use Hashtable for thread safe collection.&lt;/span&gt;&lt;/li&gt;        &lt;li&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;Use TreeMap for non-thread safe ordered map      collection otherwise use synchronized TreeMap for thread safe.&lt;/span&gt;&lt;/li&gt;  &lt;/span&gt;&lt;/ol&gt;</content><link rel='replies' type='application/atom+xml' href='http://happygwt.blogspot.com/feeds/7521681164768471663/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8731204716250805449/7521681164768471663' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/7521681164768471663'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/7521681164768471663'/><link rel='alternate' type='text/html' href='http://happygwt.blogspot.com/2009/08/performance-improvement-techniques-in.html' title='Performance Improvement techniques in Java Collections'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8731204716250805449.post-7220467417005876591</id><published>2009-08-05T23:28:00.008+08:00</published><updated>2009-08-05T23:32:54.807+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java Best Practices"/><category scheme="http://www.blogger.com/atom/ns#" term="Java Performance Tuning"/><category scheme="http://www.blogger.com/atom/ns#" term="Java Web Application"/><title type='text'>Tuning Performance of Java Web Application</title><content type='html'>&lt;span style=&quot;font-size:78%;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;source: http://java-junction.blogspot.com/search/label/Performance%20Tuning&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;;font-family:verdana;font-size:85%;&quot;  &gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Best Practices to improve performance in &lt;/span&gt;&lt;a href=&quot;http://java.sun.com/products/servlet/&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Servlets&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;1.    Use init() method to cache static data&lt;br /&gt;2.    Use StringBuffer/StringBuilder rather than using + operator when you concatenate multiple strings&lt;br /&gt;3.    Use print() method rather than println() method&lt;br /&gt;4.    Use ServletOutputStream rather than PrintWriter to send binary data&lt;br /&gt;5.    Initialize the PrintWriter with proper size&lt;br /&gt;6.    Flush the data partly&lt;br /&gt;7.    Minimize code in the synchronized block&lt;br /&gt;8.    Set the content length&lt;br /&gt;9.    Release resources in destroy() method.&lt;br /&gt;10.    Implement getLastModified() method to use browser cache and server cache&lt;br /&gt;11.    Use application server caching facility&lt;br /&gt;12.    Use Mixed session mechanisms such as HttpSession with hidden fields&lt;br /&gt;13.    Remove HttpSession objects explicitly in your program whenever you finish the task&lt;br /&gt;14.    Reduce session time out value as much as possible&lt;br /&gt;15. Use &#39;transient&#39; variables to reduce serialization overhead if your HttpSession tracking mechanism uses serialization process.&lt;br /&gt;16.    Disable servlet auto reloading feature.&lt;br /&gt;17.    Use thread pool for your servlet engine and define the size as per application requirement.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Best Practices to improve Performance in &lt;a href=&quot;http://java.sun.com/products/jsp/&quot;&gt;JSP&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1.    Use jspInit() method to cache static data&lt;br /&gt;2.    Use StringBuffer rather than using + operator when you concatenate multiple strings&lt;br /&gt;3.    Use print() method rather than println() method&lt;br /&gt;4.    Use ServletOutputStream instead of JSPWriter to send binary data&lt;br /&gt;5.    Initialize the &#39;out&#39; object (implicit object) with proper size in the page directive.&lt;br /&gt;6.    Flush the data partly&lt;br /&gt;7.    Minimize code in the synchronized block&lt;br /&gt;8.    Set the content length&lt;br /&gt;9.    Release resources in jspDestroy() method.&lt;br /&gt;10.    Give &#39;false&#39; value to the session in the page directive to avoid session object creation.&lt;br /&gt;11.    Use include directive instead of include action when you want to include the child page content in the translation phase.&lt;br /&gt;12.    Avoid giving unnecessary scope in the &#39;useBean&#39; action.&lt;br /&gt;13.    Do not use custom tags if you do not have reusability.&lt;br /&gt;14.    Use application server caching facility&lt;br /&gt;15.    Use Mixed session mechanisms such as &#39;session&#39; with hidden fields&lt;br /&gt;16.    Use &#39;session&#39; and &#39;application&#39; as cache.&lt;br /&gt;17.    Use caching tags provided by different organizations like openSymphony.com&lt;br /&gt;18.    Remove &#39;session&#39; objects explicitly in your program whenever you finish the task&lt;br /&gt;19.    Reduce session time out value as much as possible&lt;br /&gt;20.    Use &#39;transient&#39; variables to reduce serialization overhead if your session tracking mechanism uses serialization process.&lt;br /&gt;21.    Disable JSP auto reloading feature.&lt;br /&gt;22.    Use thread pool for your JSP engine and define the size of thread pool as per application requirement.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Best practices to improve performance in &lt;a href=&quot;http://java.sun.com/javase/technologies/database/&quot;&gt;JDBC&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1.    Get database connection from connection pool rather than getting it directly&lt;br /&gt;2.    Use batch transactions.&lt;br /&gt;3. Choose right isolation level as per your requirement. TRANSACTION_READ_UNCOMMITED gives best performance for concurrent transaction based applications. TRANSACTION_NONE gives best performance for non-concurrent transaction based applications.&lt;br /&gt;4.    Your database server may not support all isolation levels, be aware of your database server features.&lt;br /&gt;5.    Use PreparedStatement when you execute the same statement more than once.&lt;br /&gt;6.    Use CallableStatement when you want result from multiple and complex statements for a single request.&lt;br /&gt;7.    Use batch update facility available in Statements.&lt;br /&gt;8.    Use batch retrieval facility available in Statements or ResultSet.&lt;br /&gt;9.    Set up proper direction for processing rows.&lt;br /&gt;10.    Use proper getXXX () methods.&lt;br /&gt;11.    Close ResultSet, Statement and Connection whenever you finish your work with them.&lt;br /&gt;12.    Write precise SQL queries.&lt;br /&gt;13.    Cache read-only and read-mostly tables data.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Performance improvement techniques in Object creation&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1.    Avoid creating objects in a loop.&lt;br /&gt;2.    Use String literals instead of String objects (created using the &#39;new&#39; keyword) if the content is same.&lt;br /&gt;3.    Whenever you are done with an object make that reference null so that it is eligible for garbage collection.&lt;br /&gt;4. Never keep inheriting chains long since it involves calling all the parent constructors all along the chain until the constructor for java.lang.Object is reached.&lt;br /&gt;5.    Use primitive data types rather than using wrapper classes.&lt;br /&gt;6. Whenever possible avoid using class variables, use local variables since accessing local variables is faster than accessing class variables.&lt;br /&gt;7. Another technique is Lazy object creation: i.e. delaying the memory allocation to an object till it is not being put into use. This way a lot of memory is saved till the object is actually put in to use.&lt;br /&gt;Performance improvement techniques in Exceptions&lt;br /&gt;1. In a catch block avoid using the generic class Exception. For each try block use specific catch blocks based on what can go wrong in your code.&lt;br /&gt;2. Whenever you are using a throws clause always use the specific subclass of Exception like FileNotFoundException rather than using throws Exception.&lt;br /&gt;3. Always use the finally block to release the resources like a database connection, closing a file or socket connection etc. This prevents resource leaks even if an exception occurs.&lt;br /&gt;4. Do not use Exception handling in loops. It is better to place loops inside try/catch blocks than vice versa. Here is an code snippet that gives bench mark.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Performance improvement techniques in loops&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1. Always use an int data type as the loop index variable whenever possible because it is efficient when compared to using byte or short data types. because when we use byte or short data type as the loop index variable they involve implicit type cast to int data type.&lt;br /&gt;2.    When using arrays it is always efficient to copy arrays using System.arraycopy() than using a loop.&lt;br /&gt;3. Always avoid anything that can be done outside of the loop like method calls, assigning values to variables, or testing for conditions.&lt;br /&gt;4. Method calls are very costly and you only make it worse by putting them in a loop. So as far as possible avoid method calls in a loop.&lt;br /&gt;5. It is better to avoid accessing array elements in a loop the better option would be to use a temporary variables inside the loop and modify the array values out of the loop. It is fast to use a variable in a loop than accessing an array element.&lt;br /&gt;6. Try to compare the terminating condition with zero if you use non-JIT or HotSpot virtual machine, here is an example to prove the point. JIT or HotSpot virtual machines are optimized for general loops so you do not have to bother about the terminating condition.&lt;br /&gt;&lt;br /&gt;Reference: &lt;a href=&quot;http://www.precisejava.com/&quot;&gt;www.precisejava.com&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;hr /&gt;&lt;h3 class=&quot;post-title&quot;&gt;Tips For Measuring Application Performance&lt;/h3&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Here are some of important points which should be considered while measuring application performance.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;- Test systems should match production as closely as possible. Same hardware, OS, and software.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;- Populate databases with the number of records expected in production.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt; An application may perform well with a small number of records in the database. Performance could degrade a great deal as the number of records in the table(s) increases &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;- Test HTTP requests with different request parameters.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt; Test with the extremes. A page which performs a search may perform well when the search criteria returns a small result set, but perform poorly when the search criteria returns a large result set.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;- Simulate expected traffic over time including short term spikes.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;  A page which performs well with low request volume can cause the server to fail under higher request volume.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;- Use Server load testing tools (like &lt;a href=&quot;http://jakarta.apache.org/jmeter/&quot;&gt;Apache Jakarta &lt;/a&gt;&lt;/span&gt;&lt;a href=&quot;http://jakarta.apache.org/jmeter/&quot;&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_0&quot;  style=&quot;font-family:verdana;&quot;&gt;JMeter&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;) to simulate heavy load.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;hr /&gt;&lt;h3 class=&quot;post-title&quot;&gt;Tomcat - Jboss Performance Tuning Tips&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Apache &lt;a href=&quot;http://tomcat.apache.org/&quot;&gt;Tomcat&lt;/a&gt; is an implmentation of the &lt;/span&gt;&lt;a style=&quot;font-family: verdana;&quot; href=&quot;http://java.sun.com/products/servlet/&quot;&gt;Java Servlet&lt;/a&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt; and &lt;/span&gt;&lt;a style=&quot;font-family: verdana;&quot; href=&quot;http://java.sun.com/products/jsp/&quot;&gt;JavaServer Pages&lt;/a&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt; technologies.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;In production Enviroment, number of resources which can all impact application &lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;overall performance. Here are some important point which can help to improve &lt;a href=&quot;http://tomcat.apache.org/&quot;&gt;Tomcat&lt;/a&gt; Performance.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;span style=&quot;color: rgb(153, 51, 153); font-family: verdana;&quot;&gt;Performance Tuning - Tomcat Configuration&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Configure &lt;span style=&quot;font-style: italic;&quot;&gt;server.xml&lt;/span&gt; parameters as following.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic; font-family: verdana;&quot;&gt;-Set reloadable to false&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;When reloadable is true Tomcat tries to detect web application class changes and &lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;automatically reload any classes which change. Setting this to false removes a lot of &lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;unnecessary overhead in production.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic; font-family: verdana;&quot;&gt;-Set liveDeploy to false&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;liveDeploy controls whether your webapps directory is periodically checked for new&lt;/span&gt; &lt;span style=&quot;font-family: verdana;&quot;&gt;web application directories and war files. This is done using a background thread. &lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Set this to false and use the manager application or ant deploy tasks instead.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic; font-family: verdana;&quot;&gt;-Set debug to 0&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Disable all debug output, unnecessary logging just adds overhead.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic; font-family: verdana;&quot;&gt;-Set swallowOutput to true&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This makes sure all output to stdout or stderr for a web application gets directed to&lt;/span&gt; &lt;span style=&quot;font-family: verdana;&quot;&gt;the web application log rather than the console or catalina.out. This makes it easier &lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;to troubleshoot web application problems.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;span style=&quot;color: rgb(153, 51, 153); font-family: verdana;&quot;&gt;Performance Tuning - Jasper 2 Configuration&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Configure &lt;span style=&quot;font-style: italic;&quot;&gt;web.xml&lt;/span&gt; parameters as following.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic; font-family: verdana;&quot;&gt;-Set development to false&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Disables JSP page out of date checks on each request and enables JSP background&lt;/span&gt; &lt;span style=&quot;font-family: verdana;&quot;&gt;recompiles. development is set to true by default.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic; font-family: verdana;&quot;&gt;-Use JSP custom tag pooling&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Object pooling of classes which implement custom tags significantly improves&lt;/span&gt; &lt;span style=&quot;font-family: verdana;&quot;&gt;performance of JSP pages which use custom tag libraries. JSP custom tag pooling is &lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;enabled by default.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic; font-family: verdana;&quot;&gt;-Configure Jasper to fork javac compiles. (Do not set fork to true on MS Windows)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The JVM compiler javac has known memory leaks. Eliminates JVM memory usage&lt;/span&gt; &lt;span style=&quot;font-family: verdana;&quot;&gt;and GC overhead of javac by configuring Jasper to fork javac when compiling JSP &lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;pages.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://happygwt.blogspot.com/feeds/7220467417005876591/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8731204716250805449/7220467417005876591' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/7220467417005876591'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/7220467417005876591'/><link rel='alternate' type='text/html' href='http://happygwt.blogspot.com/2009/08/tuning-performance-of-java-web.html' title='Tuning Performance of Java Web Application'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8731204716250805449.post-5487719934647998514</id><published>2009-08-03T12:28:00.001+08:00</published><updated>2009-08-03T12:31:20.024+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript tips"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="window size and scrolling"/><title type='text'>Detecting Window Size and Scrolling In Javascript</title><content type='html'>&lt;h2&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Source: http://www.howtocreate.co.uk/tutorials/javascript/browserwindow&lt;/span&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2&gt;Window size and scrolling&lt;/h2&gt;&lt;script type=&quot;text/javascript&quot;&gt; function alertSize() {  var myWidth = 0, myHeight = 0;  if( typeof( window.innerWidth ) == &#39;number&#39; ) {   myWidth = window.innerWidth; myHeight = window.innerHeight;  } else if( document.documentElement &amp;&amp; ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {   myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;  } else if( document.body &amp;&amp; ( document.body.clientWidth || document.body.clientHeight ) ) {   myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;  }  window.alert( &#39;Width = &#39; + myWidth + &#39; and height = &#39; + myHeight ); } function getScrollXY() {  var scrOfX = 0, scrOfY = 0;  if( typeof( window.pageYOffset ) == &#39;number&#39; ) {   scrOfY = window.pageYOffset; scrOfX = window.pageXOffset;  } else if( document.body &amp;&amp; ( document.body.scrollLeft || document.body.scrollTop ) ) {   scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft;  } else if( document.documentElement &amp;&amp; ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {   scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft;  }  window.alert( &#39;Horizontal scrolling = &#39; + scrOfX + &#39;\nVertical scrolling = &#39; + scrOfY ); } &lt;/script&gt;  &lt;h3&gt;Finding the size of the browser window&lt;/h3&gt;  &lt;ul class=&quot;browserbugs&quot;&gt;&lt;li&gt;Clue browser can only work out window width.&lt;/li&gt;&lt;li&gt;Tkhtml Hv3 has the body/documentElement clientHeight/Width values reversed - versions before September 2007 also do not support innerHeight/Width, so they cannot work with this script.&lt;/li&gt;&lt;/ul&gt;  &lt;p&gt;There are some constants available that give the document area of the window that is available for writing to. These will not be available until after the document has loaded and the method used for referencing them is browser specific. The available constants are:&lt;/p&gt;  &lt;dl&gt;&lt;dt&gt;&lt;var&gt;window.innerHeight/Width&lt;/var&gt;&lt;/dt&gt;&lt;dd&gt;Provided by most browsers, but importantly, not Internet Explorer.&lt;/dd&gt;&lt;dt&gt;&lt;var&gt;document.body.clientHeight/Width&lt;/var&gt;&lt;/dt&gt;&lt;dd&gt;Provided by many browsers, including Internet Explorer.&lt;/dd&gt;&lt;dt&gt;&lt;var&gt;document.documentElement.­clientHeight/Width&lt;/var&gt;&lt;/dt&gt;&lt;dd&gt;Provided by most DOM browsers, including Internet Explorer.&lt;/dd&gt;&lt;/dl&gt;  &lt;p&gt;This is a little messy because the &lt;var&gt;clientHeight/Width&lt;/var&gt; properties can mean different things in different browsers, and even different things in the same browser, depending on whether the document type declaration triggers the browser&#39;s strict mode or quirks mode. In some cases, they refer to the dimensions of the window, and sometimes they refer to the dimensions of the contents of the document. The table below shows what the properties mean in different browsers, and different modes:&lt;/p&gt;  &lt;table&gt;  &lt;caption&gt;Properties and what they relate to&lt;/caption&gt;  &lt;thead&gt;   &lt;tr&gt;    &lt;th&gt;Browser&lt;/th&gt;    &lt;th&gt;window.&lt;br /&gt;innerHeight&lt;/th&gt;    &lt;th&gt;document.&lt;br /&gt;body.&lt;br /&gt;clientHeight&lt;/th&gt;    &lt;th&gt;document.&lt;br /&gt;documentElement.&lt;br /&gt;clientHeight&lt;/th&gt;  &lt;/tr&gt;&lt;/thead&gt;  &lt;tbody&gt;   &lt;tr&gt;&lt;th&gt;Opera 9.5+ strict&lt;/th&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;document&lt;/td&gt;&lt;td&gt;window&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;th&gt;Opera 9.5+ quirks&lt;/th&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;document&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;th&gt;Opera 7-9.2&lt;/th&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;document&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;th&gt;Opera 6&lt;/th&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;N/A&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;th&gt;Mozilla strict&lt;/th&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;document&lt;/td&gt;&lt;td&gt;window&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;th&gt;Mozilla quirks&lt;/th&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;document&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;th&gt;KHTML&lt;/th&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;document&lt;/td&gt;&lt;td&gt;document&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;th&gt;Safari&lt;/th&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;document&lt;/td&gt;&lt;td&gt;document&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;th&gt;iCab 3&lt;/th&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;document&lt;/td&gt;&lt;td&gt;document&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;th&gt;iCab 2&lt;/th&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;N/A&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;th&gt;IE 6+ strict&lt;/th&gt;&lt;td&gt;N/A&lt;/td&gt;&lt;td&gt;document&lt;/td&gt;&lt;td&gt;window&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;th&gt;IE 5-7 quirks&lt;/th&gt;&lt;td&gt;N/A&lt;/td&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;th&gt;IE 4&lt;/th&gt;&lt;td&gt;N/A&lt;/td&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;N/A&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;th&gt;ICEbrowser&lt;/th&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;document&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;th&gt;Tkhtml Hv3&lt;/th&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;document&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;th&gt;Netscape 4&lt;/th&gt;&lt;td&gt;window&lt;/td&gt;&lt;td&gt;N/A&lt;/td&gt;&lt;td&gt;N/A&lt;/td&gt;&lt;/tr&gt;  &lt;/tbody&gt; &lt;/table&gt;  &lt;p&gt;As you can see, the browsers seem to have settled on at least one reliable property; &lt;var&gt;innerHeight&lt;/var&gt;. Internet Explorer is the one that cannot make up its mind, and its influence means that other browsers change their &lt;var&gt;clientHeight&lt;/var&gt; behaviour in different versions in order to match it. For now, almost all browsers provide &lt;var&gt;window.innerHeight/Width&lt;/var&gt; so that can be used. Internet Explorer has chosen to swap the values around when it is in strict mode. Fortunately, it gives 0 in quirks mode. This means that if we see a value on the &lt;var&gt;documentElement&#39;s&lt;/var&gt; properties, and the browser does not provide the properties on the &lt;var&gt;window&lt;/var&gt; object, we can assume it is Internet Explorer in strict mode.&lt;/p&gt;  &lt;p&gt;The most accurate method I could come up with uses the following algorithm, although it may have problems with future browsers, a situation which I am definitely not happy with:&lt;/p&gt;  &lt;ol&gt;&lt;li&gt;If window.innerHeight/Width is provided, that is fully trustworthy, use that (Hooray!).&lt;/li&gt;&lt;li&gt;Else if document.documentElement.clientHeight/Width is provided and either one is greater than 0, use that.&lt;/li&gt;&lt;li&gt;Else use document.body.clientHeight/Width.&lt;/li&gt;&lt;/ol&gt;  &lt;p&gt;This algorithm will fail with IE 6+ in &#39;standards compliant mode&#39; if the window is shrunk to 0px by 0px. This is only possible when the user actively shrinks the window to hide the page within it. Even then, it will just give the height of the document instead, so it should not be a problem. The following code performs the algorithm as described.&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;function alertSize() {&lt;br /&gt; var myWidth = 0, myHeight = 0;&lt;br /&gt; if( typeof( window.innerWidth ) == &#39;number&#39; ) {&lt;br /&gt;   &lt;span class=&quot;comment&quot;&gt;//Non-IE&lt;/span&gt;&lt;br /&gt;   myWidth = window.innerWidth;&lt;br /&gt;   myHeight = window.innerHeight;&lt;br /&gt; } else if( document.documentElement &amp;amp;&amp;amp; ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {&lt;br /&gt;   &lt;span class=&quot;comment&quot;&gt;//IE 6+ in &#39;standards compliant mode&#39;&lt;/span&gt;&lt;br /&gt;   myWidth = document.documentElement.clientWidth;&lt;br /&gt;   myHeight = document.documentElement.clientHeight;&lt;br /&gt; } else if( document.body &amp;amp;&amp;amp; ( document.body.clientWidth || document.body.clientHeight ) ) {&lt;br /&gt;   &lt;span class=&quot;comment&quot;&gt;//IE 4 compatible&lt;/span&gt;&lt;br /&gt;   myWidth = document.body.clientWidth;&lt;br /&gt;   myHeight = document.body.clientHeight;&lt;br /&gt; }&lt;br /&gt; window.alert( &#39;Width = &#39; + myWidth );&lt;br /&gt; window.alert( &#39;Height = &#39; + myHeight );&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;Test it here: &lt;a href=&quot;javascript:alertSize();&quot;&gt;get the inner dimensions of this window&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Note that browsers may take the width either inside or outside the scrollbar (if there is one). I do not cover any way to work with these differences.&lt;/p&gt;  &lt;h3&gt;Finding how far the window has been scrolled&lt;/h3&gt;  &lt;ul class=&quot;browserbugs&quot;&gt;&lt;li&gt;OmniWeb 4.2-, NetFront 3.3- and Clue browser do not provide any way to do this.&lt;/li&gt;&lt;li&gt;Safari and OmniWeb 4.5+ have bugs that do not affect this script - see below.&lt;/li&gt;&lt;/ul&gt;  &lt;p&gt;When trying to produce document effects like falling snow, or more serious things like menus that remain in the same place relative to the browser window when the user scrolls, it is essential to be able to obtain the scrolling offsets in both the horizontal and vertical direction.&lt;/p&gt;  &lt;p&gt;There are also three ways to find this out, but it is easier than finding the size of the window. Most browsers provide &lt;var&gt;window.pageXOffset/pageYOffset&lt;/var&gt;. These are completely reliable. Once again, Internet Explorer is the odd one out, as it does not provide these properties. Internet Explorer and some other browsers will provide &lt;var&gt;document.body.scrollLeft/Top&lt;/var&gt;. In strict mode, IE 6 and a few other browsers, provide &lt;var&gt;document.documentElement.scrollLeft/Top&lt;/var&gt;.&lt;/p&gt;  &lt;p&gt;If the &lt;var&gt;scrollLeft/Top&lt;/var&gt; properties are provided on either the &lt;var&gt;document.body&lt;/var&gt; or &lt;var&gt;document.documentElement&lt;/var&gt;, they are reliable in everything except Safari and OmniWeb 4.5+, which return -8 if the scrolling is 0, but get all other scrolling offsets correct. However, as they correctly provide &lt;var&gt;window.pageXOffset/pageYOffset&lt;/var&gt;, this script will not have any problems.&lt;/p&gt;  &lt;p&gt;The following script will obtain the scrolling offsets.&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;function getScrollXY() {&lt;br /&gt; var scrOfX = 0, scrOfY = 0;&lt;br /&gt; if( typeof( window.pageYOffset ) == &#39;number&#39; ) {&lt;br /&gt;   &lt;span class=&quot;comment&quot;&gt;//Netscape compliant&lt;/span&gt;&lt;br /&gt;   scrOfY = window.pageYOffset;&lt;br /&gt;   scrOfX = window.pageXOffset;&lt;br /&gt; } else if( document.body &amp;amp;&amp;amp; ( document.body.scrollLeft || document.body.scrollTop ) ) {&lt;br /&gt;   &lt;span class=&quot;comment&quot;&gt;//DOM compliant&lt;/span&gt;&lt;br /&gt;   scrOfY = document.body.scrollTop;&lt;br /&gt;   scrOfX = document.body.scrollLeft;&lt;br /&gt; } else if( document.documentElement &amp;amp;&amp;amp; ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {&lt;br /&gt;   &lt;span class=&quot;comment&quot;&gt;//IE6 standards compliant mode&lt;/span&gt;&lt;br /&gt;   scrOfY = document.documentElement.scrollTop;&lt;br /&gt;   scrOfX = document.documentElement.scrollLeft;&lt;br /&gt; }&lt;br /&gt; return [ scrOfX, scrOfY ];&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;Test it here: &lt;a href=&quot;javascript:getScrollXY();&quot;&gt;get the scrolling offsets&lt;/a&gt;.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://happygwt.blogspot.com/feeds/5487719934647998514/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8731204716250805449/5487719934647998514' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/5487719934647998514'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/5487719934647998514'/><link rel='alternate' type='text/html' href='http://happygwt.blogspot.com/2009/08/detecting-window-size-and-scrolling-in.html' title='Detecting Window Size and Scrolling In Javascript'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8731204716250805449.post-2099870119858786560</id><published>2009-07-25T22:27:00.002+08:00</published><updated>2009-07-25T22:30:02.837+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ICE Faces"/><category scheme="http://www.blogger.com/atom/ns#" term="JSF"/><category scheme="http://www.blogger.com/atom/ns#" term="Struts2"/><title type='text'>Struts2 + Struts2 JSF plugin + ICE Faces</title><content type='html'>I found that there are a lot of people are looking for example or guide to make ICEfaces work together in a Struts 2 framework. Perhaps somebody who know the way can give some guides here...</content><link rel='replies' type='application/atom+xml' href='http://happygwt.blogspot.com/feeds/2099870119858786560/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8731204716250805449/2099870119858786560' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/2099870119858786560'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/2099870119858786560'/><link rel='alternate' type='text/html' href='http://happygwt.blogspot.com/2009/07/struts2-struts2-jsf-plugin-ice-faces.html' title='Struts2 + Struts2 JSF plugin + ICE Faces'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8731204716250805449.post-5150664990488995583</id><published>2009-07-07T16:50:00.002+08:00</published><updated>2009-07-07T17:01:01.970+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="enterprise gwt"/><category scheme="http://www.blogger.com/atom/ns#" term="google web toolkits"/><category scheme="http://www.blogger.com/atom/ns#" term="gwt"/><category scheme="http://www.blogger.com/atom/ns#" term="GWT app"/><category scheme="http://www.blogger.com/atom/ns#" term="GWT plugin for struts"/><category scheme="http://www.blogger.com/atom/ns#" term="gwt-ext"/><category scheme="http://www.blogger.com/atom/ns#" term="integrate gwt to struts"/><title type='text'>GWT plugin for Struts</title><content type='html'>The source of this tutorial: &lt;a href=&quot;http://cwiki.apache.org/S2PLUGINS/gwt-plugin.html&quot;&gt;http://cwiki.apache.org/S2PLUGINS/gwt-plugin.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This plugin can be used to call methods on Struts actions using Google Web Toolkit (GWT):&lt;br /&gt;&lt;table class=&quot;confluenceTable&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th class=&quot;confluenceTh&quot;&gt;Name         &lt;/th&gt; &lt;td class=&quot;confluenceTd&quot;&gt; GWT Plugin &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th class=&quot;confluenceTh&quot;&gt;Publisher    &lt;/th&gt; &lt;td class=&quot;confluenceTd&quot;&gt; &lt;span class=&quot;nobr&quot;&gt;&lt;a href=&quot;http://cwiki.apache.org/confluence/users/viewuserprofile.action?username=musachy&quot; title=&quot;View profile for Musachy Barroso&quot;&gt;&lt;sup&gt;&lt;img class=&quot;rendericon&quot; src=&quot;http://cwiki.apache.org/confluence/images/icons/user_12.gif&quot; alt=&quot;&quot; width=&quot;12&quot; align=&quot;absmiddle&quot; border=&quot;0&quot; height=&quot;12&quot; /&gt;&lt;/sup&gt;Musachy Barroso&lt;/a&gt;&lt;/span&gt;, &lt;a href=&quot;http://cwiki.apache.org/S2PLUGINS/sean-mcrae.html&quot; title=&quot;Sean McRae&quot;&gt;Sean McRae&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th class=&quot;confluenceTh&quot;&gt;License      &lt;/th&gt; &lt;td class=&quot;confluenceTd&quot;&gt; Open Source (ASL2) &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th class=&quot;confluenceTh&quot;&gt;Version      &lt;/th&gt; &lt;td class=&quot;confluenceTd&quot;&gt; 0.2 stable &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th class=&quot;confluenceTh&quot;&gt;Compatibility&lt;/th&gt; &lt;td class=&quot;confluenceTd&quot;&gt;Struts 2.0.2+ &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th class=&quot;confluenceTh&quot;&gt;Homepage     &lt;/th&gt; &lt;td class=&quot;confluenceTd&quot;&gt; &lt;span class=&quot;nobr&quot;&gt;&lt;a href=&quot;http://code.google.com/p/struts2gwtplugin/&quot; title=&quot;Visit page outside Confluence&quot; rel=&quot;nofollow&quot;&gt;http://code.google.com/p/struts2gwtplugin/&lt;sup&gt;&lt;img class=&quot;rendericon&quot; src=&quot;http://cwiki.apache.org/confluence/images/icons/linkext7.gif&quot; alt=&quot;&quot; width=&quot;7&quot; align=&quot;absmiddle&quot; border=&quot;0&quot; height=&quot;7&quot; /&gt;&lt;/sup&gt;&lt;/a&gt;&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th class=&quot;confluenceTh&quot;&gt;Download     &lt;/th&gt; &lt;td class=&quot;confluenceTd&quot;&gt;  &lt;span class=&quot;nobr&quot;&gt;&lt;a href=&quot;http://code.google.com/p/struts2gwtplugin/downloads/list&quot; title=&quot;Visit page outside Confluence&quot; rel=&quot;nofollow&quot;&gt;http://code.google.com/p/struts2gwtplugin/downloads/list&lt;sup&gt;&lt;img class=&quot;rendericon&quot; src=&quot;http://cwiki.apache.org/confluence/images/icons/linkext7.gif&quot; alt=&quot;&quot; width=&quot;7&quot; align=&quot;absmiddle&quot; border=&quot;0&quot; height=&quot;7&quot; /&gt;&lt;/sup&gt;&lt;/a&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;h2&gt;Example&lt;/h2&gt;  &lt;h3&gt;&lt;a name=&quot;GWTPlugin-SetupAction&quot;&gt;&lt;/a&gt;Setup Action&lt;/h3&gt;  &lt;p&gt;Start by creating an action that contains the method that is going to be called. This method needs to match the signature of the service interface, but you don&#39;t need to implement the interface on the action. This method will be different from regular Struts 2 action methods in that it returns any object (that GWT can serialize), instead of a result name. If you want to call regular actions from GWT (not using GWT&#39;s RPC) go &lt;span class=&quot;nobr&quot;&gt;&lt;a href=&quot;http://cwiki.apache.org/WW/struts-2-gwt.html&quot; title=&quot;Visit page outside Confluence&quot; rel=&quot;nofollow&quot;&gt;here&lt;sup&gt;&lt;img class=&quot;rendericon&quot; src=&quot;http://cwiki.apache.org/confluence/images/icons/linkext7.gif&quot; alt=&quot;&quot; width=&quot;7&quot; align=&quot;absmiddle&quot; border=&quot;0&quot; height=&quot;7&quot; /&gt;&lt;/sup&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;In this example the action &quot;Hello&quot; will return the string passed to it. Remember, &lt;b&gt;the returned object is not the regular Struts result&lt;/b&gt;, it is the object that you will receive on the client side. &lt;/p&gt;  &lt;p&gt;Example:&lt;/p&gt; &lt;div class=&quot;code&quot;&gt;&lt;div class=&quot;codeContent&quot;&gt; &lt;pre class=&quot;code-java&quot;&gt;&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; class Hello {&lt;br /&gt; &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-object&quot;&gt;String&lt;/span&gt; hello(&lt;span class=&quot;code-object&quot;&gt;String&lt;/span&gt; text) {&lt;br /&gt;     &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; text;&lt;br /&gt; }&lt;br /&gt;}&lt;/pre&gt; &lt;/div&gt;&lt;/div&gt;  &lt;h3&gt;&lt;a name=&quot;GWTPlugin-Writethemappingfortheaction&quot;&gt;&lt;/a&gt;Write the mapping for the action&lt;/h3&gt; &lt;p&gt;For any action mapping that is going to be called from GWT:&lt;/p&gt; &lt;ol&gt;&lt;li&gt;Add the map inside a package that extends &quot;gwt-default&quot;&lt;/li&gt;&lt;li&gt;Add the &quot;gwt&quot; interceptor to the mapping&lt;/li&gt;&lt;/ol&gt;   &lt;p&gt;Example:&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&amp;gt;&lt;br /&gt;&amp;lt;!DOCTYPE struts PUBLIC&lt;br /&gt;    &quot;-//Apache Software Foundation//DTD Struts Configuration 2.0//EN&quot;&lt;br /&gt;    &quot;http://struts.apache.org/dtds/struts-2.0.dtd&quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;struts&amp;gt;&lt;br /&gt;&lt;br /&gt;  &amp;lt;constant name=&quot;struts.enable.DynamicMethodInvocation&quot; value=&quot;false&quot; /&amp;gt;&lt;br /&gt;  &amp;lt;constant name=&quot;struts.devMode&quot; value=&quot;true&quot; /&amp;gt;&lt;br /&gt;&lt;br /&gt;  &amp;lt;package name=&quot;example&quot;  extends=&quot;gwt-default&quot;&amp;gt;&lt;br /&gt;     &amp;lt;action name=&quot;Hello&quot; class=&quot;example.Hello&quot; method=&quot;hello&quot;&amp;gt;&lt;br /&gt;        &amp;lt;interceptor-ref name=&quot;gwt&quot;/&amp;gt;&lt;br /&gt;     &amp;lt;/action&amp;gt;&lt;br /&gt;  &amp;lt;/package&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/struts&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;GWT classes&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;Write the required service interface as described &lt;span class=&quot;nobr&quot;&gt;&lt;a href=&quot;http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.RemoteProcedureCalls.MakingACall.html&quot; title=&quot;Visit page outside Confluence&quot; rel=&quot;nofollow&quot;&gt;here&lt;sup&gt;&lt;img class=&quot;rendericon&quot; src=&quot;http://cwiki.apache.org/confluence/images/icons/linkext7.gif&quot; alt=&quot;&quot; width=&quot;7&quot; align=&quot;absmiddle&quot; border=&quot;0&quot; height=&quot;7&quot; /&gt;&lt;/sup&gt;&lt;/a&gt;&lt;/span&gt;. This is regular GWT stuff.&lt;/p&gt;  &lt;p&gt;As an example of the interface:&lt;/p&gt; &lt;div class=&quot;code&quot;&gt;&lt;div class=&quot;codeContent&quot;&gt; &lt;pre class=&quot;code-java&quot;&gt;&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;interface&lt;/span&gt; MyService &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; RemoteService {&lt;br /&gt;  &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-object&quot;&gt;String&lt;/span&gt; hello(&lt;span class=&quot;code-object&quot;&gt;String&lt;/span&gt; s);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;interface&lt;/span&gt; MyServiceAsync {&lt;br /&gt;  &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; void hello(&lt;span class=&quot;code-object&quot;&gt;String&lt;/span&gt; s, AsyncCallback callback);&lt;br /&gt;}&lt;/pre&gt; &lt;/div&gt;&lt;/div&gt;  &lt;p&gt;And to call it:&lt;/p&gt; &lt;div class=&quot;code&quot;&gt;&lt;div class=&quot;codeContent&quot;&gt; &lt;pre class=&quot;code-java&quot;&gt;MyServiceAsync service = (MyServiceAsync) GWT.create(MyService.class);&lt;br /&gt;AsyncCallback callback = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; AsyncCallback() {&lt;br /&gt;  &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; void onSuccess(&lt;span class=&quot;code-object&quot;&gt;Object&lt;/span&gt; result) {&lt;br /&gt;      Window.alert(result.toString());&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; void onFailure(Throwable caught) {&lt;br /&gt;      Window.alert(caught.toString());&lt;br /&gt;  }&lt;br /&gt;};&lt;br /&gt;ServiceDefTarget endpoint = (ServiceDefTarget) service;&lt;br /&gt;endpoint.setServiceEntryPoint(&lt;span class=&quot;code-quote&quot;&gt;&quot;Hello.action&quot;&lt;/span&gt;);&lt;br /&gt;service.hello(&lt;span class=&quot;code-quote&quot;&gt;&quot;Hi There!&quot;&lt;/span&gt;, callback);&lt;/pre&gt; &lt;/div&gt;&lt;/div&gt;  &lt;h2&gt;&lt;a name=&quot;GWTPlugin-Installation&quot;&gt;&lt;/a&gt;Installation&lt;/h2&gt;  &lt;p&gt;This plugin can be installed by copying the plugin jar and gwt-servlet.jar (from GWT) into your application&#39;s &lt;tt&gt;/WEB-INF/lib&lt;/tt&gt; directory.  No other files need to be copied or created.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://happygwt.blogspot.com/feeds/5150664990488995583/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8731204716250805449/5150664990488995583' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/5150664990488995583'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/5150664990488995583'/><link rel='alternate' type='text/html' href='http://happygwt.blogspot.com/2009/07/gwt-plugin-for-struts.html' title='GWT plugin for Struts'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8731204716250805449.post-7927750512679389784</id><published>2009-07-07T16:40:00.004+08:00</published><updated>2009-07-07T17:04:35.191+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="gwt"/><category scheme="http://www.blogger.com/atom/ns#" term="GWT app"/><category scheme="http://www.blogger.com/atom/ns#" term="GWT application"/><category scheme="http://www.blogger.com/atom/ns#" term="integrate gwt to struts"/><category scheme="http://www.blogger.com/atom/ns#" term="struts 2 gwt"/><title type='text'>Integrate GWT into Struts 2 Application</title><content type='html'>&lt;p&gt;Source of this tutorial: &lt;a href=&quot;http://cwiki.apache.org/WW/struts-2-gwt.html&quot;&gt;http://cwiki.apache.org/WW/struts-2-gwt.html&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;These tutorial will demonstrate how to call an Struts 2 action, using GWT to submit a form and use the returned data.&lt;/p&gt;  &lt;h3&gt;&lt;a name=&quot;Struts2+GWT-Writeyouraction.&quot;&gt;&lt;/a&gt;Write your action.&lt;/h3&gt; &lt;p&gt;Example action:&lt;/p&gt;  &lt;div class=&quot;code&quot;&gt;&lt;div class=&quot;codeHeader&quot;&gt;&lt;b&gt;&quot;Hello.java&quot;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent&quot;&gt; &lt;pre class=&quot;code-java&quot;&gt;&lt;span class=&quot;code-keyword&quot;&gt;package&lt;/span&gt; example;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-keyword&quot;&gt;import&lt;/span&gt; com.opensymphony.xwork2.Action;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; class Hello {&lt;br /&gt;&lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;code-object&quot;&gt;String&lt;/span&gt; firstName;&lt;br /&gt;&lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;code-object&quot;&gt;String&lt;/span&gt; lastName;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-object&quot;&gt;String&lt;/span&gt; execute() {&lt;br /&gt;   &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; Action.SUCCESS;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-object&quot;&gt;String&lt;/span&gt; getFirstName() {&lt;br /&gt;   &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; firstName;&lt;br /&gt;}&lt;br /&gt;&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; void setFirstName(&lt;span class=&quot;code-object&quot;&gt;String&lt;/span&gt; firstName) {&lt;br /&gt;   &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;.firstName = firstName;&lt;br /&gt;}&lt;br /&gt;&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-object&quot;&gt;String&lt;/span&gt; getLastName() {&lt;br /&gt;   &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; lastName;&lt;br /&gt;}&lt;br /&gt;&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; void setLastName(&lt;span class=&quot;code-object&quot;&gt;String&lt;/span&gt; lastName) {&lt;br /&gt;   &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;.lastName = lastName;&lt;br /&gt;}&lt;br /&gt;}&lt;/pre&gt; &lt;/div&gt;&lt;/div&gt;   &lt;h3&gt;&lt;a name=&quot;Struts2+GWT-Writethemappingforyouraction.&quot;&gt;&lt;/a&gt;Write the mapping for your action.&lt;/h3&gt; &lt;p&gt;In this example the mapping is in struts.xml:&lt;/p&gt;  &lt;div class=&quot;code&quot;&gt;&lt;div class=&quot;codeHeader&quot;&gt;&lt;b&gt;struts.xml&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&amp;gt;&lt;br /&gt;&amp;lt;!DOCTYPE struts PUBLIC&lt;br /&gt;   &quot;-//Apache Software Foundation//DTD Struts Configuration 2.0//EN&quot;&lt;br /&gt;   &quot;http://struts.apache.org/dtds/struts-2.0.dtd&quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;struts&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;package name=&quot;example&quot;  extends=&quot;struts-default&quot;&amp;gt;&lt;br /&gt;   &amp;lt;action name=&quot;Hello&quot; class=&quot;example.Hello&quot;&amp;gt;&lt;br /&gt;     &amp;lt;result type=&quot;json&quot; /&amp;gt;&lt;br /&gt;   &amp;lt;/action&amp;gt;&lt;br /&gt;&lt;br /&gt;   &amp;lt;action name=&quot;Main&quot; class=&quot;com.opensymphony.xwork2.ActionSupport&quot;&amp;gt;&lt;br /&gt;     &amp;lt;result&amp;gt;org.apache.struts.gwt.Main/Main.jsp&amp;lt;/result&amp;gt;&lt;br /&gt;   &amp;lt;/action&amp;gt;&lt;br /&gt; &amp;lt;/package&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/struts&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The &quot;Hello&quot; action  has a result of type &quot;json&quot;, which will serialize the action object into a &lt;span class=&quot;nobr&quot;&gt;&lt;a href=&quot;http://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=WW&amp;amp;title=www.json.org&amp;amp;linkCreation=true&amp;amp;fromPageId=34036&quot; title=&quot;Create Page: www.json.org&quot; class=&quot;createlink&quot;&gt;JSON&lt;sup&gt;&lt;img class=&quot;rendericon&quot; src=&quot;http://cwiki.apache.org/confluence/images/icons/plus.gif&quot; alt=&quot;&quot; width=&quot;7&quot; align=&quot;absmiddle&quot; border=&quot;0&quot; height=&quot;7&quot; /&gt;&lt;/sup&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;  &lt;p&gt; string. If &quot;firstName&quot; is set to &quot;John&quot; and &quot;lastName&quot; is set to &quot;Galt&quot;, the output of the &quot;Hello&quot; action will be:&lt;/p&gt;  &lt;div class=&quot;code&quot;&gt;&lt;div class=&quot;codeContent&quot;&gt; &lt;pre class=&quot;code-java&quot;&gt;{&lt;br /&gt;&lt;span class=&quot;code-quote&quot;&gt;&quot;firstName&quot;&lt;/span&gt; : &lt;span class=&quot;code-quote&quot;&gt;&quot;John&quot;&lt;/span&gt;,&lt;br /&gt;&lt;span class=&quot;code-quote&quot;&gt;&quot;lastName&quot;&lt;/span&gt;  : &lt;span class=&quot;code-quote&quot;&gt;&quot;Galt&quot;&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt; &lt;/div&gt;&lt;/div&gt;  &lt;p&gt;The &quot;Main&quot; action points to the &quot;Main.jsp&quot; page which is the page that uses GWT. The path of the result is &quot;org.apache.struts.gwt.Main/Main.jsp&quot;. That means that the files generated by GWT must go under a folder named &quot;org.apache.struts.gwt.Main&quot; under the root of your application. See &quot;Deployment structure&quot; for more details.&lt;/p&gt;   &lt;h3&gt;&lt;a name=&quot;Struts2+GWT-Write&amp;quot;Main.jsp&amp;quot;page.&quot;&gt;&lt;/a&gt;Write &quot;Main.jsp&quot; page.&lt;/h3&gt; &lt;p&gt;This is the page that is generated by GWT&#39;s &quot;applicationCreator&quot;. It has been renamed to .jsp because we have modified it to be a jsp page, instead of a plain html page.&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Main.jsp&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;lt;%@ taglib prefix=&quot;s&quot; uri=&quot;/struts-tags&quot; %&amp;gt;&lt;br /&gt;&amp;lt;html&amp;gt;&lt;br /&gt;  &amp;lt;head&amp;gt;&lt;br /&gt;    &amp;lt;s:head theme=&quot;ajax&quot; debug=&quot;true&quot;/&amp;gt;&lt;br /&gt;    &amp;lt;meta name=&#39;gwt:module&#39; content=&#39;org.apache.struts.gwt.Main/org.apache.struts.gwt.Main&#39;&amp;gt;&lt;br /&gt;  &amp;lt;/head&amp;gt;&lt;br /&gt;&lt;br /&gt;  &amp;lt;body&amp;gt;&lt;br /&gt;    &amp;lt;script language=&quot;javascript&quot; src=&quot;${pageContext.request.contextPath}/org.apache.struts.gwt.Main/gwt.js&quot;/&amp;gt;&lt;br /&gt;&lt;br /&gt;      &amp;lt;form id=&quot;form1&quot;&amp;gt;&lt;br /&gt;         &amp;lt;input type=&quot;text&quot; name=&quot;firstName&quot;&amp;gt;&lt;br /&gt;          &amp;lt;br/&amp;gt;&lt;br /&gt;          &amp;lt;input type=&quot;text&quot; name=&quot;lastName&quot;&amp;gt;&lt;br /&gt;          &amp;lt;span id=&quot;slot1&quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;       &amp;lt;/form&amp;gt;&lt;br /&gt;&lt;br /&gt;       &amp;lt;br/&amp;gt;&lt;br /&gt;       &amp;lt;span id=&quot;slot2&quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;  &amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;br /&gt;We set head&#39;s tag attribute &quot;theme&quot; to ajax to use Dojo, don&#39;t panic, you won&#39;t have to use it directly. Note that we have changed a few things from the original html page generated by GWT, we set &quot;content&quot; to &quot;org.apache.struts.gwt.Main/org.apache.struts.gwt.Main&quot; because the GWT generated files will be under &quot;AppRoot/org.apache.struts.gwt.Main&quot; instead of beneath root, and we set &quot;src&quot; to &quot;${pageContext.request.contextPath}/org.apache.struts.gwt.Main/gwt.js&quot; for the same reason. Without these two changes the GWT files wouldn&#39;t be loaded.&lt;br /&gt;Struts2GWTHelper&lt;br /&gt;&lt;br /&gt;This class will take care of making the request. Why? Why do I need this class? Couple of reasons, first, there is a bug on bug on HTTPRequest.asyncPost which doesn&#39;t encode the payload properly, second, if you want to submit a form, you have to encode it yourself, and this class will help you do that. Optionally you can download a jar containing this class (with more methods) from here, add this to your GWT application file (i.e Main.gwt.xml):&lt;br /&gt;&lt;br /&gt;&amp;lt;inherits name=&#39;struts2gwt.Struts2GWT&#39;/&amp;gt;&lt;br /&gt;&lt;br /&gt;and add the jar to the classpath in your compile script (i.e Main-compile.cmd) and the compile script (i.e Main-shell.cmd).&lt;br /&gt;Struts2GWTHelper .java&lt;br /&gt;&lt;br /&gt;package org.apache.struts.gwt.client;&lt;br /&gt;&lt;br /&gt;import com.google.gwt.user.client.ResponseTextHandler;&lt;br /&gt;&lt;br /&gt;public class Struts2GWTHelper {&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Make asynchronous post&lt;br /&gt;     * @param url Action url&lt;br /&gt;     * @param formId id of form that will be posted&lt;br /&gt;     * @param handler callback function&lt;br /&gt;     */&lt;br /&gt;    public static native void asyncPost(String url, String formId, ResponseTextHandler handler) /*-{&lt;br /&gt;        dojo = $wnd.dojo;&lt;br /&gt;        //don&#39;t use the dojo.io.bind({...}) shortcut, it doesn&#39;t work here&lt;br /&gt;        var request = new dojo.io.Request(url);&lt;br /&gt;        request.load = function(type, data, request) {&lt;br /&gt;            handler.@com.google.gwt.user.client.ResponseTextHandler::onCompletion(Ljava/lang/String;)(data);&lt;br /&gt;        };&lt;br /&gt;        request.formNode = dojo.byId(formId);&lt;br /&gt;        request.method = &quot;POST&quot;;&lt;br /&gt;        $wnd.dojo.io.bind(request);&lt;br /&gt;    }-*/;&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Make asynchronous post&lt;br /&gt;     * @param url Action url&lt;br /&gt;     * @param handler callback function&lt;br /&gt;     */&lt;br /&gt;    public static void asyncPost(String url, ResponseTextHandler handler) {&lt;br /&gt;        Struts2GWTHelper.asyncPost(url, handler);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;See? It wasn&#39;t that bad.&lt;br /&gt;Write your GWT entry point&lt;br /&gt;Main.java&lt;br /&gt;&lt;br /&gt;package org.apache.struts.gwt.client;&lt;br /&gt;&lt;br /&gt;import com.google.gwt.core.client.EntryPoint;&lt;br /&gt;import com.google.gwt.json.client.JSONObject;&lt;br /&gt;import com.google.gwt.json.client.JSONParser;&lt;br /&gt;import com.google.gwt.json.client.JSONString;&lt;br /&gt;import com.google.gwt.user.client.ResponseTextHandler;&lt;br /&gt;import com.google.gwt.user.client.ui.Button;&lt;br /&gt;import com.google.gwt.user.client.ui.ClickListener;&lt;br /&gt;import com.google.gwt.user.client.ui.Label;&lt;br /&gt;import com.google.gwt.user.client.ui.RootPanel;&lt;br /&gt;import com.google.gwt.user.client.ui.Widget;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * Entry point classes define &amp;lt;code&amp;gt;onModuleLoad()&amp;lt;/code&amp;gt;.&lt;br /&gt; */&lt;br /&gt;public class Main implements EntryPoint {&lt;br /&gt;    final Label label = new Label();&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * This is the entry point method.&lt;br /&gt;     */&lt;br /&gt;    public void onModuleLoad() {&lt;br /&gt;        final Button button = new Button(&quot;Click me&quot;);&lt;br /&gt;&lt;br /&gt;        button.addClickListener(new ClickListener() {&lt;br /&gt;            public void onClick(Widget sender) {&lt;br /&gt;                makeRequest();&lt;br /&gt;            }&lt;br /&gt;        });&lt;br /&gt;&lt;br /&gt;        RootPanel.get(&quot;slot1&quot;).add(button);&lt;br /&gt;        RootPanel.get(&quot;slot2&quot;).add(label);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    private void makeRequest() {&lt;br /&gt;        Struts2GWTHelper.asyncPost(&quot;Hello.action&quot;, &quot;form1&quot;, new ResponseTextHandler() {&lt;br /&gt;            public void onCompletion(String responseText) {&lt;br /&gt;                JSONObject obj = (JSONObject)JSONParser.parse(responseText);&lt;br /&gt;                JSONString firstName = (JSONString)obj.get(&quot;firstName&quot;);&lt;br /&gt;                JSONString lastName = (JSONString)obj.get(&quot;lastName&quot;);&lt;br /&gt;                label.setText(&quot;Welcome &quot; + firstName.stringValue() + &quot; &quot; + lastName.stringValue());&lt;br /&gt;            }&lt;br /&gt;        });&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The makeRequest() method will make a request to the &quot;Hello&quot; action that we created before, and will pass the fields of the form &quot;form1&quot; as parameters. Which will be populated on the action, and serialized back as JSON. Using JSONParser the JSON string is parsed into a JSON object. It is definitely not type safe as GWT Remoting, but it works.&lt;br /&gt;Create Main.gwt.xml&lt;br /&gt;&lt;br /&gt;Nothing new on this file, just as reference:&lt;br /&gt;Main.gwt.xml&lt;br /&gt;&lt;br /&gt;&amp;lt;module&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;!-- Inherit the core Web Toolkit stuff.                  --&amp;gt;&lt;br /&gt;    &amp;lt;inherits name=&#39;com.google.gwt.user.User&#39;/&amp;gt;&lt;br /&gt;    &amp;lt;inherits name=&#39;com.google.gwt.json.JSON&#39;/&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;!-- Specify the app entry point class.                   --&amp;gt;&lt;br /&gt;    &amp;lt;entry-point class=&#39;org.apache.struts.gwt.client.Main&#39;/&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/module&amp;gt;&lt;br /&gt;&lt;br /&gt;Deployment structure&lt;br /&gt;Folder     Notes&lt;br /&gt;AppRoot     The application deployment folder&lt;br /&gt;AppRoot/index.html     Welcome Page&lt;br /&gt;AppRoot/org.apache.struts.gwt.Main     Content generated by GWT (usually it gets generated into a folder named &#39;www&#39;)&lt;br /&gt;AppRoot/WEB-INF     Regular webapp files and classes&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://happygwt.blogspot.com/feeds/7927750512679389784/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8731204716250805449/7927750512679389784' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/7927750512679389784'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/7927750512679389784'/><link rel='alternate' type='text/html' href='http://happygwt.blogspot.com/2009/07/integrate-gwt-into-struts-2-application.html' title='Integrate GWT into Struts 2 Application'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8731204716250805449.post-8370371999034021467</id><published>2009-07-07T16:29:00.003+08:00</published><updated>2009-07-07T16:36:03.266+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="google maps"/><category scheme="http://www.blogger.com/atom/ns#" term="GWT app"/><category scheme="http://www.blogger.com/atom/ns#" term="GWT application"/><title type='text'>A GWT app: HouseOnMaps.com</title><content type='html'>Here got a web site 100% developed in GWT. It&#39;s House On Maps Dot Com @ &lt;a href=&quot;http://www.houseonmaps.com&quot;&gt;www.houseonmaps.com&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I think the Google map is loaded a bit slow. Perhaps there should be a trick to make it faster.</content><link rel='replies' type='application/atom+xml' href='http://happygwt.blogspot.com/feeds/8370371999034021467/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8731204716250805449/8370371999034021467' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/8370371999034021467'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/8370371999034021467'/><link rel='alternate' type='text/html' href='http://happygwt.blogspot.com/2009/07/gwt-app-houseonmapscom.html' title='A GWT app: HouseOnMaps.com'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8731204716250805449.post-5175713435051933913</id><published>2009-07-07T16:22:00.005+08:00</published><updated>2009-07-07T16:29:46.347+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="best ajax tool"/><category scheme="http://www.blogger.com/atom/ns#" term="buttons"/><category scheme="http://www.blogger.com/atom/ns#" term="demo"/><category scheme="http://www.blogger.com/atom/ns#" term="dnd"/><category scheme="http://www.blogger.com/atom/ns#" term="drag and drop"/><category scheme="http://www.blogger.com/atom/ns#" term="google web toolkits"/><category scheme="http://www.blogger.com/atom/ns#" term="gwt"/><category scheme="http://www.blogger.com/atom/ns#" term="gwt-ext"/><category scheme="http://www.blogger.com/atom/ns#" term="gwt-ext download"/><category scheme="http://www.blogger.com/atom/ns#" term="gwt-ext tutorial"/><title type='text'>GWT-Ext</title><content type='html'>&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;http://gwt-ext.com/gwt-ext-2.gif&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 698px; height: 861px;&quot; src=&quot;http://gwt-ext.com/gwt-ext-2.gif&quot; border=&quot;0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;Source: http://gwt-ext.com/ (official site of GWT-Ext)&lt;br /&gt;GWT-Ext is a powerful widget library that provides rich widgets like Grid with sort, paging and filtering, Tree’s with Drag &amp; Drop support, highly customizable ComboBoxes, Tab Panels, Menus &amp; Toolbars, Dialogs, Forms and a lot more right out of the box with a powerful and easy to use API. It uses GWT and Ext.&lt;br /&gt;&lt;br /&gt;GWT-Ext 2.0.5 has been released. Grab the distribution from the Downloads area.  GWT-Ext 2.0.5 supports GWT 1.5 final (1.5.2), Firefox3 and Chrome.&lt;br /&gt;&lt;br /&gt;Note that GWT-Ext only supports Ext 2.0.2 that has a LGPL license option.&lt;br /&gt;&lt;br /&gt;The download link for current latest version of GWT-Ext (GWT-Ext 2.0): &lt;a href=&quot;http://gwt-ext.com/demo&quot;&gt;http://gwt-ext.com/demo&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://happygwt.blogspot.com/feeds/5175713435051933913/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8731204716250805449/5175713435051933913' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/5175713435051933913'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/5175713435051933913'/><link rel='alternate' type='text/html' href='http://happygwt.blogspot.com/2009/07/gwt-ext.html' title='GWT-Ext'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8731204716250805449.post-5454615002058878269</id><published>2008-01-15T12:18:00.001+08:00</published><updated>2008-01-15T12:24:44.243+08:00</updated><title type='text'>gwt window manager</title><content type='html'>Just now, I found that other people have done the same thing as mine, even better than the one I did. They really have done a great job.. that they put a lot of animations, transparent backgrounds, sophisticated window buttons (e.g: vista &amp; iMac themes), etc.&lt;br /&gt;They called it GWT Window Manager. You can find out more from this link:&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.gwtwindowmanager.org/&quot;&gt;http://www.gwtwindowmanager.org/&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://happygwt.blogspot.com/feeds/5454615002058878269/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8731204716250805449/5454615002058878269' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/5454615002058878269'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/5454615002058878269'/><link rel='alternate' type='text/html' href='http://happygwt.blogspot.com/2008/01/gwt-window-manager.html' title='gwt window manager'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8731204716250805449.post-5965927104104011823</id><published>2008-01-15T00:04:00.000+08:00</published><updated>2008-12-09T15:31:19.496+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="demo"/><category scheme="http://www.blogger.com/atom/ns#" term="dnd"/><category scheme="http://www.blogger.com/atom/ns#" term="drag and drop"/><category scheme="http://www.blogger.com/atom/ns#" term="gwt"/><category scheme="http://www.blogger.com/atom/ns#" term="source code"/><category scheme="http://www.blogger.com/atom/ns#" term="window"/><title type='text'>gwt window demo</title><content type='html'>I have made the demo of gwt window (as shown in the figure below):&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiexcwDl0MbK-ZJxrN0_upDNIvyOPUNlIqVIQWY3zEc-gWia3rKmq0jex-s9IojaT6Wmwal7BRY7KQP1Ez23y6zxkSuMBVXtqcV7jayZ2hZ1X2mLM3Xrdi_xPEoV8eAvyGP5S6ho9iCcLM/s1600-h/demo.jpg&quot;&gt;&lt;img style=&quot;margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiexcwDl0MbK-ZJxrN0_upDNIvyOPUNlIqVIQWY3zEc-gWia3rKmq0jex-s9IojaT6Wmwal7BRY7KQP1Ez23y6zxkSuMBVXtqcV7jayZ2hZ1X2mLM3Xrdi_xPEoV8eAvyGP5S6ho9iCcLM/s320/demo.jpg&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5155378103684149714&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can go to the link below to view the demo:&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.euzertech.com/gwt/gwtwindow.html&quot;&gt;http://www.euzertech.com/gwt/gwtwindow.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The source files of this demo project can be downloaded from this link:&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.euzertech.com/gwt/gwtwindow.zip&quot;&gt;http://www.euzertech.com/gwt/gwtwindow.zip&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Please note that the background and border color of the window dialogbox generated by my Window class is transparent. So, you can use external CSS to color the window. In this demo, the source code of my CSS is as below:&lt;br /&gt;&lt;br /&gt;.gwt-Window {&lt;br /&gt;   background-color: #0055ff;&lt;br /&gt;   border-color: #0000ff;&lt;br /&gt;   border-style: solid;&lt;br /&gt;   border-width: 2px;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;.gwt-Window .HeadPanel {&lt;br /&gt;   background-color: #00eeff;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;.gwt-Window .HeadPanel .Caption {&lt;br /&gt;   font-weight: bold;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Please note that in order to use the &quot;Window.java&quot;, 6 images files (close.png, close_white.png, minimize.png, minimize_white.png, maximize.png, maximize_white.png) must be included in the same folder. You can see the files structure of the demo from the figure below:&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinv8762ZxybryRwKdn1vKb0xnAfYADviYUBPgQN_FEQvEuNgFwJCl-Bl69aTaIVS7kcqcvvv79xEmXc6FvYuS7wX7D7dWKHxqHGsQ3vkd95ol_X1CPQDEk97lg42ays9Z1dc4kJXw4wNs/s1600-h/gwtWinTree.jpg&quot;&gt;&lt;img style=&quot;margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinv8762ZxybryRwKdn1vKb0xnAfYADviYUBPgQN_FEQvEuNgFwJCl-Bl69aTaIVS7kcqcvvv79xEmXc6FvYuS7wX7D7dWKHxqHGsQ3vkd95ol_X1CPQDEk97lg42ays9Z1dc4kJXw4wNs/s320/gwtWinTree.jpg&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5155378099389182402&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://happygwt.blogspot.com/feeds/5965927104104011823/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8731204716250805449/5965927104104011823' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/5965927104104011823'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/5965927104104011823'/><link rel='alternate' type='text/html' href='http://happygwt.blogspot.com/2008/01/gwt-window-demo.html' title='gwt window demo'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiexcwDl0MbK-ZJxrN0_upDNIvyOPUNlIqVIQWY3zEc-gWia3rKmq0jex-s9IojaT6Wmwal7BRY7KQP1Ez23y6zxkSuMBVXtqcV7jayZ2hZ1X2mLM3Xrdi_xPEoV8eAvyGP5S6ho9iCcLM/s72-c/demo.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8731204716250805449.post-6796735778111965740</id><published>2008-01-14T17:39:00.000+08:00</published><updated>2008-01-15T01:23:46.014+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="buttons"/><category scheme="http://www.blogger.com/atom/ns#" term="dnd"/><category scheme="http://www.blogger.com/atom/ns#" term="drag and drop"/><category scheme="http://www.blogger.com/atom/ns#" term="gwt"/><category scheme="http://www.blogger.com/atom/ns#" term="minimize"/><category scheme="http://www.blogger.com/atom/ns#" term="window"/><title type='text'>gwt window dialogbox widget with minimize and close buttons</title><content type='html'>I wanted to make a draggable window dialog box with minimize and close buttons on the caption panel, but i couldn&#39;t find this kind of gwt widget API from the web. So, i have decided to build my own one by modifying the source code from a gwt library file called &quot;DialogBox.java&quot;. Below is the source code of my &quot;Window.java&quot;:&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;* Copyright 2007 Google Inc.&lt;br /&gt;*&lt;br /&gt;* Modified from DialogBox.java of GWT 1.4.61&lt;br /&gt;* by Wong Thai Min at 14th January 2008.&lt;br /&gt;*&lt;br /&gt;* Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); you may not&lt;br /&gt;* use this file except in compliance with the License. You may obtain a copy of&lt;br /&gt;* the License at&lt;br /&gt;*&lt;br /&gt;* http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;*&lt;br /&gt;* Unless required by applicable law or agreed to in writing, software&lt;br /&gt;* distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT&lt;br /&gt;* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the&lt;br /&gt;* License for the specific language governing permissions and limitations under&lt;br /&gt;* the License.&lt;br /&gt;*/&lt;br /&gt;package com.thaimin.client;&lt;br /&gt;&lt;br /&gt;import com.google.gwt.core.client.GWT;&lt;br /&gt;import com.google.gwt.user.client.DOM;&lt;br /&gt;import com.google.gwt.user.client.Event;&lt;br /&gt;import com.google.gwt.user.client.ui.AbstractImagePrototype;&lt;br /&gt;import com.google.gwt.user.client.ui.ClickListener;&lt;br /&gt;import com.google.gwt.user.client.ui.FlexTable;&lt;br /&gt;import com.google.gwt.user.client.ui.HasHorizontalAlignment;&lt;br /&gt;import com.google.gwt.user.client.ui.HasVerticalAlignment;&lt;br /&gt;import com.google.gwt.user.client.ui.MouseListener;&lt;br /&gt;import com.google.gwt.user.client.ui.PopupPanel;&lt;br /&gt;import com.google.gwt.user.client.ui.Widget;&lt;br /&gt;import com.google.gwt.user.client.ui.HorizontalPanel;&lt;br /&gt;import com.google.gwt.user.client.ui.Label;&lt;br /&gt;import com.google.gwt.user.client.ui.Image;&lt;br /&gt;import com.google.gwt.user.client.ui.ImageBundle;&lt;br /&gt;import com.google.gwt.user.client.ui.VerticalPanel;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* A form of popup window that has a caption area at the top and can be dragged by the&lt;br /&gt;* user. Minimize, maximize and close window buttons are on the caption area.&lt;br /&gt;*&lt;br /&gt;* CSS Style Rules&lt;br /&gt;* &lt;br /&gt;* .gwt-Window { the outside of the window }&lt;br /&gt;* .gwt-Window .HeadPanel { the header panell of the window }&lt;br /&gt;* .gwt-Window .HeadPanel .Caption { the caption }&lt;br /&gt;* &lt;br /&gt;*/&lt;br /&gt;public class Window extends PopupPanel implements MouseListener {&lt;br /&gt;&lt;br /&gt;   public interface WindowImages extends ImageBundle {&lt;br /&gt;&lt;br /&gt;       AbstractImagePrototype maximize();&lt;br /&gt;&lt;br /&gt;       AbstractImagePrototype maximize_white();&lt;br /&gt;&lt;br /&gt;       AbstractImagePrototype minimize();&lt;br /&gt;&lt;br /&gt;       AbstractImagePrototype minimize_white();&lt;br /&gt;&lt;br /&gt;       AbstractImagePrototype close();&lt;br /&gt;&lt;br /&gt;       AbstractImagePrototype close_white();&lt;br /&gt;   }&lt;br /&gt;   public static final WindowImages images = (WindowImages) GWT.create(WindowImages.class);&lt;br /&gt;   private Image minmax = images.minimize().createImage();&lt;br /&gt;   private Image close = images.close().createImage();&lt;br /&gt;   private HorizontalPanel icons = new HorizontalPanel();&lt;br /&gt;   private HorizontalPanel headhor = new HorizontalPanel();&lt;br /&gt;   private VerticalPanel headver = new VerticalPanel();&lt;br /&gt;   private FlexTable content = new FlexTable();&lt;br /&gt;   private Label caption = new Label();&lt;br /&gt;   private Widget child;&lt;br /&gt;   private boolean dragging;&lt;br /&gt;   private int dragStartX,  dragStartY;&lt;br /&gt;   private FlexTable panel = new FlexTable();&lt;br /&gt;&lt;br /&gt;   /**&lt;br /&gt;    * Creates an empty dialog box. It should not be shown until its child widget&lt;br /&gt;    * has been added using {@link #add(Widget)}.&lt;br /&gt;    */&lt;br /&gt;   public Window() {&lt;br /&gt;       this(false);&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   /**&lt;br /&gt;    * Creates an empty dialog box specifying its &quot;auto-hide&quot; property. It should&lt;br /&gt;    * not be shown until its child widget has been added using&lt;br /&gt;    * {@link #add(Widget)}.&lt;br /&gt;    *&lt;br /&gt;    * @param autoHide &lt;code&gt;true&lt;/code&gt; if the dialog should be automatically&lt;br /&gt;    *          hidden when the user clicks outside of it&lt;br /&gt;    */&lt;br /&gt;   public Window(boolean autoHide) {&lt;br /&gt;       this(autoHide, true);&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   /**&lt;br /&gt;    * Creates an empty dialog box specifying its &quot;auto-hide&quot; property. It should&lt;br /&gt;    * not be shown until its child widget has been added using&lt;br /&gt;    * {@link #add(Widget)}.&lt;br /&gt;    *&lt;br /&gt;    * @param autoHide &lt;code&gt;true&lt;/code&gt; if the dialog should be automatically&lt;br /&gt;    *          hidden when the user clicks outside of it&lt;br /&gt;    * @param modal &lt;code&gt;true&lt;/code&gt; if keyboard and mouse events for widgets&lt;br /&gt;    *          not contained by the dialog should be ignored&lt;br /&gt;    */&lt;br /&gt;   public Window(boolean autoHide, boolean modal) {&lt;br /&gt;       super(autoHide, modal);&lt;br /&gt;&lt;br /&gt;       // minimize &amp;amp; close buttons for DialogBox&lt;br /&gt;       minmax.setTitle(&quot;minimize&quot;);&lt;br /&gt;       close.setTitle(&quot;close&quot;);&lt;br /&gt;&lt;br /&gt;       // panel:headver:headhor:icons HorizontalPanel ==&gt; display minmax &amp;amp; close images&lt;br /&gt;       icons.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);&lt;br /&gt;       icons.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);&lt;br /&gt;       icons.setHeight(&quot;100%&quot;);&lt;br /&gt;       icons.setSpacing(2);&lt;br /&gt;       icons.add(minmax);&lt;br /&gt;       icons.add(close);&lt;br /&gt;&lt;br /&gt;       // panel:headver:headhor HorizontalPanel&lt;br /&gt;       headhor.setWidth(&quot;100%&quot;);&lt;br /&gt;       headhor.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);&lt;br /&gt;       headhor.add(caption);&lt;br /&gt;       headhor.setCellWidth(caption, &quot;100%&quot;);&lt;br /&gt;       headhor.setCellHorizontalAlignment(caption, HorizontalPanel.ALIGN_LEFT);&lt;br /&gt;       headhor.add(icons);&lt;br /&gt;       headhor.setCellHorizontalAlignment(icons, HorizontalPanel.ALIGN_RIGHT);&lt;br /&gt;&lt;br /&gt;       // panel:headver:content VerticalPanel&lt;br /&gt;&lt;br /&gt;       // panel:headver VerticalPanel&lt;br /&gt;       headver.setWidth(&quot;100%&quot;);&lt;br /&gt;       headver.add(headhor);&lt;br /&gt;       headver.add(content);&lt;br /&gt;&lt;br /&gt;       // panel Flextable&lt;br /&gt;       panel.setWidget(0, 0, headver);&lt;br /&gt;       panel.setHeight(&quot;100%&quot;);&lt;br /&gt;       panel.setBorderWidth(0);&lt;br /&gt;       panel.setCellPadding(0);&lt;br /&gt;       panel.setCellSpacing(0);&lt;br /&gt;       panel.getCellFormatter().setHeight(1, 0, &quot;100%&quot;);&lt;br /&gt;       panel.getCellFormatter().setWidth(1, 0, &quot;100%&quot;);&lt;br /&gt;       panel.getCellFormatter().setAlignment(1, 0,&lt;br /&gt;               HasHorizontalAlignment.ALIGN_CENTER,&lt;br /&gt;               HasVerticalAlignment.ALIGN_MIDDLE);&lt;br /&gt;&lt;br /&gt;       // Display the layout of the window&lt;br /&gt;       super.setWidget(panel);&lt;br /&gt;&lt;br /&gt;       setStyleName(&quot;gwt-Window&quot;);&lt;br /&gt;       headhor.setStyleName(&quot;HeadPanel&quot;);&lt;br /&gt;       caption.setStyleName(&quot;Caption&quot;);&lt;br /&gt;       caption.addMouseListener(this);&lt;br /&gt;&lt;br /&gt;       //---------------------- Mouse Listener for window buttons -----------------&lt;br /&gt;       minmax.addMouseListener(new MouseListener() {&lt;br /&gt;&lt;br /&gt;           public void onMouseDown(Widget sender, int x, int y) {&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           // Minimize(grey) icon become white color&lt;br /&gt;           public void onMouseEnter(Widget sender) {&lt;br /&gt;               if (isMinimize()) {&lt;br /&gt;                   images.maximize_white().applyTo(minmax);&lt;br /&gt;               } else {&lt;br /&gt;                   images.minimize_white().applyTo(minmax);&lt;br /&gt;               }&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           public void onMouseLeave(Widget sender) {&lt;br /&gt;               if (isMinimize()) {&lt;br /&gt;                   images.maximize().applyTo(minmax);&lt;br /&gt;               } else {&lt;br /&gt;                   images.minimize().applyTo(minmax);&lt;br /&gt;               }&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           public void onMouseMove(Widget sender, int x, int y) {&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           public void onMouseUp(Widget sender, int x, int y) {&lt;br /&gt;               if (isMinimize()) {&lt;br /&gt;                   setMinimize(false);&lt;br /&gt;               } else {&lt;br /&gt;                   setMinimize(true);&lt;br /&gt;               }&lt;br /&gt;           }&lt;br /&gt;       });&lt;br /&gt;&lt;br /&gt;       close.addMouseListener(new MouseListener() {&lt;br /&gt;&lt;br /&gt;           public void onMouseDown(Widget sender, int x, int y) {&lt;br /&gt;           }&lt;br /&gt;           // Close(grey) icon become white color&lt;br /&gt;           public void onMouseEnter(Widget sender) {&lt;br /&gt;               images.close_white().applyTo(close);&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           public void onMouseLeave(Widget sender) {&lt;br /&gt;               images.close().applyTo(close);&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           public void onMouseMove(Widget sender, int x, int y) {&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           public void onMouseUp(Widget sender, int x, int y) {&lt;br /&gt;           }&lt;br /&gt;           });&lt;br /&gt;&lt;br /&gt;       // Close the window&lt;br /&gt;       close.addClickListener(new ClickListener() {&lt;br /&gt;&lt;br /&gt;           public void onClick(Widget sender) {&lt;br /&gt;               hide();&lt;br /&gt;           }&lt;br /&gt;       });&lt;br /&gt;//------------------ End of Mouse Listener for window buttons ------------------&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public String getText() {&lt;br /&gt;       return caption.getText();&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public boolean onEventPreview(Event event) {&lt;br /&gt;       // We need to preventDefault() on mouseDown events (outside of the&lt;br /&gt;       // DialogBox content) to keep text from being selected when it&lt;br /&gt;       // is dragged.&lt;br /&gt;       if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) {&lt;br /&gt;           if (DOM.isOrHasChild(caption.getElement(), DOM.eventGetTarget(event))) {&lt;br /&gt;               DOM.eventPreventDefault(event);&lt;br /&gt;           }&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       return super.onEventPreview(event);&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public void onMouseDown(Widget sender, int x, int y) {&lt;br /&gt;       dragging = true;&lt;br /&gt;       DOM.setCapture(caption.getElement());&lt;br /&gt;       dragStartX = x;&lt;br /&gt;       dragStartY = y;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public void onMouseEnter(Widget sender) {&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public void onMouseLeave(Widget sender) {&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public void onMouseMove(Widget sender, int x, int y) {&lt;br /&gt;       if (dragging) {&lt;br /&gt;           int absX = x + getAbsoluteLeft();&lt;br /&gt;           int absY = y + getAbsoluteTop();&lt;br /&gt;           setPopupPosition(absX - dragStartX, absY - dragStartY);&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public void onMouseUp(Widget sender, int x, int y) {&lt;br /&gt;       dragging = false;&lt;br /&gt;       DOM.releaseCapture(caption.getElement());&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public boolean remove(Widget w) {&lt;br /&gt;       if (child != w) {&lt;br /&gt;           return false;&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       panel.remove(w);&lt;br /&gt;       return true;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   /**&lt;br /&gt;    * Set the caption of the window.&lt;br /&gt;    *&lt;br /&gt;    * @param text&lt;br /&gt;    */&lt;br /&gt;   public void setText(String text) {&lt;br /&gt;       caption.setText(text);&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   /**&lt;br /&gt;    * Insert a content widget into the window. If there is any widget in the&lt;br /&gt;    * content area of the window, it will be removed and replaced by&lt;br /&gt;    * &lt;b&gt;w&lt;/b&gt;.&lt;br /&gt;    *&lt;br /&gt;    * @param w The content widget to be inserted to the Window.&lt;br /&gt;    */&lt;br /&gt;   public void setWidget(Widget w) {&lt;br /&gt;       // If there is already a widget, remove it.&lt;br /&gt;       if (child != null) {&lt;br /&gt;           content.remove(child);&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       // Add the widget to the center of the cell.&lt;br /&gt;       if (w != null) {&lt;br /&gt;           content.setWidget(1, 0, w);&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       child = w;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   /**&lt;br /&gt;    * Override, so that interior panel reflows to match parent&#39;s new width.&lt;br /&gt;    *&lt;br /&gt;    * @Override&lt;br /&gt;    */&lt;br /&gt;   public void setWidth(String width) {&lt;br /&gt;       super.setWidth(width);&lt;br /&gt;&lt;br /&gt;       // note that you CANNOT call panel.setWidth(&quot;100%&quot;) until parent&#39;s width&lt;br /&gt;       // has been explicitly set, b/c until then parent&#39;s width is unconstrained&lt;br /&gt;       // and setting panel&#39;s width to 100% will flow parent to 100% of browser&lt;br /&gt;       // (i.e. can&#39;t do this in constructor)&lt;br /&gt;       panel.setWidth(&quot;100%&quot;);&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   /**&lt;br /&gt;    * Determines whether the window state is currently minimized or restored.&lt;br /&gt;    */&lt;br /&gt;   public boolean isMinimize() {&lt;br /&gt;       return !content.isVisible();&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   /**&lt;br /&gt;    * Set the window state whether to be minimized or restored.&lt;br /&gt;    *&lt;br /&gt;    * @param state &lt;code&gt;true&lt;/code&gt; to minimize the window.&lt;br /&gt;    */&lt;br /&gt;   public void setMinimize(boolean b) {&lt;br /&gt;       content.setVisible(!b);&lt;br /&gt;       if (b = true) {&lt;br /&gt;           images.maximize().applyTo(minmax);&lt;br /&gt;       } else {&lt;br /&gt;           images.minimize().applyTo(minmax);&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://happygwt.blogspot.com/feeds/6796735778111965740/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8731204716250805449/6796735778111965740' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/6796735778111965740'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8731204716250805449/posts/default/6796735778111965740'/><link rel='alternate' type='text/html' href='http://happygwt.blogspot.com/2008/01/gwt-window-widget-with-drag-and-drop.html' title='gwt window dialogbox widget with minimize and close buttons'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>