Wednesday, July 15, 2015

An Example to add a Calendar Control using Jquery and Font-Awesome

Following is an example to add Calendar Control using Jquery and Font Awesome.

There are two date pickers being used here  :

1. First one uses single field with a formatted date.
2. Second one uses three different boxes for month, date and year respectively.

It depends on the requirements which one to use.



Following is the code for above example. To see this running example follow the jsfiddle link here:
http://jsfiddle.net/sanjayingole/6hmdgmdo/

HTML

<div id="inputDiv">
    <h3>Select a Date</h3>

    <div class="dateDiv">
        <input id="sampleDateField1" type="text" class="datepicker" />
        <br/><span class="dateFormatStr">(mm/dd/yyyy)</span>
    </div>

    <div class="dateDiv">
        <input type="text" id="monthField"></input> /
        <input type="text" id="dayField"></input> /
        <input type="text" id="yearField"></input>
        <span id="sampleDateField2"><i class='fa fa-calendar' title="select"></i></span>
        <br/><span class="dateFormatStr">(mm/dd/yyyy)</span>
    </div>
 
    <h3>Selected Date : <span id="selectedDate"></span>  </h3>
 

</div>


CSS

.datepicker{
    width : 80px;    
}

#inputDiv {
    padding-left : 5px;
    float : left;   
    width : 100%;
    height : 300px;
    background-color : #DFEFDD;
}

#dayField{
    width : 20px;
}
#monthField{
    width : 20px;
}
#yearField{
    width : 40px;
}

#caltype1 {
   width : 100px; 
}

.dateDiv { 
    margin : 20px;   
}
.dateFormatStr {
        margin-left : 20px;
}

JAVASCRIPT

$( "#sampleDateField1" ).datepicker({
                showOn: "button",
                buttonText: "<i class='fa fa-calendar'></i>",
                showAnim:"",
                defaultDate: '',
                dateFormat: "mm/dd/yy",
                onSelect: function(date) {
                    $('#selectedDate').html(date);
                }
});

$("#sampleDateField2").unbind().bind("click",function(){
    $('#sampleDateField2 .ui-datepicker').show();
    $( "#sampleDateField2" ).datepicker({
                showOn: "button",
                buttonText: "<i class='fa fa-calendar'></i>",
                showAnim:"",
                defaultDate: '',
                dateFormat: "mm/dd/yy",
                onSelect: function(date, eventField) {
                    //eventField returns the field on which datepicker is applied.
                    var day = $(this).datepicker('getDate').getDate();  
                    var month = $(this).datepicker('getDate').getMonth() + 1;  
                    var year = $(this).datepicker('getDate').getYear();  
                    $('#selectedDate').html(date);
                    $('#dayField').val(day);
                    $('#monthField').val(month);
                    $('#yearField').val(year);
                    $('#sampleDateField2 .ui-datepicker').hide();
                }
    });    
});      

Tuesday, July 14, 2015

Exception while deploying application using beanstalk in Eclipse

I am using Eclipse Juno to deploy a sample web application on AWS using beanstalk, but getting exception while deploying application :

Exception while deploying application using beanstalk in Eclipse:

Unable to upload application to Amazon S3: User: arn:aws:iam::256104670613:user/dev-user is not authorized to perform: elasticbeanstalk:CreateStorageLocation User: arn:aws:iam::256104670613:user/dev-user is not authorized to perform: elasticbeanstalk:CreateStorageLocation
Solution :

Created two user groups :

1. dev-group - with following policies attached:

  • IAMFullAccess
  • AmazonS3FullAccess
2. dev-ops - with following policy attached:
  • AWSElasticBeanstalkFullAccess
And added the user dev-user to both of these groups. That resolved the issue.

Also are available the read only versions of these policies if required:
  •  IAMReadOnlyAccess
  • AmazonS3ReadOnlyAccess
  • AWSElasticBeanstalkReadOnlyAccess



Using Jquery for a fixed footer


Following example shows the use of jquery to keep the footer at the bottom:


<script type="text/javascript">
$(document).ready(function(){

resizeContainer();

$(window).load(function() {
try {
resizeContainer();
}catch(err) {
return false;
}
});

});

function resizeContainer() {

x = $('.pageContainer').height() + 30; // 30 gives space between div and footer
y = $(window).height();

if (x + 30 <= y){
   $('.footer').css('position', 'fixed');
 
}else{
   $('.footer').css('position', 'relative');  
}
}
</script>

Tuesday, June 30, 2015

jquery issue : object doesn't support this property or method 'dialog'

Issue#

I have a div in jsp which I am trying to show as dialog on a click event. But getting following error message while trying show a jquery dialog:

object doesn't support this property or method 'dialog'

Fix :

Possible reasons for this issues could :

1. Multiple references to Jquery library. Check if you have included jquery javascript more than once. If yes remove the duplicate references.

2. The dialog method is from the jQuery UI library. Make sure you have included jquery ui javascript.

3. If you are using any custom version of jQuery UI, please ensure it includes dialog method.

4. Also check if the browser version is obsolete. Sometime older version of IE does not support new fields and methods. Try upgrading the the browser.

Thursday, June 4, 2015

Jquery : Change Product Image on click event

Following Example shows how to use jquery to change the product image in Product Image Container.

The same example can be tested in jsfiddle (http://jsfiddle.net/sanjayingole/9que4n1p/5/)

We have a left panel and a right panel, where :

  • Left Panel contains small image icons.
  • Right Panel shows the larger image when an icon from left panel is clicked.

Javascript :


$(".imageIconLink").click(function() {
    
    var imgSrc= $(this).find("img").attr("src");
    
    $(".largeImage").attr("src", imgSrc); 
});


CSS :
.smallImage {
    height: 80px; width: 80px; border: 0px solid;
}

.largeImage {
    height: 280px; width: 380px; border: 0px solid;
}

.leftImgDiv {
    width : 20%;
    float : left;
    height : 300px;
    overflow : auto;
}

.rightImgDiv {
    width : 80%;
    float : right;
}


HTML :


<div class="leftImgDiv">
<a href="#" class="imageIconLink">
    <img class="smallImage" src="http://s7d1.scene7.com/is/image/BedBathandBeyond/33748242127673p?hei=2000&amp;wid=2000&amp;qlt=50,1" :="" border="" width="2000" height="2000"/>
</a>
    
<a href="#" class="imageIconLink">
    <img class="smallImage" src="http://www.brookstone.com/webassets/product_images/700x700/833371p.jpg" width="252" height="252"/>
    </a>    

<a href="#" class="imageIconLink">
    <img class="smallImage" src="http://slimages.macys.com/is/image/MCY/products/8/optimized/2546128_fpx.tif?01AD=31absA3WJUG8eGA5NUMCutd7x16A-v8cmsm4k_DZNgdpUvQGEe2iugA&amp;01RI=958CD8AFBE261DF&amp;01NA=&amp;wid=1320&amp;hei=1616&amp;fit=fit,1&amp;$filterlrg$"/>
</a>

<a href="#" class="imageIconLink">
    <img class="smallImage"
    src="http://www.u3j.org/wp-content/uploads/2014/07/uncategorized-amazing-where-to-buy-leather-sofa-in-malaysia-where-to-buy-leather-furniture-repair-kits-where-to-buy-leather-furniture-repair-kit-where-to-buy-leather-furniture-in-bali-where-to-bu.jpg" />
</a>
    
    
<a href="#" class="imageIconLink">
    <img class="smallImage"
    src="http://www.u3j.org/wp-content/uploads/2014/07/uncategorized-amazing-where-to-buy-leather-sofa-in-malaysia-where-to-buy-leather-furniture-repair-kits-where-to-buy-leather-furniture-repair-kit-where-to-buy-leather-furniture-in-bali-where-to-bu.jpg" />
</a>
</div>    
    
<div class="rightImgDiv">
    <img class="largeImage" src="http://s7d1.scene7.com/is/image/BedBathandBeyond/33748242127673p?hei=2000&amp;wid=2000&amp;qlt=50,1"/>
</div>





Saturday, May 30, 2015

Object doesn't support property or method 'dialog'

Object doesn't support property or method 'dialog'

Suggestions:
Check the jquery file path if its relative url.
Check for multiple references of jquery js file in final html. If its invoked from multiple times from different jsps included in one page then it might cause this exception. Better to put its reference in one common jsp file and include it once in parent jsp.

In my case I had duplicate references to following js.
<script src="include/scripts/jquery-1.8.1.min.js"></script>

Also as observed this will be fine if you have duplicate inclusion in same jsp or html , but if there are multiple child jsps with jquery inclusion, this might cause the problem.

Tuesday, March 10, 2015

Search for a String/ Jar name in SVN repository

Following command can be used :

* search for a specific String
svn list -R [[repository path]] | findstr /s "string to find" > D:\search-results.xml


* search for a specific file
svn list -R <<repository path>> | findstr [[filename]] > D:\search-results.xml