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]);
}
}





Friday, December 2, 2011

Updating Table for Particular Records or Rows

Scenario :  We have to update the particular column of a table for some rows range. Using csv data file.


Address Table







add idadd1add2Street city
100sampsamp2testtstcity
101sampsamp2testtstcity
102sampsamp2testtstcity

Monday, November 28, 2011

Inserting CVS Data to DB Using Db command


Command:
  db2 import from C:\test.csv of del insert into address    (addressId,status,nickname,firstname,lastname,email1)

Imp Points:
  • According to csv file the corresponding coloumns have to be specified for the table.
  • Have to be login to DB with Administrative Privilages.

Thursday, November 3, 2011

Creating Datasource in WAS6.0 for MySql -- RAD7.0

This Post about Creating Mtsql Datasource in RAD 7.0 for WAS 6.0 / WAS 6.1
By default WAS 6.0 does not provide datasource for MySql. We have to create User defined JDBC provider for the My Sql.

The detailed Steps for the Creation.

Step1:
In Admin console select Data Source under Resources.




 


















Step : 3
On the new screen, select User-Defined in Database type field (because WAS doesn’t have MySQL pre-defined), com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource in Implementation Class Name field and MySQL JDBC Provider in Name field.



Step 4: Specify the Jar file path for MySql JDBC connection.


Step 5: Click Finish button.



Step 7: After finishing Again click on the "Test"(what we created just now) Datasource on list of data sources, and Click on the right side JASS-J2C Authentication.


Step 8: Fill the database authentication details like username and password.

Step 9: Just Last Step. We have to fill in some custom properties. like databaseName, URL (of the Database).



Step 10 : in Custom properties look for the URL and enter the Database Access url.







Step 11: now select the authentication we creatted now.

Step 13; now test the connection. its successful.