Operating events and message events in portlet

zhaozj2021-02-16  69

There are three types of events in the Portlet API:

Operating event: The portlet container is generated when an HTTP request is generated, and a behavior is usually closed, such as the user tap a link. Message Event: A portlet generates a form event when sending a message to another, generating a message: generates when the user changes the portlet form

In the example below, we will use the operating events and message events.

1.1 Operational event

When the portlet container receives an HTTP request to associate portletAction, an operational event will be sent to the corresponding PORLET. Operating events are typically associated with HTTP links or buttons in the HTML form, enabling developers to achieve different operations for different selection of users. The portlet event can carry any information, which is part of the operating event and will be transferred to the operation listener.

PortletAction objects must be implemented, which will be linked to the URL and passed via ActionEvent. The Portlet API also offers a defaultletAction object with default parameters. You can use a DEFAULTPORTLETACTION, or implement your own portletAction. The URI involving portletAction can be created by the Portleturi class and its addAction () method.

If the portlet wishes to receive an operational event, the portlet class must implement an ActionListener interface.

1.2 message event

If multiple Porlet is a member of the same PORLET app, and within the same page, the message event can be sent from a portlet to another portlet. In addition, DEFAULTPORTLETMESSAGE can span other portlets of the same page across portlet applications. When a portlet change will affect the other, the message event will be very useful.

The portletMessage type object must be implemented, it will be sent via MessageEvent. MessageEvent will be sent by the PORLET container when a portlet sends a message to another.

If you want to receive a message event, you must implement the MessageListener interface in the portlet class that receives the message.

转载请注明原文地址:https://www.9cbs.com/read-16962.html

New Post(0)