Pass data structure from PHP to JS
In JS:
var ap_radioMode = unserialize('<?php echo serialize ($ap_radioMode) ?>');
i.e. Use PHP's serialze() and echo out the value, then apply JS's counterpart unserialize() to get the data structure.
In JS:
var ap_radioMode = unserialize('<?php echo serialize ($ap_radioMode) ?>');
Posted by
Ginger
at
3:32 PM
0
comments
Cookie is sent from web server to the browser as a header, and it is stored in the browser. On all the subsequent requests, the browser would send the cookie data transparently to the server, So it advised to keep the size minimal.
Http Session data is stored in the server, but its session identifier is sent in cookie. In this way, the session reference is passed instead of the actual data to save network traffic. When the user disable the cookie in the browser, URL rewrite (response.encodeUrl) will be used to append jsessionid on url parameters.
When a GET hits the server with no session cookie or id, Tomcat creates a new session and sets the cookie:
Set-Cookie: JSESSIONID=2978A7FABFF3DB35BE622290E1294CDE; Path=/
It then also encodes all URLs on a page with jsessionid. At this point, does not know if the browser supports cookies. So the next GET (with both cookie and URL parameter) is required to decide if cookies are OK or not.
Posted by
Ginger
at
5:45 PM
0
comments

The JNDI architecture consists of an API and a service provider interface (SPI). Java applications use the JNDI API to access a variety of naming and directory services. The SPI enables a variety of naming and directory services to be plugged in transparently.RMIRegistry is also one type of JNDI provider besides Ldap, File System.
envs.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.rmi.registry.RegistryContextFactory");
envs.put(Context.PROVIDER_URL, "rmi://localhost:1099");
Posted by
Ginger
at
5:39 PM
0
comments
The window.onload event is synchronous with images and external dependencies, so it doesn't fire until they've all resolved (or timed out), also in some browser (IE), the target elements that do not yet exist when onload event fired. What we really want is an event that fires when the DOM ready, YUI's onDOMReady(), onAvailable() and onContentReady () help to avoid this problem.
Event object is accessed differently in different browser. In IE the event object is accessed through the window object, whereas in Firefox, it is automatically passed to your event handler as an argument.
[1] has a good explanation on the callback function signature.
Callback for Native Browser Events
var callback = function(e, o) {
alert(o.msg);
};
YAHOO.util.Event.addListener(elemId, "click", callback, {msg: "hi"});
var callback = function(e, a, o) {
//a is an array contains arguments fire method: arg1, arg2, ...
//o is the object passed from the subscribe method
alert(o.msg);
};
//to fire this event
eventObj.fire(arg1, arg2, ...);
//to listen to this event
eventObj.subscribe(callback, {msg: "hi"});
var callback = function(a, o) {
//a is the first argument that passed to fire method of this event
//o is the object passed from the subscribe method
alert(o.msg);
};
//to fire this event
eventObj.fire(arg);
//to listen to this event
eventObj.subscribe(callback, {msg: "hi"});
Posted by
Ginger
at
11:05 PM
0
comments