10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Java</strong>Beans Components<br />

168<br />

<strong>The</strong> following element creates an instance of mypkg.myLocales if none exists, stores it as an<br />

attribute of the application scope, and makes the bean available throughout the application by<br />

the identifier locales:<br />

<br />

Setting <strong>Java</strong>Beans Component Properties<br />

<strong>The</strong> standard way to set <strong>Java</strong>Beans component properties in a JSP page is by using the<br />

jsp:setProperty element. <strong>The</strong> syntax of the jsp:setProperty element depends on the source<br />

of the property value. Table 5–6 summarizes the various ways to set a property of a <strong>Java</strong>Beans<br />

component using the jsp:setProperty element.<br />

Note –<br />

Syntax rules of attribute values used in this table:<br />

1. beanName must be the same as that specified for the id attribute in a useBean element.<br />

2. <strong>The</strong>re must be a setPropName method in the <strong>Java</strong>Beans component.<br />

3. paramName must be a request parameter name.<br />

TABLE 5–6 Valid Bean Property Assignments from String Values<br />

Value Source Element Syntax<br />

String constant <br />

Request parameter <br />

Request parameter name that<br />

matches bean property<br />

<br />

<br />

Expression <br />

<br />

<br />

expression<br />

<br />

<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!