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

What are the new features of Tapestry5

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces the relevant knowledge of "what are the new features of Tapestry5". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

List of new features for Tapestry5:

New features of Tapestry5 1. Component classes no longer need to inherit base classes

Tapestry5 component classes can be independent of the framework, do not need to inherit base classes, do not need to be defined as abstract, and the life cycle is fully implemented using annotations.

Package org.example.myapp.components; import org.apache.tapestry.MarkupWriter; import org.apache.tapestry.annotations.ComponentClass; import org.apache.tapestry.annotations.BeginRender; @ ComponentClass public class HelloWorld {@ BeginRender void renderMessage (MarkupWriter writer) {writer.write ("Bonjour from HelloWorld component.");}}

@ ComponentClass is equivalent to tagging extends BasePage

@ BeginRender is equivalent to implements PageBeginRenderListener

Tapestry5 new features 2, component classes are no longer abstract classes, but pure simple POJO (plain old Java objects)

The configuration is also implemented entirely in annotations, including the IOC container, that is, the IOC container configured based on annotations, instead of hivemind. Module and service define classes:

Package org.example.myapp.services; import org.apache.tapestry.ioc.annotations.Id; @ Id ("myapp") public class MyAppModule {public static Indexer buildIndexer () {return new IndexerImpl ();}}

Classes that need to be injected:

@ Inject ("service:myapp.Indexer") private Indexer indexer

That is, the buildIndexer method is fixed and the format is build {serviceId}. Of course, there is also the shadow of hivemind, such as multi-module and contribute and so on.

Tapestry5 new features 3, no longer use XML configuration files and component definition files (.page, .jwc), all configuration information using comments (annotations).

Page and component configuration files can be fully implemented using comments, this feature can already be used in Tapestry4, nothing new, but completely configured in comments, looking at the code a little messy, write too much will begin to wonder if this is still a Java class.

Example:

Package org.example.app.pages; import org.apache.tapestry.annotations.Component; import org.apache.tapestry.annotations.ComponentClass; import org.example.app.components.Count; @ ComponentClass public class Countdown {@ Component (parameters = {"start=5", "end=1", "value=countValue") private Count _ count; private int _ countValue; public int getCountValue () {return _ countValue } public void setCountValue (int countValue) {_ countValue = countValue;}}

Tapestry5's new features 4, any changes to component classes and templates can be reflected immediately without any reboot.

Tapestry 5 automatically reloads changed classes and templates, which should be a feature of the scripting language, but from the description it seems that only component classes have this feature, and other classes may need to be restarted. However, this is a great progress, using java to achieve the dynamic loading function of the scripting language. Now, with more and more research on classloader, the use of Java is more and more in-depth.

New features of Tapestry5 5. Blazing is faster than Tapestry4.

With regard to performance, there is no cost of parsing configuration files, and it is estimated that the problem of slow initialization in Tapestry4 should be solved. If it is faster than pure servlet and jsp, it is thanks to the use of cache.

Generally speaking, Tapestry5 is still worth looking forward to, it is still in the development stage, many features are not finalized, if there is a better concept, it is estimated that HLS will be added (PS: really convinced him, Tapestry4.1 added the function of Ajax, is about to study, but launched this T5, which tickles my heart, but I haven't been excited to see the new features for a long time). Many new concepts are worth using for reference, including the annotation-based IOC container, and now spring has also introduced the spring-annotation package; annotation-based page display life cycle definition, @ SetupRender, @ BeginRender, @ BeforeRenderBody, etc., so that the whole class is intrusive except annotations, and removing annotations is a simple java class that does not need inheritance or implementation of fixed methods. And Tapestry5's life cycle is based on state machines and queue algorithms, rather than tail recursion, so cycles can be finely defined and easy to implement.

That's all for "what are the new features of Tapestry5"? thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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