In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to analyze Seam Remoting API and Ajax4jsf. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
Most Java developers are bullish on mashup these days, so you may wonder how Seam can be integrated with technologies known as Web 2.0, especially Ajax. It would be cool if you could use Seam to start some page updates in JSF or use Google Map to assist with the JSF application mashup, wouldn't it? Not only can you do this, but it's also very easy.
I'll show you how to use Seam Remoting API and Ajax4jsf components to facilitate Ajax-style interactions in JSF-based applications. As you will see, the greatest benefit of combining Seam and Ajax is that it allows you to enjoy all the luxuries of Web 2.0 without having to suffer the pain of using JavaScript XMLHttpRequest objects. With Seam Remoting and Ajax4jsf, you can communicate with the managed bean on the server as if the bean were local to the browser. The browser and server states remain synchronized and never have to deal with the low-level API that facilitates communication between them.
I'll start by showing you how Seam promotes a new component-based approach to Ajax programming. You will learn how to use Seam Remoting API to communicate between JavaScript and server-side objects through Ajax. Once you understand this new (and simple) approach to Ajax, you can use it to enhance your Open 18 application as follows:
◆ creates a mashup between the Open 18 course directory and the Google Maps.
◆ uses Ajax4jsf to merge the course catalog page and the course details page of the application.
◆ revisits the application's Spring integration and makes Spring bean available during the Seam Remoting lifecycle.
The mashup between Open 18 and Google Maps allows the user to locate the location in the golf course directory on the map. Combining this course catalog with the course details page (and Ajax the low-level code) allows you to display the details of the course without having to load a new page. The integration of Spring bean and Seam Remoting allows you to capture the relocation of Google Maps location markers and store the longitude and latitude of the relevant courses in a database. As you can see, the result is an impressive Web 2.0-style application that all golfers like to use!
If you've ever suffered from overly complex Ajax programming involving a lot of JavaScript, and if, so far, you've avoided using Ajax because you don't want to face its complexity, then what this article teaches will help you avoid that worry. You need to do some JavaScript coding when refactoring your application, but unlike most Ajax implementations, JavaScript does not take up most of your code; instead, it extends only server-side Java objects.
Different paths to Ajax
Just as you want to avoid explicit memory management in your application, you don't want to have to deal with low-level Ajax request protocols. Doing so will only lead to more trouble (or rather, more trouble), such as multi-browser support, data marshaling, concurrency conflicts, server load, and custom servlet and servlet filters. The hassle you want to avoid is the inadvertently exposed stateless request-response paradigm, but this paradigm is based on what component frameworks, such as JSF, want to hide.
The JSF lifecycle promotes component-oriented design by shielding application code from the underlying servlet model. To maintain this abstraction in dealing with Ajax, you can leave these trivial tasks at the lower level to Seam Remoting or Ajax4jsf. Both libraries are responsible for the pipeline processing required to fuse JSF components into browsers through Ajax interactions. Figure 1 shows the Seam Remoting in practice. When an event is triggered, such as when the user clicks a button, the message is sent asynchronously to the component on the server. Once a response is received, it is used to make incremental updates to the page. The low-level communication protocols used to handle the interaction between browsers and server-side components are hidden behind API.
Figure 1. Seam Remoting Fusion JSF components and browsers
In the use case shown in figure 1, the user can see the result of the method call that occurs after the button is clicked. When studying this use case, there are two key points to note:
◆ this page can never be refreshed
The ◆ client code communicates transparently with the methods on the component, rather than explicitly building and then requesting URL. Standard HTTP requests are used in the background, but client code never needs to interact directly with the HTTP protocol.
Seam Remoting and Ajax4jsf
Seam Remoting and Ajax4jsf are two unique libraries that serve the "Ajax" purpose of JSF, respectively. Both libraries use Ajax to introduce an interaction model, where communication between the browser and the server can occur asynchronously in the background and is not visible to the user. There is no need to waste time reloading user pages in order to execute methods on the server. The information retrieved by the server in the Ajax requests made by these libraries can be used to incrementally update the status of the page in "real time". Both libraries can be equipped with a lifecycle that restores the state of the component when the browser needs it. This Ajax interaction is not a real request but a "restore and execute". The browser is like "tapping" on the shoulder of the server, asking it to execute a method on a managed bean on the server side and return the result.
Although the two libraries work differently, they are not mutually exclusive. Because they both use the JSF component model, the two can be easily combined with each other, which will be described in more detail later in this article. For now, we only need to consider the ways in which each of them introduces Ajax-style interactions into JSF applications:
Seam Remoting provides JavaScript API that can be used to access server-side components in JavaScript as if they were local objects, so that data can be sent and retrieved through method calls. Seam Remoting uses a customized, non-JSF life cycle to enable the browser to communicate with server-side components. Only the Seam container and its components can be restored during these requests. The transparent protocol is Ajax, but you don't have to worry about the details of how the packet is transmitted.
Ajax4jsf takes abstraction a step further by completely hiding the use of JavaScript. It wraps all the logic in the basic UI component. Ajax4jsf accepts Ajax requests through the full JSF life cycle. As a result, components that support Ajax can execute action handlers, upgrade the JSF component tree, and rerender parts of the page without triggering browser navigation events. Similarly, communication is done through Ajax, but all of this takes place in the background and is not visible to the page developer. Ajax4jsf's component-oriented approach makes Ajax functionality a natural part of JSF rather than an out-of-place outsider.
On how to analyze Seam Remoting API and Ajax4jsf to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.