7 Using JSP components - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

7 Using JSP components

Description:

7.2.1 The different types of JavaBeans. Visual component beans. elements of GUI's. Data beans ... fully qualified name of the bean class. The type attribute ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 12
Provided by: usersT
Category:
Tags: jsp | beans | components | of | types | using

less

Transcript and Presenter's Notes

Title: 7 Using JSP components


1
7 Using JSP components
2
7.1 The JSP component model
  • ? JavaBeans
  • 7.1.1 Component architectures
  • Component self-contained, reusable software
    elements that encapsulate application behavior or
    data into a discrete package
  • 7.1.2 Benefits of a component architecture
  • Abstraction
  • Reusability
  • 7.1.3 Component design for web projects
  • 7.1.4 Building applications from components

3
7.2 JavaBean fundamentals
  • Bean containers? allows developers to call up
    beans, configure them and access their
    information and behavior
  • Bean properties
  • ? named attributes of the bean that maintain its
    state and control its behavior
  • Trigger and linked properties? properties used
    to trigger behavior and report information?
    changing the value of one updates the value of
    others linked properties
  • Indexed properties? collection of values, each
    value is accessible through an index number
  • Property data types? Java primitives, Java
    objects, user-defined objects, other beans
  • Bean property sheets? description of the
    features of a bean

4
7.2 JavaBean fundamentals
  • 7.2.1 The different types of JavaBeans
  • Visual component beans? elements of GUIs
  • Data beans? access to a collection of
    information
  • Service beans? perform specific tasks or
    calculations ( worker beans)

5
7.3 JSP bean tags
  • 7.3.1 Tag-based component programming
  • 7.3.2 Accessing JSP components
  • 7.3.3 Initializing beans
  • 7.3.4 Controlling a beans scope

6
7.3 JSP bean tags
  • 7.3.1 Tag-based component programming
  • ltjspuseBeangtltjspsetPropertygtltjspgetPropertygt
  • Custom tag libraries? support additional
    programming constructions and functionality

7
7.3 JSP bean tags
  • 7.3.2 Accessing JSP components
  • The ltjspuseBeangt tag
  • make a bean available by creating or fetching an
    existing one from the server
  • requires two attributes id and class
  • ltjspuseBean idbean name classclass namegt
  • other attributes scope, type, beanName
  • The ID attribute
  • unique name for the bean
  • case sensitive
  • first character must be a letter
  • only letters, numbers and _ are allowed

8
7.3 JSP bean tags
  • 7.3.2 Accessing JSP components
  • The class attribute
  • fully qualified name of the bean class
  • The type attribute
  • if you need to refer to the bean as another type,
    for example a base class or an interface that the
    bean implements
  • if you specify both class and type, the bean will
    be created using the class, then cast to type
  • The beanName attribute
  • specifies the name of a bean which will be passed
    to the instantiate() method of the
    java.beans.Beans class
  • can be assigned throug a runtime expression

9
7.3 JSP bean tags
  • 7.3.2 Accessing JSP components
  • The tag body
  • Initialize any user configurable properties of
    the bean
  • ltjspuseBeangt in action
  • Only available to portions of the page following
    the tag
  • Accessing bean properties with ltjspgetPropertygt
  • ltjspgetProperty namebean name
    propertyproperty name/gt
  • The ltjspsetPropertygt tag
  • ltjspsetProperty namebean name
    propertyproperty name valueproperty value/gt
  • Indexed properties
  • Collection of values
  • lt bean.getPropertyName(index) gt

10
7.3 JSP bean tags
  • 7.3.3 Initializing beans
  • ? setting the value of configurable properties
  • ? first time the bean is created
  • bean configuration
  • in the body tag of ltjspuseBeangt
  • ltjspuseBean idmyBean classbe.syntra.MyBeangt
    ltjspsetProperty namemyBean
    propertycounter value0/gtlt/jspuseBeangt
  • initializing beans from the request
  • ltform actionpage.jspgt
  • Specifying default initialization values
  • ltjspsetProperty namecounter propertystart
    value0/gtltjspsetProperty namecounter
    propertystart valuestartValue/gt
  • A security consideration
  • ltjspsetProperty property/gt

11
7.3 JSP bean tags
  • 7.3.4 Controlling a beans scope
Write a Comment
User Comments (0)
About PowerShow.com