Configure HTML/JavaScript

Monday, December 20, 2010

Checking the Request is Ajax

//function to check if the request is made through ajax
function isAjax() {
return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&
($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'));
}
}

in reference to: http://php.net/ (view on Google Sidewiki)

Thursday, December 9, 2010

managing multiple Databases in php

Hi,
This is important to manage your database connections in php if you are using many connections in a single application. you can use single ton pattern in php to make is clear.

Exe:
class Connector {
    private $conn;
    private $intranetdb = 'jprod';
    private $metricsdb = 'metrics_prod';
    private function __costructor(){
           
    }
    static function intranetDb(){
        return 'jprod';
    }
    static function metricsDb(){
        return 'metrics_prod';
    }
    static function makeConnection($host, $username, $password){
        return $this->conn = mysql_connect($host, $username, $password);
    }
    static function prodConnection(){
       
        $prod_dbhost         = 'localhost1';
        $prod_dbuser         = 'jroot';
        $prod_dbpass         = 'joomla1';
        /*
        $prod_dbhost         = 'localhost';
        $prod_dbuser         = 'root';
        $prod_dbpass         = '';
        */
        $prod_conn = mysql_connect($prod_dbhost, $prod_dbuser, $prod_dbpass) or die ('Error connecting to mysql');
        return $prod_conn;
    }
    static function metricsConnection(){
       
        $dbhost         = 'localhost2';
        $dbuser         = 'jroot';
        $dbpass         = 'joomla1';
        /*
        $dbhost         = 'localhost';
        $dbuser         = 'root';
        $dbpass         = '';
        */
        $db             = 'metrics_prod';
        $conn = mysql_connect($dbhost, $dbuser, $dbpass);
        return $conn;
    }
    static function closeConnection($resource){
            return mysql_close($resource);
    }
    static function freeResult($result){
            return mysql_free_result($result);
    }
}

Friday, November 12, 2010

file copy from url in java

public int copyfile(String filesToTransfor[]) {
int oneChar, count = 0;
if (filesToTransfor.length < 1) {
System.err.println("Two file path is required to complete the process");
System.exit(1);
}
try {
URL url = new URL(filesToTransfor[0]);
System.out.println("Opening connection to " + filesToTransfor[0] + "...");
URLConnection urlC = url.openConnection();
// Copy resource to local file, use remote file
// if no local file name specified
InputStream is = url.openStream();
// Print info about resource
System.out
.println("Copying resource (type: " + urlC.getContentType());
// Date date=new Date(urlC.getLastModified());
// System.out.println(", salesnet file modified on: " + date.toString() + ")...");
System.out.flush();
FileOutputStream fos = null;
if (filesToTransfor.length < 2) {
String localFile = null;
// Get only file name
StringTokenizer st = new StringTokenizer(url.getFile(), "/");
while (st.hasMoreTokens())
localFile = st.nextToken();
fos = new FileOutputStream(localFile);
} else
fos = new FileOutputStream(filesToTransfor[1]);

while ((oneChar = is.read()) != -1) {
fos.write(oneChar);
count++;
}
is.close();
fos.close();
System.out.println(count + " byte(s) copied");

} catch (MalformedURLException e) {
System.err.println(e.toString());
} catch (IOException e) {
System.err.println(e.toString());
}

return count;
}

in reference to: Google Toolbar Installed (view on Google Sidewiki)

Saturday, September 4, 2010

example of object in javascript (privileges)

javascript private members of a object

Private Members in JavaScript

Douglas Crockford
www.crockford.com



JavaScript is the world's most misunderstood programming language. Some believe that it lacks the property of information hiding because objects cannot have private instance variables and methods. But this is a misunderstanding. JavaScript objects can have private members. Here's how.
Objects

JavaScript is fundamentally about objects. Arrays are objects. Functions are objects. Objects are objects. So what are objects? Objects are collections of name-value pairs. The names are strings, and the values are strings, numbers, booleans, and objects (including arrays and functions). Objects are usually implemented as hashtables so values can be retrieved quickly.

If a value is a function, we can consider it a method. When a method of an object is invoked, the this variable is set to the object. The method can then access the instance variables through the this variable.

Objects can be produced by constructors, which are functions which initialize objects. Constructors provide the features that classes provide in other languages, including static variables and methods.
Public

The members of an object are all public members. Any function can access, modify, or delete those members, or add new members. There are two main ways of putting members in a new object:
In the constructor

This technique is usually used to initialize public instance variables. The constructor's this variable is used to add members to the object.

function Container(param) {
this.member = param;
}

So, if we construct a new object

var myContainer = new Container('abc');

then myContainer.member contains 'abc'.
In the prototype

This technique is usually used to add public methods. When a member is sought and it isn't found in the object itself, then it is taken from the object's constructor's prototype member. The prototype mechanism is used for inheritance. It also conserves memory. To add a method to all objects made by a constructor, add a function to the constructor's prototype:

Container.prototype.stamp = function (string) {
return this.member + string;
}

So, we can invoke the method

myContainer.stamp('def')

which produces 'abcdef'.
Private

Private members are made by the constructor. Ordinary vars and parameters of the constructor becomes the private members.

function Container(param) {
this.member = param;
var secret = 3;
var that = this;
}

This constructor makes three private instance variables: param, secret, and that. They are attached to the object, but they are not accessible to the outside, nor are they accessible to the object's own public methods. They are accessible to private methods. Private methods are inner functions of the constructor.

function Container(param) {

function dec() {
if (secret > 0) {
secret -= 1;
return true;
} else {
return false;
}
}

this.member = param;
var secret = 3;
var that = this;
}

The private method dec examines the secret instance variable. If it is greater than zero, it decrements secret and returns true. Otherwise it returns false. It can be used to make this object limited to three uses.

By convention, we make a private that parameter. This is used to make the object available to the private methods. This is a workaround for an error in the ECMAScript Language Specification which causes this to be set incorrectly for inner functions.

Private methods cannot be called by public methods. To make private methods useful, we need to introduce a privileged method.
Privileged

A privileged method is able to access the private variables and methods, and is itself accessible to the public methods and the outside. It is possible to delete or replace a privileged method, but it is not possible to alter it, or to force it to give up its secrets.

Privileged methods are assigned with this within the constructor.

function Container

in reference to: Contribute with Sidewiki - Toolbar Help (view on Google Sidewiki)

Thursday, June 24, 2010

learning spanish

few words

I -> estoy
Excuse me -> perdone senora

good morning -> buenos dias
if not morning -> buenos noches

how are you feeling -> como esta?
i am fine -> Estoy ben.

what is your name -> como iiama

my name is anirudda -> me iiama aniruddha

its nice to meet you -> mucho gusto

Thanks

in reference to: Edit My Profile (view on Google Sidewiki)

Wednesday, May 26, 2010

JSON (javascript object notification)

Hi all,

This is one of the technology you can use to make your javascript and ajax objects more powerfull.

declaring object:

var newJsonObj = {}
vat newJsonArr = [];

newJsonObj = { "tty" : android,
"name", aniruddha das,
"posts" : [
{"":thid,}
]
}

in reference to: 4shared.com - free file sharing and storage (view on Google Sidewiki)

Sunday, May 23, 2010

generating a popup calender in javascript

// written by Tan Ling Wee on 2 Dec 2001
// last updated 10 Apr 2002
// email : fuushikaden@yahoo.com

var fixedX = -1 // x position (-1 if to appear below control)
var fixedY = -1 // y position (-1 if to appear below control)
var startAt = 1 // 0 - sunday ; 1 - monday
var showWeekNumber = 1 // 0 - don't show; 1 - show
var showToday = 1 // 0 - don't show; 1 - show
var imgDir = "images/" // directory for images ... e.g. var imgDir="/img/"

var gotoString = "Go To Current Month"
var todayString = "Today is"
var weekString = "Wk"
var scrollLeftMessage = "Click to scroll to previous month."
var scrollRightMessage = "Click to scroll to next month."
var selectMonthMessage = "Click to select a month."
var selectYearMessage = "Click to select a year."
var selectDateMessage = "Select [date] as date." // do not replace [date], it will be replaced by date.

var crossobj, crossMonthObj, crossYearObj, monthSelected, yearSelected, dateSelected, omonthSelected, oyearSelected, odateSelected, monthConstructed, yearConstructed, intervalID1, intervalID2, timeoutID1, timeoutID2, ctlToPlaceValue, ctlNow, dateFormat, nStartingYear

var bPageLoaded=false
var ie=document.all
var dom=document.getElementById

var ns4=document.layers
var today = new Date()
var dateNow = today.getDate()
var monthNow = today.getMonth()
var yearNow = today.getYear()
var imgsrc = new Array("drop1.gif","drop2.gif","left1.gif","left2.gif","right1.gif","right2.gif")
var img = new Array()

var bShow = false;

/* hides and objects (for IE only) */
function hideElement( elmID, overDiv )
{
if( ie )
{
for( i = 0; i < document.all.tags( elmID ).length; i++ )
{
obj = document.all.tags( elmID )[i];
if( !obj || !obj.offsetParent )
{
continue;
}

// Find the element's offsetTop and offsetLeft relative to the BODY tag.
objLeft = obj.offsetLeft;
objTop = obj.offsetTop;
objParent = obj.offsetParent;

while( objParent.tagName.toUpperCase() != "BODY" )
{
objLeft += objParent.offsetLeft;
objTop += objParent.offsetTop;
objParent = objParent.offsetParent;
}

objHeight = obj.offsetHeight;
objWidth = obj.offsetWidth;

if(( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft );
else if(( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop );
else if( overDiv.offsetTop >= ( objTop + objHeight ));
else if( overDiv.offsetLeft >= ( objLeft + objWidth ));
else
{
obj.style.visibility = "hidden";
}
}
}
}

/*
* unhides and objects (for IE only)
*/
function showElement( elmID )
{
if( ie )
{
for( i = 0; i < document.all.tags( elmID ).length; i++ )
{
obj = document.all.tags( elmID )[i];

if( !obj || !obj.offsetParent )
{
continue;
}

obj.style.visibility = "";
}
}
}

function HolidayRec (d, m, y, desc)
{
this.d = d
this.m = m
this.y = y
this.desc = desc
}

var HolidaysCounter = 0
var Holidays = new Array()

function addHoliday (d, m, y, desc)
{
Holidays[HolidaysCounter++] = new HolidayRec ( d, m, y, desc )
}

if (dom)
{
for (i=0;i<

in reference to: Google (view on Google Sidewiki)

opening a new divisin window in javascript and handling ajax operation

//generate the message window

function showWindow(varTotalTax,evt)
{

//var evt = (evt) ? evt : ((window.event) ? window.event : "")
if(evt)
{
var elem = (evt.target) ? evt.target : evt.srcElement
var id = elem.id;
var x = evt.clientX - 10;
var y = evt.clientY + document.body.scrollTop+4;
var divObj = document.getElementById("popupdiv");
divObj.style.display = "block";
divObj.style.position = "absolute";
divObj.style.left = x;
divObj.style.top = y;
if(varTotalTax !=0)
{
divObj.innerHTML = "

"+varTotalTax+"

"
}
else
{
divObj.innerHTML = "Notes not available
X "
}
}
}

// close the generated window
function divclose(name)
{
var divObj;
divObj= document.getElementById(name);
divObj.style.display = "none";
}

in reference to: Google (view on Google Sidewiki)

sending ajax request

function selectState(e)
{
if(e==212)
{
//document.getElementById("countryLvl").innerHTML = "";
document.getElementById("stateLebel").innerHTML = "County : ";
document.getElementById("state").innerHTML = "";
//document.getElementById("countryLvl").innerHTML = "";

}
else
{
document.getElementById("stateLebel").innerHTML = "State : ";
if(xmlHttp)
{
try {
xmlHttp.open("GET","SelectState.php?country="+e, true);
xmlHttp.onreadystatechange = handleServerResponse;
xmlHttp.send(null);
} catch(e) {
alert("Can't connect to server:\n" + e.toString());
}
}
}
}

/*function selectCity(e)
{
var myDivLebel = document.getElementById("cityLebel"); //.innerHTML;
myDivLebel.innerHTML = "City : ";

if(xmlHttp)
{
try {
var country = document.getElementById("countryId").value;
xmlHttp.open("GET","SelectState.php?country="+country+"&state="+e, true);
xmlHttp.onreadystatechange = handleServerResponseCity;
xmlHttp.send(null);
} catch(e) {
alert("Can't connect to server:\n" + e.toString());
}
}
}*/

function handleServerResponse()
{
myDiv = document.getElementById("state");
// display the status o the request
/* if (xmlHttp.readyState == 1)
{
myDiv.innerHTML = "Request status: 1 (loading)
";
}
else if (xmlHttp.readyState == 2)
{
myDiv.innerHTML = "Request status: 2 (loading)
";
}
else if (xmlHttp.readyState == 3)
{
myDiv.innerHTML = "Request status: 3 (loading)
";
}
else*/ if (xmlHttp.readyState == 4)
{
// continue only if HTTP status is "OK"
if (xmlHttp.status == 200)
{
try {
response = xmlHttp.responseText;
//myDiv.innerHTML += "Request status: 4 (complete). Server said:
";
myDiv.innerHTML = response;
} catch(e) {
alert("Error reading the response: " + e.toString());
}
}
}
}

function handleServerResponseCity()
{
myDiv = document.getElementById("city");
/* if (xmlHttp.readyState == 1)
{
myDiv.innerHTML = "Request status: 1 (loading)
";
}
else if (xmlHttp.readyState == 2)
{
myDiv.innerHTML = "Request status: 2 (loading)
";
}
else if (xmlHttp.readyState == 3)
{
myDiv.innerHTML = "Request status: 3 (loading)
";
}
else*/ if (xmlHttp.readyState == 4)
{
// continue only if HTTP status is "OK"
if (xmlHttp.status == 200)
{
try {
response = xmlHttp.responseText;
//myDiv.innerHTML += "Request status: 4 (complete). Server said:
";
myDiv.innerHTML = response;
} catch(e) {
alert("Error reading the response: " + e.toString());
}
}
}
}

in reference to: Google (view on Google Sidewiki)

JavaScript ajax call using xmlHttpRequest and xmlHttpResponse

var xmlHttp = createXmlHttpRequestObject();

function createXmlHttpRequestObject() {
  var xmlHttp;
// if running Internet Explorer  if(window.ActiveXObject) {
    try {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlHttp = false;
      }
    }
  } else { // if running Mozilla or other browsers    
    if(!xmlHttp && typeof ActiveXObject == "undefined") {
      try {
        xmlHttp = new XMLHttpRequest();
      } catch (e) {
        xmlHttp = false;
      }
    }
  }
// return the created object or display an error message  if (!xmlHttp) {
    alert("Error creating the XMLHttpRequest object.");
  } else {
    return xmlHttp;
  }
}


Tuesday, May 18, 2010

jave project arcteture

Hi,

Project Architecure means what are the tiers in our project with flow diagram.

supposoe our project contains five tiers like client tier ,presentation tier, Business tier,Integration tier,Data tier. then we draw the all tiers flow.

project approch is different from project architecure. sorry here i can't insert my own project architecure diagram. if any one want project architecure , project approch then mail me.

Client tier:

• IE Browser (default) from which the end user will access the application
• The request from the browser will be submitted to the Application Server using HTTP protocol.
• The Response from the presentation layer (struts framework) will be interpreted into html pages to view on the browsers.
• Presentation Tier:

Struts Framework with Tiles
• On Request from the browser, the appropriate Action Class handles the user request. The Action class then connects to the business tier via Service Business Delegate.
• Tiles have been used to create a set of pages with a consistent user interface (e.g.: the same navigation bar, header, footer, etc.).
• Taglibs are used for displaying tabular data (e.g. search results) in a consistent fashion, with pagination.
Business Delegate layer
• Enable the Struts Action classes to be unaware of underlying Session Beans
• Encapsulates the invocation of Service Locator to locate them.

Advantages of Struts
‘Centralized File-Based Configuration’, i.e. rather than hard-coding information into Java programs, many Struts values are represented in XML or property files.
This loose coupling means that many changes can be made without modifying or recompiling Java code.
Validation of the user entry fields in the jsps to be handled by entries in the validation.xml and defining validation rules in validator-rules.xml.
Internationalization of the static components of the screen as field and button labels, titles, error messages etc.
This approach also lets Java and Web developers to focus on their specific tasks (like implementing business logic, presenting certain values to clients.) without needing to know about the overall system layout.

Business Tier

• The Business Delegate identifies the business service class (the Session EJBs) and delegates client request to the EJBs. Internally, the session beans are shallow, and delegate all business logic requests to business logic POJOs, which in turn implement the actual functionality.
• The Business Logic POJOs encapsulate the server side business logic. They do not use Hibernate directly, but instead call upon Data Access Objects (DAO) to work with the model. Parameters and return values are modeled as Data Transfer Objects (DTO), and hence no Hibernate model classes will ever leave the DAO layer. The business logic is made available in the business service class, which increases maintainability and easy debugging, if necessary.

Hibernate/DB Tier
The DAOs encapsulates the database access. For all practical purposes, we are using Hibernate (v 2.1) as the OR mapping layer. This saves development time to write SQLs for executing insert and update statements, find by primary key etc. For each value object that directly or compositely represent a table in the database, we have Hibernate mapping files.
For some complex data retrieval, however we will be using raw SQLs (independent of database) from the DAOs and populate the Value Object POJOs. In those specific cases, the DAOs will be having direct access to the Databases using the available connection. The connection properties of the ‘DB Manager’, holding the data sources, direct the request to the appropriate database.

Issues that may rise of Hibernate
• Hibernate no longer supports dynamic proxies
• The Hibernate has issues using Microsoft's driver especially when using SqlServer2000. It appears that the failures are due to some strange handling of dates.
• Hibernate has issues with Informix Databases due to the way JDBC implementation is done in Informix.

keeps smiling and mailing

bora_srinivasarao@yahoo.co.in
Hyderabad

"HELP EVER HU

in reference to: Google (view on Google Sidewiki)

hi

Android Development


Android development is very easy now with Android Studio 2.0. Google guys changed almost everything they can to make the android development super fast and easy. The best part is lots of configuration are automated and you dont have to write or make configuration related changes to start porject.


Developing application in Android studio 2.0

Now a days developing android application is really easy, i remember those days when I started with eclipse and there were hell lot of bugs everywhere. 

Templates:


To start a new porject in android studion 2.0, you can go to the new project wizard and then you will get more options like which types of project you want to create, what layout you want to use, how your pplication will react to the UI, etc. Also they included new now a days device options as well. like if your app will run on android watch, tv etc.

if you are new to android development, you can get all kind of latest news and help at  developer.android.com.


Friday, May 14, 2010

code book

goooing to be realy amagin..

in reference to:

"still he"
- orkut - my orkut (view on Google Sidewiki)

waw its amaging and can be a new innovative way to communicating the web with google wave.

u guys can check the videos from youtube to use google wave both for developer and end users

in reference to: orkut - my orkut (view on Google Sidewiki)

Wednesday, April 28, 2010

android

is there anyone to help me to teach android and help me to make application i will pay for that

in reference to: Google (view on Google Sidewiki)

Saturday, April 17, 2010

yes google is the best

yes you are right,,

i m not ever finded the search engin like google..
it cant be compairable to others

in reference to: Google (view on Google Sidewiki)

its better to follow the wiki for result

hi,

its better you follow this wiki link for the relation between anciant math and art


http://simple.wikipedia.org/wiki/Category:Ancient_mathematicians

in reference to: Nivedita .. - Google Profile (view on Google Sidewiki)

Sunday, April 4, 2010

....

.....

in reference to: Google (view on Google Sidewiki)

hi all ...do the best you can and live the life as you can&gt;&gt;&gt;&gt;&gt;

hi all ...do the best you can and live the life as you can>>>>>


this is one life and can not be back again.


waw.....

in reference to: Google (view on Google Sidewiki)