الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

JavaBean

مغلق
بدأه prog_Basem في 23 مارس 2007 · 3 رد · 1,288 مشاهدة · في JavaEE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

انا لسه مبتدئ فى jsp والحمد لله شايف انها لغاية دلوقتى مش صعبة لكن لما وصلت للjavabean مش قادر افهمها خالص ممكن حد ياريت يفهمهالى

#2

JavaBean is simple class file. this class used for storing/receive data at runtime.

Some Library & IDE use these class style to recognized the structure of class.

In JSP u will use JavaBeans to Store/Read data and JVM will set the value to veriable at runtime automatically.

Let take A simall exmaple:

//First a declare simple class called employee to store employee information


//Every employee has 2 properties

//Name to store employee name

private String name;

//Age to store employee age

private byte age;


public Employee(){

name = null;

age = 1;

}


}
class Employee {

This class is just simple class but not javabean yet, to make it javabean we must apply these conditions

1- Every property must has get Method : this method JVM will be called at runtime.

the name of this property must be like this expression:

public <return type like variable datatype> get<variable name>

for example :


return name;

}


public byte getAge(){

return age

}
public String getName(){

2- (Not required for read only variables) the class must contain the setter method for property: this method JVM will be called at runtime when it try to set new value to variable.

Expression:

public void set<variable name>(<parameter has same variable datatype>)

example:


this.name = name;

}


public void setAge(byte age){

this.age = age;

}
	public void setName(String name){

So finally the class must be like this:

class Employee {

private String name;

private byte age;

public Employee(){

name = null;

age = 1;

}

public String getName(){

return name;

}

public byte getAge(){

return age

}

public void setName(String name){

this.name = name;

}

public void setAge(byte age){

this.age = age;

}

}

So, this class has ability to store name/age of employee.

for more information about how can I call these beans for JSP page see this link:
http://stardeveloper.com/articles/display....2001&page=1

تم تعديل هذه المشاركة بواسطة yadoo86 في 23 مارس 2007 في 21:18

winter-main.jpg

6179.gif

#3

شكرا على مساعدتك yadoo

#4

غفر الله لك علي هذا الموقع الرائع

هذا الموضوع مغلق.

مواضيع مشابهة