Which tag handler method will accomplish this goal?

You web application uses a lot of Java enumerated types in the domain model of the application.
Built into each enum type is a method, getDisplay(), which returns a localized, user-oriented string.
There are many uses for presenting enums within the web application, so your manager has
asked you to create a custom tag that iterates over the set of enum values and processes the
body of the tag once for each value; setting the value into a pagescoped attribute called,
enumValue. Here is an example of how this tag is used:

You have decided to use the Simple tag model to create this tag handler. Which tag handler
method will accomplish this goal?

You web application uses a lot of Java enumerated types in the domain model of the application.
Built into each enum type is a method, getDisplay(), which returns a localized, user-oriented string.
There are many uses for presenting enums within the web application, so your manager has
asked you to create a custom tag that iterates over the set of enum values and processes the
body of the tag once for each value; setting the value into a pagescoped attribute called,
enumValue. Here is an example of how this tag is used:

You have decided to use the Simple tag model to create this tag handler. Which tag handler
method will accomplish this goal?

A.
public void doTag() throw JspException {
try {
for ( Enum value : getEnumValues() ) {
pageContext.setAttribute(“enumValue”, value);
getJspBody().invoke(getOut());
}
} (Exception e) { throw new JspException(e); }
}

B.
public void doTag() throw JspException { try {
for ( Enum value : getEnumValues() ) {
getJspContext().setAttribute(“enumValue”, value);
getJspBody().invoke(null);
}
} (Exception e) { throw new JspException(e); }
}

C.
public void doTag() throw JspException {
try {
for ( Enum value : getEnumValues() ) {
getJspContext().setAttribute(“enumValue”, value);
getJspBody().invoke(getJspContext().getWriter());
}}
(Exception e) { throw new JspException(e); }
}

D.
public void doTag() throw JspException {
try {
for (
Enum value : getEnumValues() ) {
pageContext.setAttribute(“enumValue”, value);
getJspBody().invoke(getJspContext().getWriter());
}
} (Exception e) { throw new JspException(e); }
}

Explanation:



Leave a Reply 0

Your email address will not be published. Required fields are marked *