I18N and Database




<link rel="stylesheet" href="css/pagination.css" />
<script type="text/javascript" src="js/pagination/jquery.pagination.js"></script>
<script type="text/javascript">
        var _EVENT;
        var _MAX_DISPLAY_PAGES = 5;
        var _ITEMS_PER_PAGE = 4;
        jQuery(document).ready(function() {
        function initPagination() {
                _EVENT = "load";
                        var totalItemCount = formObj.totalItemCount.value;
            jQuery("#pageLinks").pagination(totalItemCount, {
                callback: paginate,
                num_display_entries: _MAX_DISPLAY_PAGES ,
                items_per_page: _ITEMS_PER_PAGE
         }         function paginate(pageIndex, container){
        var startOffset;
        var endOffset;
        var formObj = document.forms["dummyForm"];
        if (_EVENT != "load") {
            endOffset = (pageIndex + 1) * 4;
            startOffset = endOffset – 4;
            formObj.startOffset.value = startOffset;
                jQuery.get("dummy.html?operation=viewList", params, function(data){
        } else {
            _EVENT = "";
        return false;
<form name="paginationForm">
        <div id="resultArea">
                <!– The list of records to paginate will come here; maybe in a table form –>
        <div id="pageLinks">
                <!– Page links will be rendered by JQuery plugin
                upon calling the paginate callback function for the first time –>
        <input type="hidden" name="startOffset" />        
        <input type="hidden" name="totalItemCount" value="${pageList.totalItemCount}" />        

Style Sheet Switcher

$(document).ready(function() {
               //load silver automatically in ready

                 $("a.silver").click(function() {
                         $('head > link').last().remove();   //removes red and adds silver
                         $('head').append('<link rel="stylesheet" href="style2.css" type="text/css" />');

                 $("a.red").click(function() {
                        $('head > link').last().remove();  //remove silver - adds red
                        .append('<link rel="stylesheet" type="text/css" href="themes/silver/css/template.css"/>');

"DataBase "

DataBase related quick notes:Normalization , Outer Join Vs Inner Join, Sample Stored Procedures, Tiggers etc.,

1 )   DataBase Normalization


  • DataBase Normalization
    Sample Img 1
DataBase Normalization Forms

2 )   Database Outer Join VS Inner Join


  • Database Outer Join VS Inner Join
    Sample Img 2
An inner join of TableA and TableB gives the result of TableA intersect TableB, i.e. the
inner part of a venn diagram intersection.
An outer join of TableA and TableB gives the results of TableA union TableB, i.e. the
outer parts of a venn diagram union.
Suppose you have two Tables, with a single column each, and data as follows:
TableA    TableB
------   ------
1          3
2          4
3          5
4          6
Note that (1,2) are unique to TableA, (3,4) are common, and (5,6) are unique to TableB.
Inner join
An inner join using either of the equivalent queries gives the intersection of the two tables,
i.e. the two rows they have in common.
select * from a INNER JOIN b on a.a = b.b;
select a.*,b.*  from a,b where a.a = b.b;
TableA | TableB
------   ---+--
3      | 3
4      | 4
Left outer join
TableA left outer join will give all rows in TableA, plus any common rows in TableB.
select * from a LEFT OUTER JOIN b on a.a = b.b;
select a.*,b.*  from a,b where a.a = b.b(+);
TableA |  TableB
--     +-----
1      | null
2      | null
3      |    3
4      |    4
Full outer join
TableA full outer join will give you the union of TableA and TableB, i.e. All the rows
in TableA and all the rows in TableB. If something in TableA doesn't have a corresponding
data in TableB, then the TableB portion is null, and vice versa.
select * from TableA FULL OUTER JOIN TableB on a.a = b.b;
 TableA   |  TableB
-----     +-----
   1      | null
   2      | null
   3      |    3
   4      |    4
null      |    6
null      |    5

3 )   Query execution plan


  • Query execution plan
    Sample Img 3
A query plan (or query execution plan) is an ordered set of steps used to access or
modify information in a SQL relational database management system.
There are typically a large number of alternative ways to execute a given query, with
widely varying performance. When a query is submitted to the database,the query optimizer
evaluates some of the different, correct possible plans for executing the query
and returns what it considers the best alternative.
Please take a look at the sample Query Execution Plan above for the following Query.
SELECT  header.[SalesOrderID] ,header.[OrderDate] ,header.[ShipDate] ,details.[ProductID]
,details.[OrderQty] ,details.[UnitPrice] ,header.[CustomerID] FROM
[Sales].[SalesOrderHeader] AS header JOIN [Sales].[SalesOrderDetail] AS details
ON header.[SalesOrderID] = details.[SalesOrderID] WHERE header.[CustomerID] = 29560;
If your application performamce is poor, this is one of the aspect you have to look at,
identify the time consuming Queries and review the execution plans of them and see
you could find an optimal one.

4 )   Select statement Sample

Select distinct pub_id from titles order by type

5 )   Sample Delete

delete authors where syb_identity = 4

6 )   Sample Update

update salesdetail set discount = 40
        from salesdetail readpast
    where title_id like "BU1032"
        and qty > 100

7 )   Sample Cursor ?

create procedure proc2 @flag int
if @flag > 0
    declare names_crsr cursor
    for select au_fname from authors

    declare names_crsr cursor
    for select au_lname from authors

8 )   DataBase Tigger ?

A trigger executes automatically when a user attempts a specified data modification
statement on a specified table.
If the pub_id column of the publishers table is changed, make the corresponding
change in the titles table:
create trigger t2
on publishers
for update as
if update (pub_id) and @@rowcount = 1
    update titles
    set titles.pub_id = inserted.pub_id
    from titles, deleted, inserted
    where deleted.pub_id = titles.pub_id

9 )   Drop And Alter


Drop :
drop table otherdb..newtable

Alter :

alter table titles
    modify notes varchar(150) not null
    with exp_row_size = 40
alter table titles
    add author_type varchar(30) null
    modify city varchar(30)
    drop notes
    add sec_advance money default 1000 not null
    lock datarows
    with exp_row_size = 40

10 )   Sample query with Group By and Having ?

group by
select type, avg(price) from titles group by type order by avg(price)
sets conditions for the group by clause, similar to the way in which where sets
conditions for the select clause. having search conditions can include aggregate
expressions; otherwise, having search conditions are identical to where search
select pub_id, total = sum(total_sales)
from titles
where total_sales is not null
group by pub_id
having count(*)>5

11 )   java.lang.IncompatibleClassChangeError

This Error occurs  when you compile a class with Different Version of JRE other than the one
 which this is being run(the Server on which you deploy this class files).
 For example, you compile a Java file by using Eclips which is using JRE 1.6, create a Jar file these class,
 and you deploy this Jar in a Env which is using JRE 1.4, this exception will be thrown.

Solution :

Please recompile this file with the correct version of JRE, in above case you have re-compile with JRE 1.4

"JavaScript "

Html/JavaScript related quick notes
1 )   Quick HTML Tags?

Body Tag with onLoad Event :
<body onLoad="populateComboBox()"> </body>
Some other Events , onunload
HyperLink with OnClick Event :
<a href="http://testonClick="alert('You Clicked on HyperLink')">Visit your side</a>
Some Other Events,  onmousedown,onmousemove
Tooltip -  Use "alt" attribute for ToolTip
Input Text Box :
<input type="text" name="yourname" />
Text Area :
<textarea rows="2" cols="30">
 your First Text Are
Button with OnClick:
<button type="button" onClick='yourSubmit();'>Click </button>


 <input type="button" value="Click">
Submit Button :
<input type="submit" value="Submit" />
Reset Button :
<input type="reset" value="Reset" />
CheckBox :
<input type="checkbox" name="vehicle" value="Bike" checked />
Combo Box :
<select id='stateList' onchange='OnChange(this)'>
  <option value="NJ">New Jersy</option>
Bullet List
 <ul >
         <li>First Bullet</li>
         <li>First Bullet</li>

 Div :
For invisible
 <div style="display: none;">
  <h2>Click Here</h2>
For Visble
 <div style="display: block;">
  <h2>Click Here</h2>

2 )   Form onLoad ()

<script type="text/javascript">
function loadDropdown()
alert("Load Your Dropdown");

<body onload="loadDropdown()"> 
<h1>Welcome to my Blog</h1>

3 )   Form onunLoad ()

Same as above just use "onunLoad()"

4 )   Button Onclick

<script type="text/javascript">
function yourSubmit()
alert("Submit Your Form");

<body >
<h1>Welcome to Button OnClick Blog</h1>
<button type="button" onClick='yourSubmit();'>Click </button> 

5 )   Adding Options to HTML Dropdown

Following Example Adds the States to States Dropdown
function addTheStates (dataArray,dataIDArray) {
//alert("addTheQuestions " + document.getElementById('questionList'));
for (var i=0;i<dataArray.length;i++){
var option = document.createElement("option");
 option.innerHTML = dataArray[i];


6 )   Get selected Item from a Dropdown?

function getSelectedValue (dropdown1) {
    var myindex  = dropdown1.selectedIndex;
    var SelValue = dropdown1.options[myindex].value;


7 )   Clear HTML Text Boxes

  function clearTextArea() {

8 )   Java Script Disable right Click ?

<script language="JavaScript1.1">
var debug = true; function
right(e) { if (navigator.appName == 'Netscape' && (e.which == 3 || e.which
== 2)) return false; else if (navigator.appName == 'Microsoft Internet Explorer'
&& (event.button == 2 || event.button == 3)) { alert('This Page is fully
protected!'); return false; } return true; } document.onmousedown=right; if (document.layers)
window.captureEvents(Event.MOUSEDOWN); window.onmousedown=right;

    9 )   Java ArrayList to JavaScript Array?

    function convertToArray () {
      var nfhEvents =new Array();
      <% ArrayList nfhList = (ArrayList)request.getAttribute("yourList"); 
      String[] stringArray = (String[])nfhList.toArray(new String[nfhList.size()]); 
      for (int i=0;i< stringArray.length;i++) { 
      %> nfhEvents[<%= i%>] = '<%= stringArray[i] %>'; 
      <% } %> 

    10 )   Parse XML string by using Java Script ?

    unction xmlParser(questionName) {
                str = "<QuestionsList><Question>What is your    name?</Question><Answer>Smith</Answer><
                           /QuestionsList><QuestionsList><Question>Where you born ?</Question><Answer>Herndon</Answer></QuestionsList>";
                            var questionArray =new Array();
                    var xml = $.parseXML(str);
                    var result = $(xml).find("QuestionsList").each(
                    function(){  var question = $(this).find('Question').text();
                                            var name_text = $(this).find('Answer').text(); 
                                            questionArray[i] = img_path;

    11 )   Java Script Pop up window.


    12 )   Java Script "Trim()" function

    Java Script "Trim()" function  
    function trim(str) {
    return str.replace(/^\s+|\s+$/g,"");