Thursday, October 17, 2013

Exclude files from War packaging by Maven profile

To achieve this I have used the "packagingExcludes" property of Maven war plugin. For more info and examples of using this property see this page. To exclude files by Maven profile you need to first parameterize the value of "packagingExcludes" in war plugin declaration in pom file


In Maven profile you can define the value of this property by profile


Tuesday, July 30, 2013

Mobile Browsers and Cookies

My attempt at succinctly describing first party and third party cookie support in various mobile browsers. For a good read on Cookies in general see this Wikipedia article

BrowserDefault Cookie BehaviourDefaultReference
Safari MobileSupports three cookie settings. "Never", "From Visited", "Always"From Visited
Chrome MobileAccept cookies: checked/unchecked. No way to enable frist part only. CheckedChecked on my phone
Opera MobileAccept cookies: On /OffOnChecked on my phone
Opera Mini on a BlackberryAccept cookies: on/off. On
Android BrowserAccept cookies: Checked / Unchecked. No way to enable first part only.Checked
Firefox AndroidCookies: Options "Enabled", "Enabled, excluding 3rd party", "Disabled"EnabledInstalled on my phone and checked
Internet Explorer MobileAllow cookies on my phone: Checked / Unchecked Checked
Blackberry BrowserAccept cookies: Checked / UncheckedChecked

Monday, June 03, 2013

Elastic Beanstalk Tomcat Container Timezone

When deploying a Tomcat container webapp using AWS Elastic Beanstalk with default AMI, it defaults the EC2 instances to UTC/GMT timezone. To set a different timezone the hard way is to create your own custom AMI with the required timezone. If you are only running the Tomcat container on EC2 instance then an easier way to change timezone is to specify is as a JVM command line option. To change the configuration

1. Login to your AWS console
2. Go to "Elastic Beanstalk" service
3. Under your environment click on "Edit Configurations"
4. That should popup a screen and the last tab in the screen will say "Container"
5. Set the required timezone as shown in below screenshot. Java supports these timezones

Wednesday, May 15, 2013

DOJO Combobox On Enter Key Event

Below code can be used to setup a event to fire when a enter key is pressed inside combobox.

1:  require([  
2:  "dojo/ready", "dojo/store/JsonRest", "dijit/form/ComboBox", "dojox/storage", "dojo/request", "dojo/json"  
3:  ], function(ready, JsonRest, ComboBox, storage, request, json)  
5:  {   
6:      var comboBox = new ComboBox(  
7:      {  
8:         id: "IdCombo",  
9:         name: "NameCombo",  
10:         placeholder: "Enter text",     
11:      }, "placesomewhereid");  
13:      comboBox.startup();     
15:      require(["dojo/on", "dijit/focus", "dojo/keys", "dojo/domReady!"], function(on, focusUtil, keys)  
16:      {  
17:          on(document, "keyup", function(event)  
18:          {  
19:             if(event.keyCode == keys.ENTER && == "IdCombo")  
20:             {  
21:                 //Write code here that needs to run when enter key is pressed  
22:             }        
23:          });  
24:      });  
25:  });  

Monday, May 13, 2013

Creating autocomplete text box in DOJO

Using DOJO combobox, you can create a autocomplete functionality. Below code creates a programmatic combobox and assigns a json store to combobox. A declarative input form element is used a placeholder on page.

1:  <script type="text/javascript">   
2:  require([  
3:  "dojo/ready", "dojo/store/JsonRest", "dijit/form/ComboBox"], function(ready, JsonRest, ComboBox)  
4:  {    
5:    var jsonStore = new JsonRest  
6:     ({  
7:        target: "URL for Ajax service"  
8:     });  
9:     var comboBox = new ComboBox(  
10:     {  
11:        id: "SomeUniqueID",  
12:        name: "SomeUniqueName",  
13:        value: "",  
14:        store: jsonStore,  
15:        pageSize: 3,  
16:        searchAttr: "key",  
17:        queryExpr: "${0}"  
18:     }, "StoreItemSelect");  
19:    comboBox.startup();   
20:  });   
21:  </script>  
22:  <body>  
23:     <input id="StoreItemSelect"/>  
24:  <body>  

The AJAX service should return items in below json format

 [{key: "Autocomplete value 1"},{key: "Autocomplete value 2"},{key: "Autocomplete value 3"}]  

Friday, May 10, 2013

Dojo TabContainer Tab select ContentPane reload

The usual way to implement a TabContainer is to define a ContentPane as tab childs. When a tab is selected and if you want the ContentPane to reload everytime the tab is selected then you need to specify the refreshOnShow property of ContentPane to true.

 var tc = new TabContainer(  
     style: "height: 100%; width: 100%;"  
 }, "tc1-prog");  
  var cp2 = new ContentPane(  
     title: "First Tab",  
     href: "page1.html",      
  var cp2 = new ContentPane({  
     title: "Second Tab",  
     href: "page2.html",   
     refreshOnShow: true     

In this case when "Second Tab" is selected, it refreshes every time. Refresh basically calls the dojo ready function on the page same as when loading the page using F5. "First tab" on the other hand will only load the first time its selected and will not refresh in later selects

Wednesday, April 17, 2013

Using to add row to TableContainer

-- Assume you have a table container defined declaratively


To add a new row to this table container pro grammatically using'