JSP Tag Libraries

Скачать в pdf «JSP Tag Libraries»


Creates a link to a dynamically created card.


Displays the link name using the product name.


Ends the iteration of products.


Ends the iteration of categories.


Figure 14.8 Viewing a category card



1*


1(


2)


2!


2@



Iterates through the products. For every Product, a card is created with its ID made up of the keyword prod and the Product’s SKU. In each card an option to add the Product to the user’s current Order is available. Inside the card, the Product’s SKU and price are listed together with an input field wherein the user can specify the amount they wish to order. The price is formatted for the currently used locale. The result will look like in
figure 14.9Adds a card for each product.


For each card, uses the product name as title.


Adds an option to add the product to the current order.


Figure 14.9


Viewing a product card



Displays the product’s SKU.



Displays the product’s price. As the <currency> tag is used without any specified locale, the tag will look in the context for it.
Listing 14.8 shows a Locale setting in the web.xml file.


Ends the iteration of products.


Listing 14.8 An applicationwide available Locale setting in the web.xml file.



<context-param>



<param-name>locale</param-name> <param-value>en_US</param-value> C </context-param>


О Defines the name of the Context parameter. e Defines the value of the Context parameter.


In the listing we define the name of the Context parameter to be locale, which is the parameter name that the <currency> tag will look for. We set the value of the parameter to be a string representing the locale, which the tag will then use to construct a Locale. As the dollar sign is used to define a variable in WML, we must be sure that we will not run into problems when displaying prices such as $100 (which could be interpreted as referencing the variable defined with a name of 100). In
Listing 14.7 and other listings where we use the <currency> tag, we display all prices inside the CDATA block, which tells the client that the information inside is character data and should not be parsed.

Скачать в pdf «JSP Tag Libraries»