Tuesday, March 9, 2010

Dynamic table creation using JSON objects.

Hi,
Here is an example for creating dyanmic table using JSON objects.

script type="text/javascript"

// Adding the rows to tbody. From the html we will call the below function.
function displayRows(jsonString){
var tableBody = document.getElementById("QuestionBody");
// Clears the table row contents initally.
while (tableBody.firstChild) {
tableBody.removeChild(tableBody.firstChild);
}
// Fetches the size of the JSON object and creates that many rows.
for(i=0; ivar row = document.createElement('tr');
createTableData(row, jsonString[i]);
tableBody.appendChild(row);
}
document.getElementById("QuestionBody").appendChild(tableBody);
jQuery('#QuestionTable').show();
jQuery('table').Scrollable(100, 800);
}

function createTableData(rowObject, data){
createTableRowContent(rowObject, data, 'td');
}
// Adding the actuall data content to the td.
function createTableRowContent(rowObject, data, cellType){
var rowContent = document.createElement(cellType);
var cell = document.createTextNode(data);
rowContent.appendChild(cell);
rowObject.appendChild(rowContent);
}
/script

Friday, March 5, 2010

Ways to fetch values using Hibernate

There are 3 ways to fetch values using Hibernate.
1) Using the HQL : just write the query in hql and map the tables to Classes and also the columns to attributes in the Class.
Ex:
String queryString = "select columName from tableX where columName like '%"+name+"%'";
List str = getHibernateTemplate().find(queryString);
Note : here in hql we are supposed to use the table attributes as column name and class names as table name.

2) Fetch directly with out using the query statement at all.
Ex : this.getSession().createCriteria(XXX.class).list();

3) write the query in the hbm.xml file and call the query from java file.
Ex :
In the java file :
getHibernateTemplate().findByNamedQuery("selectAllLike", x.trim());
In the hbm file define the selectAllLike query statement like

sql-query name="selectAllLike"
return alias="component" class="com.bofa.osm.hibernate.Component"
SELECT * FROM COMPONENT c WHERE upper(c.NAME) LIKE upper(?)
sql-query

Note : sql-query ans return are the tags.
Cheers
DeepthiMahesh

Friday, February 5, 2010

Food for thought

If you want to make the right decisions in confusing times—Time to refinance? Explore a different career? Root for the singing spinster or the 12-year-old?—you need to pay special attention to what you eat. That’s right: Your grocery list can help with your to-do list. That’s because the right foods are a kind of clean-burning fuel for your body’s biggest energy hog: Your brain. A study in the Journal of Physiology makes the point that, though your brain represents only 2 percent of your body weight, it makes 20 percent of the energy demands on your resting metabolism. On our new Eat This, Not That! Web site, we rounded up the best foods to munch on when you need a mental boost—and found studies that show, in fact, that you can be up to 200 percent more productive if you make the right eating choices. Stock up on these items to halt mental decline, jog your memory, sharpen your senses, improve your performance, activate your feel-good hormones, and protect your quick-witted sharpness, whether you’re 15, 40—or not admitting to any age whatsoever! FOR SHORT-TERM MEMORYDrink This!: COFFEEFresh-brewed joe is the ultimate brain fuel. Caffeine has been shown to retard the aging process and enhance short-term memory performance. In one study, British researchers found that just one cup of coffee helps improve attention and problem-solving skills. Not That!: ENERGY DRINKS/TOO MUCH COFFEEEver heard of the concept “too much of a good thing”? If you OD on caffeine—too many cups, a jolt of caf from the late afternoon onward, a Red Bull cocktail—it can mess with your shuteye schedule. Sleep is reboot time for your mental computer, and you don’t want to mess with it.FOR LONG-TERM MEMORYEat This!: BLUEBERRIESAntioxidants in blueberries help protect the brain from free-radical damage and cut your risk of Alzheimer’s and Parkinson’s diseases. They can also improve cognitive processing (translation: thinking). Wild blueberries, if you can find them, have even more brain-boosting antioxidants than the cultivated variety, so book that vacation in Maine now. The berries will ripen in July. Not That!: THE UNRIPE AND UNREADYHere’s a cool tip: if your favorite berries are out of season, buy them frozen. The freezer locks in peak flavor and nutrients, so the berries’ antioxidant capacity is maxed out. Those pale, tough, and expensive off-season berries usually ripen on a truck, rather than on the bush, so they’re nutritional imposters compared to the real thing.For more smart shopping tips, point your grocery cart to THIS story and learn how to pick the most delicious and nutritious while controlling your waistline! TO THINK FASTEREat This!: SALMON OR MACKERELIf the Internal Revenue Service picks you for some up-close-and-personal auditing, you’ll want to be on your toes when they vet your deductions list. So put salmon or mackerel on the grocery list. The omega-3 fatty acids found in fatty fishes are a primary building block of brain tissue, so they’ll amp up your thinking power. Salmon is also rich in niacin, which can help ward off Alzheimer’s disease and slow the rate of cognitive decline. Not That!: FULL-FAT ICE CREAMNot all fats are created equal: Beware foods high in saturated fats, which can clog blood vessels and prevent the flow of nutrients and blood to the brain. Ice cream is not a brain-health food. TO ENERGIZE:Eat This!: HIGH-PROTEIN SALAD WITH VINAIGRETTEThe oil in the dressing will help slow down digestion of protein and carbs in the salad, stabilizing blood-sugar levels and keeping energy levels high. Build your salad on a bed of romaine and spinach for an added boost in riboflavin, and add chicken and a hard-boiled egg for more energizing protein. Not That!: PANCAKES OR BAGELSMIT researchers analyzed blood samples from a group of people who had eaten either a high-protein or a high-carbohydrate breakfast. Two hours after eating, the carb eaters had tryptophan levels four times higher than those of the people who had eaten protein. The tryptophan in turkey is one of the reasons you crawl off for an afternoon nap after Thanksgiving dinner. So watch what you gobble.TO CALM DOWNEat This!: LOW-FAT YOGURT OR MIXED NUTSScientists in Slovakia gave people 3 grams each of two amino acids—lysine and arginine—or a placebo, and asked them to deliver a speech. Blood measurements of stress hormones revealed that the amino acid-fortified guys were half as anxious during and after the speech as those who took the placebo. Yogurt is one of the best food sources of lysine; nuts pack loads of arginine. Not That!: SODAA study from the American Journal of Public Health found that people who drink 2½ cans of soda daily are three times more likely to be depressed and anxious, compared with those who drink fewer. So Mountain Dew is a Mental Don’t. TO CONCENTRATEEat This!: PEPPERMINT TEAThe scent of peppermint helps you focus and boosts performance, according to researchers. Need to reach Chicago before nightfall, and you’re stuck in traffic around Cleveland? One study found that peppermint makes drivers more alert and less anxious. Not That!: CANDYSugary foods incite sudden surges of glucose that, in the long term, cause sugar highs and lows, leading to a fuzzy state of mind. So you’ll need to avoid all the attention-busting sugar bombs on this list of the 20 most sugar-packed foods in America. FOR GOOD MOODS AND GRINSEat This! ARUGULA OR SPINACH SALADLeafy greens—arugula, chard, spinach—are rich sources of B vitamins, which are key components on the assembly line that manufactures feel-good hormones such as serotonin, dopamine, and norepinephrine. According to a study published in the Journal of Neuroscience Nursing, a lack of B6 can cause nervousness, irritability, and even depression. Not That!: WHITE CHOCOLATEWhite chocolate isn’t chocolate at all, since it contains no cocoa solids. So it won’t stimulate the euphoria-inducing mood boosters like serotonin, as real chocolate does. Grab the real thing, the darker the better. More cacao means more happy chemicals and less sugar, which will eventually pull you down. FOR SHARPER SENSESEat This!: 1 TBSP OF GROUND FLAXSEED DAILYFlax is the best source of alphalinoleic, or ALA—a healthy fat that improves the workings of the cerebral cortex, the area of the brain that processes sensory information, including that of pleasure. To meet your quota, sprinkle it on salads or mix it into a smoothie or shake. Not That!: ALCOHOLThis one’s obvious, but worth mentioning anyway. A drink or two can increase arousal signals, but more than that will actually depress your nervous system. This makes you sloppy, not sharp.


Work for a Cause, not applause. Live to express, not to impress...

Life is short make it sweet.
Satish

The INTERNET now has a personality. YOURS! See your Yahoo! Homepage.

Sunday, December 20, 2009

A Motivational Story with Wisdom

A Professor stood before his philosophy class and had some items in front of him. When the class began, wordlessly, he picked up a very large and empty mayonnaise jar and proceeded to fill it with golf balls. He then asked the students if the jar was full. They agreed that it was.
So the Professor then picked up a box of pebbles and poured them into the jar. He shook the jar lightly. The pebbles rolled into the open areas between the golf balls. He then asked the students again if the jar was full. They agreed it was.
The Professor next picked up a box of sand and poured it into the jar. Of course, the sand filled up everything else. He asked once more if the jar was full. The students responded with an unanimous "yes."
The Professor then produced two cups of coffee from under the table and poured the entire contents into the jar, effectively filling the space between the grains of sand.
"Now," said the professor, as the laughter subsided, "I want you to recognize that this jar represents your life. The golf balls are the important things--your family, your children, your health, your friends, and your favorite passions - things that if everything else was lost and only they remained, your life would still be full.
The pebbles are the other things that matter like your job, your house, and your car. The sand is everything else -the small stuff.
"If you put the sand into the jar first," he continued, "there is no room for the pebbles or the golf balls. The same goes for life. If you spend all your time and energy on the small stuff, you will never have room for the things that are important to you. Pay attention to the things that are critical to your happiness. Play with your children. Take time to get medical checkups. Take your partner out to dinner. Play another 18.
There will always be time to clean the house and fix the disposal. "Take care of the golf balls first, the things that really matter. Set your priorities. The rest is just sand."
One of the students raised her hand and inquired what the coffee represented. The Professor smiled. "I'm glad you asked.
"It just goes to show you that no matter how full your life may seem, there's always room for a couple of cups of coffee with a friend."

Thursday, December 17, 2009

Customized Java scripts Alerts

Here is the code through which we can override the JavaScript window.Alert() and write our own custom alerts where we can define our own title, text in the button of alert box :
Just we need to follow the below files and enjoy the customzied Javascript Alerts.

CSS Code :
just copy the below code in the "style type="text/css" " tag and "/style"

#alertBox {
position:relative;
width:300px;
min-height:100px;
margin-top:50px;
border:2px solid #000;
background-color:#F2F5F6;
background-image:url(alert.png);
background-repeat:no-repeat;
background-position:20px 30px;
}
#alertBox h1 {
margin:0;
font:bold 0.9em verdana,arial;
background-color:#78919B;
color:#FFF;
border-bottom:1px solid #000;
padding:2px 0 2px 5px;
}
#alertBox p {
font:0.7em verdana,arial;
height:50px;
padding-left:5px;
margin-left:55px;
}
#alertBox #closeBtn {
display:block;
position:relative;
margin:5px auto;
padding:3px;
border:2px solid #000;
width:70px;
font:0.7em verdana,arial;
text-transform:uppercase;
text-align:center;
color:#FFF;
background-color:#78919B;
text-decoration:none;
}

JavaScript Code :

just copy the below code in the javaScript code "
script type="text/javascript"" " tag and "/script"

var ALERT_TITLE = "Oops!";
var ALERT_BUTTON_TEXT = "Ok";
if(document.getElementById) {
window.alert = function(txt) {
createCustomAlert(txt);
}
}
function createCustomAlert(txt) {
d = document;
if(d.getElementById("modalContainer")) return;
mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
mObj.id = "modalContainer";
mObj.style.height = d.documentElement.scrollHeight + "px";
alertObj = mObj.appendChild(d.createElement("div"));
alertObj.id = "alertBox";
if(d.all && !window.opera) alertObj.style.top = document.documentElement.scrollTop + "px";
alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth)/2 + "px";
alertObj.style.visiblity="visible";
h1 = alertObj.appendChild(d.createElement("h1"));
h1.appendChild(d.createTextNode(ALERT_TITLE));
msg = alertObj.appendChild(d.createElement("p"));
//msg.appendChild(d.createTextNode(txt));
msg.innerHTML = txt;
btn = alertObj.appendChild(d.createElement("a"));
btn.id = "closeBtn";
btn.appendChild(d.createTextNode(ALERT_BUTTON_TEXT));
btn.href = "#";
btn.focus();
btn.onclick = function() { removeCustomAlert();return false; }
alertObj.style.display = "block";
}
function removeCustomAlert() {
document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
}

HTML Code :
<input type="button" value = "Test the alert" onclick="alert('This is a custom alert dialog that was created by over-riding the window.alert method.');" />

Monday, November 30, 2009

Interactive Sites on Medical INFO - Very useful

The tutorials listed below are interactive health education resources from the Patient Education Institute. Using animated graphics each tutorial explains a procedure or condition in easy-to-read language. You can also listen to the tutorial. JUST CLICK ON YOUR PREFFERED AILMENT NOTE: These tutorials require a special Flash plug-in, version 6 or above... If you do not have Flash, you will be prompted to obtain a free download of the software before you start the tutorial.
Diseases and Conditions
Abdominal Aortic Aneurysm
Acne
AIDS
Allergies to Dust Mites
Alopecia
Amyotrophic Lateral Sclerosis (ALS)
Angina
Anthrax
Arrhythmias
Arthritis
Asthma
Atrial Fibrillation
Avian Influenza
Back Pain - How to Prevent
Bell's Palsy
Brain Cancer
Breast Cancer
Burns
Cataracts
Cerebral Palsy
Cold Sores (Herpes)
Colon Cancer
Congestive Heart Failure
COPD (Chronic Obstructive Pulmonary Disease)
Crohn's Disease
Cystic Fibrosis
Depression
Diabetes - Eye Complications
Diabetes - Foot Care
Diabetes - Introduction
Diabetes - Meal Planning
Diverticulosis
Endometriosis
Epstein Barr (Mononucleosis)
Erectile Dysfunction
Fibromyalgia
Flashes and Floaters
Fractures and Sprains
Ganglion Cysts
Gastroesophageal Reflux Disease (GERD)
Glaucoma
Gout
Hearing Loss
Heart Attack
Hepatitis B
Hepatitis C
Hypertension (High Blood Pressure)
Hypoglycemia
Incisional Hernia
Influenza
Inguinal Hernia
Irritable Bowel Syndrome
Kidney Failure
Kidney Stones
Leishmaniasis
Leukemia
Low Testosterone
Lung Cancer
Lupus
Lyme Disease
Macular Degeneration
Malaria
Melanoma
Meningitis
Menopause
Migraine Headache
Mitral Valve Prolapse
Multiple Myeloma
Multiple Sclerosis
Myasthenia Gravis
Osteoarthritis
Osteoporosis
Otitis Media
Ovarian Cancer
Ovarian Cysts
Pancreatitis
Parkinson's Disease
Pneumonia
Prostate Cancer - What is it?
Psoriasis
Retinal Tear and Detachment
Rheumatoid Arthritis
Rotator Cuff Injuries
Sarcoidosis
Scabies
Seizures and Epilepsy
Sexually Transmitted Diseases
Shingles
Skin Cancer
Sleep Disorders
Smallpox
Spinal Cord Injury
Temporomandibular Joint Disorders (TMJ)
Tennis Elbow
Tinnitus
Trigeminal Neuralgia
Tuberculosis
Ulcerative Colitis
Umbilical Hernia
Uterine Fibroids
Varicose Veins
Vasculitis
Warts
Tests and Diagnostic Procedures
Amniocentesis
Barium Enema
Bone Densitometry
Breast Lumps - Biopsy
Bronchoscopy
Colonoscopy
Colposcopy
Coronary Angiogram and Angioplasty
CT Scan (CAT Scan)
Cystoscopy - Female
Cystoscopy - Male
Echocardiogram
Echocardiography Stress Test
IVP (Intra Venous Pyelogram)
Knee Arthroscopy
Laparoscopy
Mammogram
MRI
Myelogram
Newborn Screening
Pap Smear
Shoulder Arthroscopy
Sigmoidoscopy
Ultrasound
Upper GI Endoscopy
Surgery and Treatment Procedures
Aorto-Bifemoral Bypass
Cardiac Rehabilitation
Carotid Endarterectomy
Carpal Tunnel Syndrome
Chemotherapy
Cholecystectomy - Open Laparoscopic (Gallbladder Removal Surgery)
Clinical Trials
Colon Cancer Surgery
Colostomy
Coronary Artery Bypass Graft (CABG)
C-Section
Dilation and Curettage (D & C)
General Anesthesia
Heart Valve Replacement
Hemorrhoid Surgery
Hip Replacement
Hip Replacement - Physical Therapy
Hysterectomy
Knee Replacement
LASIK
Massage Therapy
Neurosurgery - What is it?
Open Heart Surgery - What to Expect?
Pacemakers
Preparing for Surgery
Prostate Cancer - Radiation Therapy
Shoulder Replacement
Sinus Surgery
Stroke Rehabilitation
Thyroid Surgery
Tonsillectomy and Adenoidectomy
TURP (Prostate Surgery)
Vaginal Birth
Vasectomy
Prevention and Wellness
Back Exercises
Coumadin - Introduction
Exercising for a Healthy Heart
Managing Cholesterol
Muscles
Preventing Strokes
Smoking - The Facts

Saturday, November 28, 2009

Annotations

Annotation: From English Dictionary, it's the explanation/comments/Remarks/Observations/Notes/Clarifications.

Annotations in Java: Annotations are like meta-tags that you can add to your code and apply them to package declarations, type declarations, constructors, methods, fields, parameters, and variables. As a result, you will have helpful ways to indicate whether your methods are dependent on other methods, whether they are incomplete, whether your classes have references to other classes, and so on.
Pros & cons of Annotations:

Pros :1) Annotations are relatively simple to use and understand.2) Compilation time requires less for annotations when compared to the xml-configurations.3) Annotations are used for flexibility.4) Annotations can be used by the compiler to detect errors or suppress warnings.5) Software tools can process annotation information to generate code, XML files, and so forth.6) Annotations can be applied to a program's declarations of classes, fields, methods, and other program elements.

Cons: Annotations unnecessarily couple the metadata to the code. Thus, changes to metadata require changing the source code. (i.e. when we want to change some configuration , we need to change the source code, where as in the xml -configuration, just need to change the xml file & redeploy it ).
Two things in Annotations:

1) Annotation : An annotation is the meta-tag that you will use in your code to give it some life.

2) Annotation Type: It is used for defining an annotation. used when we need to create our own custom annotation.
Define an Annotation type: In order to define our own custom tag, the following syntax need to be followed. "@" symbol followed by "interface" followed by "Name of the annotations".
Example:
public @interface MyAnnotation {String doSomething();}

Annotate Your Code (Annotation)
We are just supposed to use the name of our annotations & assign some values to the annotation variables.
Example:
MyAnnotation (doSomething="What to do")public void mymethod() {....}
Annotation Types:

There are three annotation types:

Marker: Marker type annotations have no elements, except the annotation name itself. Example: public @interface MyAnnotation {}Usage: @MyAnnotationpublic void mymethod() {....}

Single-Element: Single-element, or single-value type, annotations provide a single piece of data only. This can be represented with a data=value pair or, simply with the value (a shortcut syntax) only, within parenthesis.Example: public @interface MyAnnotation {String doSomething();}Usage: @MyAnnotation ("What to do")public void mymethod() {....}

Full-value or multi-value: Full-value type annotations have multiple data members. Therefore, you must use a full data=value parameter syntax for each member.Example: public @interface MyAnnotation {String doSomething();int count; String date();}Usage: @MyAnnotation (doSomething="What to do", count=1,date="09-09-2005")public void mymethod() {....}

Rules to define an Annotation Type.
1) Annotation declaration should start with an 'at' sign like @, following with an interface keyword, following with the annotation name.2) Method declarations should not have any parameters.3) Method declarations should not have any throws clauses.4) Return types of the method should be one of the following:i) primitivesii) Stringiii) Classiv) enumv) array of the above types
Annotation :

Simple annotations : These are the basic types supplied with Tiger, which you can use to annotate your code only; you cannot use those to create a custom annotation type. There are only three types of simple annotations provided by JDK5.

They are:

Override : ( @Override ) throws an error when it some method is not overrided preoperly.
Deprecated: ( @Deprecated ) throws warnings when a method is used which is deprecated.
Suppress warnings: This annotation indicates that compiler warnings should be shielded in the annotated element and all of its sub-elements. @SuppressWarnings({"deprecation
Meta annotations : These are called the annotations-of-annotations
These are:i) Targetii) Retentioniii) Documentediv) Inherited.

The Target annotation : The target annotation indicates the targeted elements of a class in which the annotation type will be applicable. It contains the following enumerated types as its value:@Target(ElementType.TYPE)—can be applied to any element of a class@Target(ElementType.FIELD)—can be applied to a field or property@Target(ElementType.METHOD)—can be applied to a method level annotation@Target(ElementType.PARAMETER)—can be applied to the parameters of a method@Target(ElementType.CONSTRUCTOR)—can be applied to constructors@Target(ElementType.LOCAL_VARIABLE)—can be applied to local variables@Target(ElementType.ANNOTATION_TYPE)—indicates that the declared type itself is an annotation type
The Retention annotation:The retention annotation indicates where and how long annotations with this type are to be retained. There are three values:RetentionPolicy.SOURCE—Annotations with this type will be by retained only at the source level and will be ignored by the compilerRetentionPolicy.CLASS—Annotations with this type will be by retained by the compiler at compile time, but will be ignored by the VMRetentionPolicy.RUNTIME—Annotations with this type will be retained by the VM so they can be read only at run-time
The Documented annotation : The documented annotation indicates that an annotation with this type should be documented by the javadoc tool. . By default, annotations are not included in javadoc. But if @Documented is used, it then will be processed by javadoc-like tools and the annotation type information will also be included in the generated document
The Inherited annotation: Automatically all the methods are inherited in the child class.
Ex :@Inheritedpublic @interface myParentObject {boolean isInherited() default true;String doSomething() default "Do what?";}
Next, annotate a class with your annotation:
@myParentObjectpublic Class myChildObject {}

If there were no annotations , we should have written the class in the following way. i.e. we need to implement all the methods
public class myChildObject implements myParentObjectpublic boolean isInherited() {return false;}public String doSomething() {return "";}public boolean equals(Object obj) {return false;}public int hashCode() {return 0;}public String toString() {return "";}public Class annotationType() {return null;}}