Apache Tapestry Built-In Components - Apache Tapestry

How many built-in components are there in Apache tapestry?

This chapter gives detailed explanation about the built-in components in Tapestry. Tapestry supports more than 65 built-in components and custom components can also be created. Some of the important components are mentioned below.

What is If Component in Apache Tapestry?

if component is used for rendering a block conditionally and the condition is checked by a test parameter.

Create a page IfSample.java as shown below

After creating a page, create a corresponding template file as shown below

Result as shown below will be rendered after requesting a page.

Result − http://localhost:8080/MyFirstApplication/ifsample

component

What is Unless and Delegate Component in Apache Tapestry?

Unless component different from if component. Delegate component does not render anything on its own, but it usually delegates markup to block element, unless if components can use delegate and block to conditionally swap the dynamic content.

Create a page Unless.java as follows.

Create a corresponding template file as shown below

Result as shown below will be rendered after requesting a page.

Result − http://localhost:8080/MyFirstApplication/unless

component

What is Loop Component in Apache Tapestry?

Loop component is the basic component to loop over a collection items and render the body for every value / iteration.

Create a Loop page as shown below

Loop.java

After that create corresponding template Loop.tml as shown below

Loop.tml

Loop component has below two parameters

  • source − Collection source. 1…5 is a property expansion used for creating an array within a specified range.
  • var − Render variable used to render current value in the body of the template.

Result as shown below will be rendered after requesting a page.

loop component

What is PageLink Component in Apache Tapestry?

PageLink component is used for linking a page from one page to another page. Create a PageLink test page called PageLink.java as shown below

After that create a corresponding template file as shown below

PageLink.tml

PageLink component has a page parameter which should refer the target tapestry page.

Result − http://localhost:8080/myFirstApplication/pagelink

page component

What is EventLink Component in Apache Tapestry?

EventLink component sends the event name along with the corresponding parameter through the URL. Create an EventsLink page class as shown below.

EventsLink.java

After that create a corresponding “EventsLink” template file as shown below

What is EventsLink.tml in Apache Tapestry?

EventLink has the below two parameters

  • Event − name of the event will be triggered in the EventLink component and by default, points to the id of the component.
  • Context − It is an optional parameter and defines the context for the link.

Result − http://localhost:8080/myFirstApplication/EventsLink

event link

After clicking on the count value, page will display the event name in the URL as shown in below screenshot.

event link

What is ActionLink Component in Apache Tapestry?

ActionLink component is similar to EventLink component, but the only difference is that it sends the target component id. Its default event name is action.

Create a page “ActivationLinks.java” as shown below

ActivationLinks.java

Now, create a corresponding template file as shown below

ActivationLinks.tml

By clicking on the ActionLink component, OnActionFromSub method will be called.

Result − http://localhost:8080/myFirstApplication/ActivationsLink

action link

What is Alert Component in Apache Tapestry?

A warning message is given to the users by using an alert dialog box. For example, if no input is given by the users for mandatory text, then an alert box can be used to give a warning message.

Create a page “Alerts” as shown below.

Alerts.java

After that create a corresponding template file as shown below

Alerts.tml

Alert has 3 severity levels:

  • Info
  • Warn
  • Error

Above template can be created by using an info alert defined as alert-info. Other severities can be created depending on the requirement.

Output

http://localhost:8080/myFirstApplication/Alerts

alerts

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Apache Tapestry Topics