Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to mix JSF tags with JSTL tags

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you the "mixed use of JSF tags and JSTL tags", the content is easy to understand, clear, hope to help you solve your doubts, the following let Xiaobian lead you to study and learn how to mix JSF tags and JSTL tags "this article.

All the JSF custom tag libraries I've talked about are good, but what if I have my own custom tag or a third-party tag library? Or should I use the JSP Standard tag Library (JSTL)? It is a set of tag libraries that can do everything we just mentioned. To a great extent, these tags can be mixed with JSF tags. Faces tags can be nested within other tags, and vice versa. Some products, such as IBM's WebSphere Application Developer, encourage this approach. Others, such as Sun's Java Creator Studio, choose pure JSF tags, on the other hand, Oracle's JDeveloper allows you to mix and use them together, but also encourages the use of pure JSF tags.

Note: whenever you nest a JSF tag within a non-JSF custom tag, you must assign a component identifier to the JSF tag. Because JSTL is standard and many people are familiar with it, we will use it to demonstrate how to use it with JSF custom tags. If you want a comprehensive understanding of JSTL, please read a wonderful book written by Shawn Bayern, JSTL in Action. Let's start with a simple example of mixing and using JSTL tags and JSF tags. The code introduces two JSF tag libraries and a core JSTL tag library.

Mixed use of JSTL tags and JSF tags

Code content

JSF in Action: JSTL Example 1-Mixing JSF with other custom tags

In this example, the JSTL and JSF tags are nested within the JSF tag, defining the beginning of the JSF component tree. This example uses JSF's h tag () and JSTL tag to display text. On this page, the JSTL tag contains the system's web.xml file (this is not the right way to share files with others, so don't do this on a real server). Because web.xml is a XML file, the tag is nested inside, it is a JSF UIOutput component, and the XML element is escaped when drawn, so it will display correctly in the HTML page. This example doesn't have much content, but it demonstrates that different tags can be used together on the same page. Notice that we nest the JSTL tag within the JSF tag, which is generally easier than nesting the JSF tag within the content of other tags. In fact, any component with subcomponents, such as HtmlDataTable and HtmlPanelGrid, needs to nest the template text within a tag. The use of JSTL tags in conjunction with JSF tags makes JSF more powerful, both of which use a similar expression language. (the same is true for JSP 2.0 expressions). This allows you to share data between JSTL and JSF tags in an intuitive way. As an example of this, let's look at another example that allows the user to enter a value in the HtmlInputText control and then use that value to repeatedly output a string using the JSTL tag.

JSF, JSTL tags, and the same backing bean

Code content

Queen Tracey will achieve world domination.

...

...

The above is all the content of the article "how to mix JSF tags with JSTL tags". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report