WDD_lec_36 - variables (fields) • Private values should...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
CourseOutline Example & JavaBeans Lec - 36
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Start with Example Displaying Course Outlines User will select either course “web design & development” or “java” . On submitting request, course outline would be displayed of the selected course from database
Background image of page 2
Program Flow index.jsp controller .jsp web.jsp java.jsp If page = = web If page = = java
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Issues with Last Example Too much cluttered code in JSP Difficult to understand A single page is doing everything – bad approach Displaying contents (Presentation logic) Connecting with database (DB connectivity logic) Results Processing (Business Logic) Solution: Use JavaBeans
Background image of page 4
JavaBeans
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
What are JavaBeans? Java class that can be easily reused and composed together in an application Any java class that follows certain design conventions can be a JavaBeans component
Background image of page 6
JavaBeans Design Conventions A bean class must have a zero argument constructor A bean class should not have any public instance
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 8
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 10
Background image of page 11
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: variables (fields) • Private values should be accessed through setters/getters – For boolean data types, use boolean isXXX( ) & setXXX(boolean) • A bean class must be serializable A Sample JavaBean public class MyBean implements Serializable { private String name; // zero argument constructor public MyBean( ){ name = “”; } // standard setter public void setName(String n) { name = n; } A Sample JavaBean cont. // standard getter public String getName( ) { return name; } // any other method public void print( ) { System.out.println(“Name is: ” + name); } } // end Bean class Incorporating Bean in Last Example • Create a CourseOutlineBean – Has following attributes • sessionNo • topic • assignment • Create a CourseDAO (bean) – Encapsualte database connectivity logic • web.jsp & java.jsp will use these beans Example Code Incorporating JavaBeans in CourseOutline Example...
View Full Document

This note was uploaded on 07/01/2010 for the course CS CS506 taught by Professor mr. umair javed during the Spring '10 term at Virtual University of Pakistan.

Page1 / 11

WDD_lec_36 - variables (fields) • Private values should...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online