Accessing Complex Properties with JSTL

More interesting in Example 3-17 is how the JSTL expression language (EL) is used to retrieve the collection of IDEs for the chosen language:

${languageChoices.languageldeMap[DevPollForm.map. language]}

The power of EL allows you to access normal JavaBean properties as well as mapped properties in almost any combination. To understand how the expression is evaluated, let's examine how it would be done in Java:

// get the language-ide map

Map ideMap = languageChoices.getLanguageldeMap( ); // get the selected language from the form bean DynaActionFrom form =

(DynaActionForm) session.getAttribute("DevPollForm"); String language = form.getMap( ).get("language"); // get the list of IDEs from the language-ide map List ides = (List) map.get(language);

DynaActionForms expose their internal table of name/value pairs via themap property. This allows you to retrieve the chosen language from the DevPollForm dynamic form bean.

The html:radio tag is used just as it was on the first page shown irExample 3-15. Though c:forEach is used instead of logic:iterate, you can use the idName attribute of the radio tag. When using JSTL in this way, theidName should be the same as the value for the/ar attribute of the JSTL c:forEach tag.

0 0

Post a comment

  • Receive news updates via email from this site