In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Treasure chest: Portlet development used in almost all projects
"commonly used Portlet" refers to several Portlet that almost every customer has required to develop in more than 50 enterprise portal implementations that I have done. Some of these Portlet are public information, some are toolkits, some are train inquiries, and some are weather forecasts. In short, they are some of the small functions most commonly used by users in their daily office life. They themselves involve a small amount of development, but rely on some of the skills of Portal development.
Readers have mastered the development of these Portlet, one is to try and practice for the study of this chapter, and the other is that you can use these Portlet directly when you take over a Portal project. According to my experience, these Portlet are liked and needed by mass customers, so the title of this section is also called "Treasure chest".
1.1 Portlet1.1.1 essentials related to the development of public information
Portal system is a website that displays public information without users logging in. The only difference is that the content of this website is in the form of components. In technical terms, the entire Portal site is made up of countless Portlet, and each Portlet is an aspect of content. In real development, since we have digitized our public information, we just need to extract it from the database. Here are some examples that are often encountered in the development of enterprise portal systems.
This is an example of an IT application, as shown in figure 1-1.
Figure 1-1 Development of commonly used Portelt (1)
These are several small examples of "× ×", as shown in figure 1-2.
Figure 1-2 Development of commonly used Portelt (2)
There are usually two ways to extract this public information.
-write Portlet and read the background database directly in the data part of Portlet. This is relatively independent and consistent in style, but it will incur huge system overhead, so it is not recommended.
-write a page that reads public information, which can be run on specific application servers, such as WebSphere, WebLogic, Tomcat, etc. All we have to do is write a Portlet and embed an Iframe in the Portlet to display the page.
This section mainly discusses the development method of common information Portlet for the second method. This section is introduced step by step according to the development steps, and there is no primary or secondary distinction.
1.1.2 Development steps
1. Create a properties file for the address list
The content of JspURL.properties is structured data and is used to store the URL of each news page. For example:
2. Read the properties file in the Portlet data layer
GetUrl is used to read the URL where each news page is located from the JspURL.properties properties file. The general content of this class is as follows:
We embed an Iframe in the View page and specify that its URL property is the address read from this class.
OK, even if the development of the public information Portlet is complete, we will package it and publish it to the Portal portal system, complete the permission assignment, and then we can customize and display it on your portal site.
1.2 develop a toolkit Portlet
Public gadgets such as train query and weather forecast are popular widgets in the current portal. Here we briefly introduce their development methods by placing three small icons on the Portlet page and entering the train number query, flight information and calculator respectively when clicked.
To develop this Portlet, follow these steps.
1.2.1 use tables to introduce pictures
1.2.2 draw hotspots on the picture as links
1.2.3 event handling for links
For example, we can do the following for "weather forecast".
Through the weather forecast Portlet, you can see the weather conditions of the day in the cities where the company's units are located and in several major cities across the country, as shown in figure 1-3.
Figure 1-3 Portlet for developing weather forecasts
Click the button on the right to enter the editing page, as shown in figure 1-3a, this Portlet allows each user to set the forecast location.
Figure 1-3a Weather Forecast Portlet allows each user to set a forecast location
OK, the View part of the Portlet, is done. As for the Model and Controller parts, you can add handling methods for these events to read the actual data. For example, the weather forecast information is read from the specified URL, stored in an object, written to Session, and then displayed in View.
1.3 Portlet1.3.1 development essentials for developing personal schedules
When anonymous users open the Portal page, they see a calendar. After Portal users log in, there is an extra "add schedule / schedule Management" button, where users can add and manage their own schedules.
1.3.2 Database design
The personal schedule management field is relatively simple, the data concurrent processing is very few, and the requirement to the database is not high, so we choose Access. The specific field settings will not be described in detail.
1.3.3 Business process design
Portlet first attempts to get the user id. If the id is empty, the user is not logged in, and a calendar is displayed; if the id is not empty, the personal calendar is displayed. Portlet retrieves the calendar entry for the user id from the database and turns the date with the schedule red, which pops up when the user clicks on that date. On the schedule entry, the user can edit his own schedule; when the user adds the schedule, the user id obtained by Portal is used as the primary key to join the database.
The specific business process is as follows.
You can learn about the current date and schedule through the Portlet of your personal schedule, as shown in figure 1-4.
Figure 1-4 Portlet of personal schedule allows each person to define their own memo
You can see the corresponding date by adjusting the year and month. If there is a schedule activity on that date, a different color will be displayed, and you can click on the date to see the schedule, as shown in figure 1-5.
Click New schedule, and the interface shown in figure 1-6 will appear, and you can add your own personal schedule.
Figure 1-5 dates with message reminders will be displayed in different colors on the personal calendar
Figure 1-6 allows you to add your own personal schedule
Users can add schedules, including schedule title, start / end time, reminder settings, schedule content, and so on.
The start / end time can be accurate to minutes. " The "cyclic reminder" in the reminder setting is used to set whether the information is displayed in a cycle of day or week, month, year, etc.; the "pop-up reminder x minutes before the start time" is based on the settings of the user. How long before the start of the schedule to remind the user; "SMS reminder" is to remind the user by SMS (this function is temporarily unavailable because the SMS platform has not yet been built). When the settings are complete and saved, the scheduled date will turn light blue and will be displayed in Today's reminder.
There are three ways to remind the schedule: one is to display in a list; the second is to scroll the reminder in the Today reminder module on the my work page; and the third is a pop-up window reminder, which pops up in the "my work" page at the time set by the "x minutes before start" (server time).
1.3.4 Code implementation
1. Display the page
Only the more important parts are shown here.
2. Show schedule entries
When the user clicks on a date with a schedule prompt, the schedule pops up.
Specific coding, I use the display format as follows.
3. Increase the schedule
Click add schedule to add a schedule for logged-in users.
4. Modify the schedule
On the schedule entry that appears, click Edit schedule to modify this schedule entry.
1.3.5 Interface beautification
In order to make the schedule display interface clear and beautiful, it needs to be further beautified, and the process of beautification will no longer be introduced in this book.
1.4 develop a tool for converting Excel files to txt Portlet
The purpose of this tool Portlet is that most of the time, some data of the application system is stored in the Excel table, and we need to export the data, such as user and user group information.
1.4.1 instructions for use
(1) this tool uses the jxl.jar package, so please add this package to the Porltet class library first. Of course, you can also debug directly in Tomcat, so the target container is Tomcat, then you need to manually copy this file to the class library folder of Tomcat.
(2) copy the main file reansfer.jsp to the container directory, visit the page directly in the browser, and the program will be executed.
(3) by default, the source file * .xls needs to be copied to C:\, and the generated file name is: qas_1.txt.
(4) if you need batch conversion, or if you need to select your own files or folders, please modify the code yourself.
1.4.2 detailed code explanation
To develop this Portlet, you first need to download an Excel-to-txt control from the Internet, and then create a new Portlet to control the logic in the Portlet display layer (PortletView.jsp file).
The following is part of the source code of the file, for reference only.
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.