Wednesday, December 12, 2012

Adding favicon to the our domain

Add the image in root folder of the web server(Apache Tomcat).
Image extension '.ico'

add the following tag under title tag.
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />

Wednesday, May 9, 2012

Basic DB2 commands



  • If we close the systram icon for db2 manager, to activate again the icon the below cmd..

             C:\Documents and Settings\db2admin>db2systray

Thursday, January 5, 2012

Ajax and Struts1.3 Sample Example

Task: Populate states based on Country using AJAX.

In previous post its done using javascript. Now its based on Ajax.
In this example i used static data. we can do it using Database. Based on country it will get the corresponding states.

1). RegisterUser.jsp

<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<html>
<head>
<script type="text/JavaScript" src="javascripts/CommonAjax.js"></script>
</head>
  <body>  <h2>Struts1.3 - Ajax Example</h2>

Wednesday, January 4, 2012

Populating States based on country using javascript

Instead of Ajax call we can populate States based on country using javascript in struts1.3

RegisterUser.jsp:-
Its normal Jsp, in the form i have two select fields in Form. Country and State.

Country:<html:select property="region" styleId="region" onchange="getTerritories(this.form, this.value);">
<html:option value="">-- None --</html:option>
<html:option value="Central">Central</html:option>
<html:option value="East">East</html:option>
<html:option value="Enterprise">Enterprise</html:option>
 <html:option value="West">West</html:option>
</html:select>

State:<html:select property="territory" styleId="territory" >
<html:option value="">-- Please Select --</html:option>
</html:select>


"getTerritories" is the javascript funtion that calls when onChange Event occurs.

required JS File:-



var territories=new Array();
territories.Central=new Array("North Central","Great Lakes","Great Plains");
territories.East=new Array("Mid-Atlantic","NY NJ Metro","WallStreet","South","Upstate NY/NE");
territories.Enterprise=new Array("IBM-TBD","SAP-TBD","Healthcare-TBD","Automotive-TBD","CSC","Accenture","IBM","Ford","Delphi Automotive","Target");
territories.West=new Array("Pacific NW","Pacific SW","South West");


function getTerritories(form,index){
var cntrySel=document.getElementById("region");
// alert("cntrySel"+cntrySel.value);
terrirotyList=territories[cntrySel.value];

if(terrirotyList!=null){
setTerritories("territory",terrirotyList,terrirotyList);
}
}

function setTerritories(fieldId,newOptions,newValues){
// alert(fieldId+"@@"+newOptions+"&&"+newValues);
var selectedField=document.getElementById("territory");
selectedField.options.length=0;
for(i=0; i<newOptions.length;i++){
selectedField.options[selectedField.length]=new Option(newOptions[i],newValues[i]);
}
}