<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mersoft Corporation Blog &#187; GWT-EXT</title>
	<atom:link href="http://blog.mersoft.com/tag/gwt-ext/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mersoft.com</link>
	<description>Achieve, Compete, and Evolve</description>
	<lastBuildDate>Tue, 25 May 2010 15:37:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>GWT-EXT 2.0.6 ComboBox &#8211; onChange event</title>
		<link>http://blog.mersoft.com/2010/05/25/gwt-ext-2-0-6-combobox-onchange-event/</link>
		<comments>http://blog.mersoft.com/2010/05/25/gwt-ext-2-0-6-combobox-onchange-event/#comments</comments>
		<pubDate>Tue, 25 May 2010 15:30:54 +0000</pubDate>
		<dc:creator>Tom Bollwitt</dc:creator>
				<category><![CDATA[Java/Java Frameworks]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[EXTJS]]></category>
		<category><![CDATA[google web toolkit]]></category>
		<category><![CDATA[Goolge Web Toolkit]]></category>
		<category><![CDATA[GWT]]></category>
		<category><![CDATA[GWT-EXT]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://blog.mersoft.com/?p=363</guid>
		<description><![CDATA[I ran into an issue where I needed to use the onChange event for a Combobox and it was not working as expected. It only worked when the value was selected from the dropdown. This posed a problem for me since I was not forcing the user to make a selection &#8211; they can enter [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into an issue where I needed to use the onChange event for a Combobox and it was not working as expected. It only worked when the value was selected from the dropdown. This posed a problem for me since I was not forcing the user to make a selection &#8211; they can enter in text manually.</p>
<p>I found <a href="http://www.extjs.com/forum/showthread.php?6343-Solved-1.0.1a-1.1-DateField-change-event-bugs-proposed-fixes&amp;p=52974#post52974" target="_blank">this fix</a> on the EXTJS forum, however the fix did not work when the user entered in their own value into the combo box.</p>
<p>To resolve this I changed 2 lines of code from the fix I found.</p>
<p>I modified&#8230;</p>
<pre>this.startValue = this.getValue();</pre>
<p>to</p>
<pre>this.startValue = this.getRawValue();</pre>
<p>and</p>
<pre>var v = this.getValue();</pre>
<p>to</p>
<pre>var v = this.getRawValue();</pre>
<p>So here is the entire code for the updated fix&#8230;</p>
<pre>Ext.override(Ext.form.Field, {
 onFocus : function() {
 if (!Ext.isOpera) { // don't touch in Opera
 this.el.addClass(this.focusClass);
 }
 if (!this.hasFocus) {
 this.hasFocus = true;
 <span style="color: #0000ff;"><strong>this.startValue = this.getRawValue();</strong></span>
 this.fireEvent("focus", this);
 }
 },

 onBlur : function() {
 this.beforeBlur();
 this.el.removeClass(this.focusClass);
 this.hasFocus = false;
 if (this.validationEvent !== false &amp;&amp; this.validateOnBlur &amp;&amp; this.validationEvent != "blur") {
 this.validate();
 }
 <span style="color: #0000ff;"><strong>var v = this.getRawValue();</strong></span>
 if (String(v) !== String(this.startValue)) {
 this.fireEvent('change', this, v, this.startValue);
 }
 this.fireEvent("blur", this);
 }
 });</pre>
<p>I hope this helps someone out there who may be having the same problem I had.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fblog.mersoft.com%2F2010%2F05%2F25%2Fgwt-ext-2-0-6-combobox-onchange-event%2F&amp;linkname=GWT-EXT%202.0.6%20ComboBox%20%26%238211%3B%20onChange%20event"><img src="http://blog.mersoft.com/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://blog.mersoft.com/2010/05/25/gwt-ext-2-0-6-combobox-onchange-event/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GWT &#8211; Hide Tabs in TabPanel</title>
		<link>http://blog.mersoft.com/2009/08/27/gwt-hide-tabs-in-tabpanel/</link>
		<comments>http://blog.mersoft.com/2009/08/27/gwt-hide-tabs-in-tabpanel/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 21:14:32 +0000</pubDate>
		<dc:creator>Tom Bollwitt</dc:creator>
				<category><![CDATA[Java/Java Frameworks]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[google web toolkit]]></category>
		<category><![CDATA[Goolge Web Toolkit]]></category>
		<category><![CDATA[GWT]]></category>
		<category><![CDATA[GWT-EXT]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://blog.mersoft.com/?p=320</guid>
		<description><![CDATA[I was continuing my work on a sample GWT app and needed the ability to use a Menu with CheckItems to show/hide tabs in a tab panel. Here is how I did it.
Note: This post does not cover the creation of the TabPanel, Toolbar and ToolbarButton with a Menu.
Step 1: Override the Ext.TabPanel. (Note: This [...]]]></description>
			<content:encoded><![CDATA[<p>I was continuing my work on a sample GWT app and needed the ability to use a Menu with CheckItems to show/hide tabs in a tab panel. Here is how I did it.</p>
<p>Note: This post does not cover the creation of the TabPanel, Toolbar and ToolbarButton with a Menu.</p>
<p>Step 1: Override the Ext.TabPanel. (Note: This was just added to a JavaScript file I added to my application. I did not modify the ext-all.js file)</p>
<pre style="border: 1px solid grey; padding: 10px;">Ext.override(Ext.TabPanel, {

  hideTabStripItem : function(item){
    //Don't hide if its the last tab
    var cnt = this.items.length;
    var visibleTabs = 0;
    for(var i = 0; i &lt; cnt; i++ ){
      if(!this.isTabStripItemHidden(i)){
        visibleTabs++;
      }
    }
    if(visibleTabs &gt; 1){
      item = this.getComponent(item);
      var isactive = (item == this.activeTab);	    

      var el = this.getTabEl(item);
      if(el){
        el.style.display = 'none';
          this.delegateUpdates();
      }

      if(isactive){
        //Set the next visible tab active
        var curIndx = 0;
        var indx = 0;
        for(var i = 0; i &lt; cnt; i++ ){
          var tab = this.getComponent(i);
          if(tab.id == item.id){
            curIndx = i;
            break;
          }
        }

        //Check for the next available tab
        for(var i = (curIndx+1); i &lt; cnt; i++ ){
          if(!this.isTabStripItemHidden(i)){
            indx = i;
            break;
          }
        }

        if(indx == 0){
          //Check for a tab before the current one
          for(var i = 0; i &lt; curIndx; i++ ){
            if(!this.isTabStripItemHidden(i)){
              indx = i;
              break;
            }
          }
        }

        this.setActiveTab(indx);
      }
    }
    if(visibleTabs == 1){
      throw "Could not hide the tab";
    }
  },

  unhideTabStripItem : function(item){
    item = this.getComponent(item);
    var el = this.getTabEl(item);
    if(el){
      el.style.display = '';
      this.delegateUpdates();
    }

    this.setActiveTab(item);
  },

  isTabStripItemHidden : function(item){
    item = this.getComponent(item);
    var el = this.getTabEl(item);
    if(el){
      return el.style.display == 'none';
    }
    //return true since it does not exist.
    return true;
  }
});</pre>
<p>Step 2: Create a CheckItem with a listener to show/hide the tab (add it to a ToolbarButton&#8217;s Menu).</p>
<pre style="border: 1px solid grey; padding: 10px;">public CheckItem createTabCheckItem(String menuTitle, final String tabId, final TabPanel tabPanel){
  CheckItem ci = new CheckItem(menuTitle);
  ci.addListener(new CheckItemListenerAdapter() {
    public void onCheckChange(CheckItem item, boolean checked) {
      if (checked) {
        tabPanel.unhideTabStripItem(tabId);
      } else {
        try {
          tabPanel.hideTabStripItem(tabId);
        } catch (Exception e) {
          item.setChecked(true);
        }
      }
    }
  });
  ci.setHideOnClick(false);
  return ci;
}</pre>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fblog.mersoft.com%2F2009%2F08%2F27%2Fgwt-hide-tabs-in-tabpanel%2F&amp;linkname=GWT%20%26%238211%3B%20Hide%20Tabs%20in%20TabPanel"><img src="http://blog.mersoft.com/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://blog.mersoft.com/2009/08/27/gwt-hide-tabs-in-tabpanel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GWT Disable ComboBox options</title>
		<link>http://blog.mersoft.com/2009/08/25/gwt-disable-combobox-options/</link>
		<comments>http://blog.mersoft.com/2009/08/25/gwt-disable-combobox-options/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 22:33:15 +0000</pubDate>
		<dc:creator>Tom Bollwitt</dc:creator>
				<category><![CDATA[Java/Java Frameworks]]></category>
		<category><![CDATA[google web toolkit]]></category>
		<category><![CDATA[Goolge Web Toolkit]]></category>
		<category><![CDATA[GWT]]></category>
		<category><![CDATA[GWT-EXT]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://blog.mersoft.com/?p=264</guid>
		<description><![CDATA[I have been working on an application that required the ability to disable ComboBox options. I googled to see if someone else had already done this and I found the following post. I used the code from the post as a starting point and added additional code to flush out a few more features.
The main [...]]]></description>
			<content:encoded><![CDATA[<p>I have been working on an application that required the ability to disable ComboBox options. I googled to see if someone else had already done this and I found the following <a href="https://www.extjs.com/forum/showthread.php?p=181913" target="_blank">post</a>. I used the code from the post as a starting point and added additional code to flush out a few more features.<br />
The main features I added dealt with the option selecting itself, such as using the up and down keys to select options. In order to tie everything together I have posted all the critical code in its entirety to avoid confusion.</p>
<p>To start off with I added the following to a JavaScript file that I included in my application. The main difference from this code and the code from the original post above is the addition of the selectNext and selectPrev overrides. I also had to modify the onViewClick override since I was using Strings instead of booleans for the selectable value (see the SimpleStore created later).</p>
<pre style="border: 1px solid grey; padding: 10px;">Ext.override(Ext.form.ComboBox, {

  tpl: '&lt;tpl for="."&gt;' +
    '&lt;div class="x-combo-list-item &lt;tpl if="selectable == \'false\'"&gt;x-combo-list-item-unsel&lt;/tpl&gt; "&gt;' +
    '&lt;img src="{image}"&gt; ' +
    '{text}&lt;div class="x-clear"&gt;&lt;/div&gt;&lt;/div&gt;' +
    '&lt;/tpl&gt;',

    // private

    onViewClick : function(doFocus){

        var index = this.view.getSelectedIndexes()[0];
        var r = this.store.getAt(index);
        var sel = r.get('selectable');
        if(sel &amp;&amp; sel == 'false'){
            return;
        }

        if(r){
            this.onSelect(r, index);
        }

        if(doFocus !== false){
            this.el.focus();
        }
    },

    selectNext : function(){
        var ct = this.store.getCount();
        if(ct &gt; 0){
        	var hasSelectable = this.store.getAt(0).get('selectable');

        	if(hasSelectable){
        		//check for selectable records
        		//Get the next selectable record
        		var currentIndex = this.selectedIndex;
        		var nextIndex = currentIndex;

        		while(true){
        			if(nextIndex &lt; ct-1){
        				var r = this.store.getAt(++nextIndex);
        				if(r.get('selectable') == 'true'){
        					break;
        				}
        			}else{
        				break;
        			}
        		}

        		this.select(nextIndex);
        	}else{
        		//select the original way
        		if(this.selectedIndex == -1){
                    this.select(0);
                }else if(this.selectedIndex &lt; ct-1){                     this.select(this.selectedIndex+1);                 }         	}         }     },     selectPrev : function(){         var ct = this.store.getCount();         if(ct &gt; 0){
        	var hasSelectable = this.store.getAt(0).get('selectable');

        	if(hasSelectable){
	        	//Get the next selectable record
	        	var currentIndex = this.selectedIndex;
	        	var nextIndex = currentIndex;

				while(true){
					if(nextIndex != -1){
						var r = this.store.getAt(--nextIndex);
						if(r.get('selectable') == 'true'){
							break;
						}
					}else{
						break;
					}
				}

				this.select(nextIndex);
        	}else{
        		//select the original way
        		if(this.selectedIndex == -1){
                    this.select(0);
                }else if(this.selectedIndex != 0){
                    this.select(this.selectedIndex-1);
                }
        	}
        }
    },
}    

);</pre>
<p>I then added the following CSS class to my application&#8217;s CSS file&#8230;</p>
<pre style="border: 1px solid grey; padding: 10px;">.x-combo-list-item-unsel{
  -moz-opacity:0.5;
  opacity: .50;
  filter:alpha(opacity=50);
}</pre>
<p>And now for some java code.</p>
<p>I created the Store for my ComboBox with the following code. If you read the JavaScript code above you will notice that it depends on the Records in the Store having the &#8220;selectable&#8221; attribute.</p>
<p>Note: The getOptions() method is coming up next.</p>
<pre style="border: 1px solid grey; padding: 10px;">final Store store = new SimpleStore(new String[]{"image", "text", "value", "selectable"}, getOptions(false));
store.load();</pre>
<p>In my application I needed to be able to reverse the disabled options so I created the following method to generate the Object array used for my Store.</p>
<pre style="border: 1px solid grey; padding: 10px;">private Object[][] getOptions(boolean isDisabled){
  Object[][] results = new Object[][]{
    new Object[]{"images/image1.gif", "Option 1", "VALUE1", !isDisabled},
    new Object[]{"images/image2.gif", "Option 2", "VALUE2", !isDisabled},
    new Object[]{"images/image3.gif", "Option 3", "VALUE3", isDisabled},
    new Object[]{"images/image4.gif", "Option 4", "VALUE4", !isDisabled},
    new Object[]{"images/image5.gif", "Option 5", "VALUE5", !isDisabled}
  };

  return results;
}</pre>
<p>Then in a listener on a TextField I added the following code to switch the disabled options&#8230;</p>
<pre style="border: 1px solid grey; padding: 10px;">Store store = combobox.getStore();
store.removeAll();
store.add(getOptionRecords(true));  //Note: send true or false depending on which options you want disabled.</pre>
<p>Here is the getOptionRecords() method used in the code above&#8230;</p>
<pre style="border: 1px solid grey; padding: 10px;">private static Record[] getOptionRecords(boolean isDisabled){
  Store store = new SimpleStore(new String[]{"image", "text", "value", "selectable"}, getPhoneLabels(isDisabled));
  store.load();
  return store.getRecords();
}</pre>
<p>I hope that this post helps someone out.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fblog.mersoft.com%2F2009%2F08%2F25%2Fgwt-disable-combobox-options%2F&amp;linkname=GWT%20Disable%20ComboBox%20options"><img src="http://blog.mersoft.com/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://blog.mersoft.com/2009/08/25/gwt-disable-combobox-options/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
