Monday, August 13, 2012
JOptionPane - showInputDialog
import javax.swing.*;
class AdditionDemo{
public static void main(String rk[]){
try{
String num1 = JOptionPane.showInputDialog("Input fist Value") ;
String num2 = JOptionPane.showInputDialog("Input second Value") ;
int a = Integer.parseInt(num1);
int b = Integer.parseInt(num2);
int c = a+b;
JOptionPane.showMessageDialog(null," Total is : "+c);
}catch(Exception e ){
JOptionPane.showMessageDialog(null,"Oop !! Buddy, you gave wrong input. :-( ");
}
}
}
REGEX for number greater than zero
var nre= /^[1-9]+[0-9]*$/;
var regexp = new RegExp(nre);
if(regexp.test(val)){
alert(“Number is greater than zero.”)
}
var regexp = new RegExp(nre);
if(regexp.test(val)){
alert(“Number is greater than zero.”)
}
STRUTS : logic:notEmpty
"<"logic:notEmpty name=”beanName” property=”beanPropertyName”">"
"<"bean:write name=”beanName” property=”beanPropertyName”/">"
"<"/logic:notEmpty">"
Note : if you have DataBean.java class with userName as its one property variable, and if you gave one object of DataBean class i.e “dataBean” in request scope , then you could use that object as given below into the destination .jsp page.
"<"logic:notEmpty name=”dataBean” property=”userName”">"
"<"bean:write name=”dataBean” property=”userName”/">"
"<"/logic:notEmpty">"
"<"bean:write name=”beanName” property=”beanPropertyName”/">"
"<"/logic:notEmpty">"
Note : if you have DataBean.java class with userName as its one property variable, and if you gave one object of DataBean class i.e “dataBean” in request scope , then you could use that object as given below into the destination .jsp page.
"<"logic:notEmpty name=”dataBean” property=”userName”">"
"<"bean:write name=”dataBean” property=”userName”/">"
"<"/logic:notEmpty">"
STRUTS – ITERATE MAP – logic:iterate
"<"logic:iterate id=”keyValuePair” name=”mapName”">"
"<"bean:write name=”keyValuePair” property=”key”/">"
"<"bean:write name=”keyValuePair” property=”value”/">"
"<"/logic:iterate">"
"<"bean:write name=”keyValuePair” property=”key”/">"
"<"bean:write name=”keyValuePair” property=”value”/">"
"<"/logic:iterate">"
STRUTS- ITERATE LIST : logic:iterate
"<"logic:iterate id=”userName” name=”userNameList”">"
"<"bean:write name=”userName”/">"
"<"/logic:iterate">"
"<"bean:write name=”userName”/">"
"<"/logic:iterate">"
STRUTS- ITERATE LIST TO GET OBJECT : logic:iterate
"<"logic:iterate id=”studDataObj” name=”dataList” type=”com.student.Data” ">"
"<"bean:write name=”studDataObj” property=”rollNumber”/">"
"<"bean:write name=”studDataObj” property=”name”/">"
"<"/logic:iterate">"
Note : Here com.student.Data is the package name with actualy “Data.java” class
class Data {
String name;
int rollNumber;
/*
……………
setter getter method
…………….
*/
}
"<"bean:write name=”studDataObj” property=”rollNumber”/">"
"<"bean:write name=”studDataObj” property=”name”/">"
"<"/logic:iterate">"
Note : Here com.student.Data is the package name with actualy “Data.java” class
class Data {
String name;
int rollNumber;
/*
……………
setter getter method
…………….
*/
}
STRUTS : logic:equal , logic:notEqual
logic:equal
"<"logic:equal name=”studentDataObject” property=”rollNumber” value=”11″">"
"<"bean:write name=”studentDataObject” property=”rollNumber”/">"
"<"/logic:equal">"
——————————————————————————————————-
logic:notEqual
"<"logic:notEqual name=”studentDataObject” property=”rollNumber” value=”3″">"
"<"bean:write name=”studentDataObject” property=”rollNumber”/">"
"<"/logic:notEqual">"
"<"logic:equal name=”studentDataObject” property=”rollNumber” value=”11″">"
"<"bean:write name=”studentDataObject” property=”rollNumber”/">"
"<"/logic:equal">"
——————————————————————————————————-
logic:notEqual
"<"logic:notEqual name=”studentDataObject” property=”rollNumber” value=”3″">"
"<"bean:write name=”studentDataObject” property=”rollNumber”/">"
"<"/logic:notEqual">"
JQUERY : GET SELECT-OPTION VALUE
$(document).ready(function() {
$('#selectElementId').change(function(){
var value=$('#selectElementId').val();
alert(value)
});
});
$('#selectElementId').change(function(){
var value=$('#selectElementId').val();
alert(value)
});
});
Subscribe to:
Posts (Atom)