Develop portlet guidelines

xiaoxiao2021-03-06  78

This section contains the following topics:

Model View Controller (MVC) Design Mode Portlet Creating Guideline Tag Guide Using Portlet API Tags

Model View Controller (MVC) Design Mode

Portlets must be able to support multiple Internet browsers that are displayed to run on many communication devices. These browsers typically require different display markers. The smaller device's display screen is smaller, usually the display mark has more restrictions.

By implementing the Model View Controller (MVC) design mode, Portlets support multiple browsers and device types. This design contains three entities:

Model, the model data of the data source portlet to be retrieved for portlet is typically retrieved from the external data source and is formatted with the XML document when it is loaded with the Java display bean. View, used to display the output mechanism of portlet data. The display view is usually implemented as a JSP or XSLT style sheet. When using the Java Bean to implement the data model, the previous use of the data is used, and the latter is used when the format of the data is an XML document. Controller, which connects the selected view to the data and guides the operation of the portlet. The controller selects the view you want to display according to the target device or browser, and then pass the data model to the view. The view extracts specific display data to format the data for the browser, and then supplies it to the browser as part of the portal to the portal output.

For portlet development, the MVC mode has the following characteristics:

Depending on the mark supported by the client, the portlet is only responsible for calling the correct controller. The connector is responsible for accessing the content source. Typically, each content source type corresponds to a connector, for example, a connector for POP3 access, a file-based cache. The model represents the content retrieved by the connector. The model is independent of. The controller is responsible for providing appropriate tags (HTML, CHTML or WML) for content.

In the MVC structure, there is a significant separation between the data and representations, which uses a controller component to manage data (model) and the interaction between (or view). The controller understands the environment where the application is called, collects the information to be displayed from the data object, and then uses the appropriate view to apply the appropriate view for the markup language for the current device.

Portlet creation criterion

Portlet API is designed to give you the greatest flexibility to develop portlet developers to develop portlets. By applying some guidelines, you can maximize the performance of the portlet. If you develop servlet using the Servlet API, you will find that some guidelines are very similar to the criteria for creating portlets.

Examples and class variables

The most important rule is to limit the use of instances or class variables in portlets. In WebSphere Portal, only a single instance of the portlet class is exemplified. Even if different users use the same portlet on their pages, or by the same portlet object instance to generate tags. Therefore, each portlet instance will be treated as a single body. This implies that there should be no status or other information between portlet calls using an example or class variable. As a monomer, each instance variable of the portlet effectively has class variables with similar scopes, and problems may occur when accessing variables multiple times in each user's portlet context. It is best to avoid these problems by limiting the use of examples or class variables to read-only values. Otherwise, you can only sacrifice re-enter or thread security.

One exception to this rule is that you can use instance variables. Values ​​do not change variables are safely stored in instance variables. For example, when you initialize the portlet, you can set it in the portlet. Because the configurations between different users or calls do not change, it can be stored in the instance variable. Visit Portal Server

WebSphere Portal is based on an open source called JetSpeed. However, WebSphere Portal contains many new features and features that are not available in JetSpeed, so it cannot guarantee binary compatibility between the two products and interfaces. Typically, you should not write the portlet or portal extension attempted to access the internal components of WebSphere Portal because these extensions or portlets may reduce the performance and operation of the portal.

Portlet efficiency and performance

WebSphere Portal generates different page tags for different users using the same portlet instance. There is a limit on the number of threads to perform these tasks. Realizing the portlet makes it possible to complete its work as soon as possible, so that the response time of the entire page can be optimized.

Optimizations that should be considered are:

Limit the method of synchronization or synchronized code blocks in the processing of the portlet method. Limit the use of complex string operations. This includes:

When possible, use the JSP of the view bean instead of XSL. When JSP is much more than Java objects, the XSL style sheet will cause many temporary Java object exemplary. Consider using StringBuffer to replace the temporary String object. In general, these are more efficient when processing strings and generally do not instantiate other temporary String objects. Determine if the log level is enabled before the message or tracking information is written before the log. See Message and Tracking Record Logs for more information. Limit the loop running for a long time. In JSP, reduce blank and use unconvertable JSP annotation format (<% -%>) instead of using HTML annotation format (). Minimize Java object exemplary.

General Tip of Portlet Output

One of the purposes of writing portlet tags is to provide consistent, clear and complete user interfaces. The Portal Server page is displayed using the appearance and topic defined by the portal administrator. The subject represents the entire appearance and feelings of the portal, including colors and fonts. The appearance represents the border presented around the single portlet. WebSphere Portal is installed with some predefined appearances and topics.

To integrate portlets with organization's portals or custom portals, they should generate tags of class-like style classes that call portlets, rather than using tags or properties to specify color, fonts, or other visual elements. To get more information about these style classes, see customizing your appearance and feelings.

Portlets are only allowed to provide taggers, and then these clips are assembled into a complete page by the Portlet Framework. For example, portlets are provided on the portal page on the HTML table unit (). Therefore, ensuring that all page level tags, such as , , , , , <meta>, <base>, and <WML>. For tags, it is recommended to use a verification tool such as a tool in the W3C HTML to verify service or tag editor, such as WebSphere Studio. See Tag Guide for specific information about HTML, WML, and ChTML taggers.</p> <p>The resource URI should be the namespace encoded, which allows the portal to provide the direct path of resources related to the protected, unprotected and specific locales. You should also encode named elements (form fields, JavaScript variables, etc.) to avoid portlet conflicts with elements or other pages on other portals. See Portleturi to get regular information about encoding, and see an example of how to use JSP to generate markers to get the name of how to encode the input field in the JSP. As long as it is possible, provide support for a type of tag (HTML, WML, and ChTML). This means that from the Client object to the tag test, you need to use the getMarkupname () method. You must also indicate that the tag type supported by the portlet is indicated in the portlet deployment descriptor.</p> <p>To prepare to convert the portlet, ensure that all strings are retrieved from the feature file using portletContext () method, instead of hard coding in portlet. Allows a string extension in a portlet user interface in some languages.</p> <p>Consider how the portlet is accessed by the disabled person when you write a portlet. For example, persons defective people may not distinguish some colors, or require auxiliary assistance to access portlet. More information on accessibility guidelines can be found from the Application Special Technology Center (CAST) or W3C Web Accessibility Initiator. IBM provides web accessibility guidelines in http://www-3.ibm.com/able/accessWeb.html.</p> <p>Mark guide</p> <p>This section provides information on the use of HTML, WML, and CHTML taggers. Because HTML, WML, and CHTML code segments are embedded in other code segments, make sure they are complete, not including open tags, and only valid HTML, WML, or Chtml. For example, this helps prevent portlets from closing the HTML code aggregated. To get other information, please refer to the general prompt of the portal output.</p> <p>Rendering HTML (Chtml)</p> <p>Use standard Chtml. To get information about HTML compatible with I-MODE, see http://www.nttdocomo.com/i/tagindex.html. It is assumed that it can be displayed separately when designing the portlet, or can be displayed with other portlets. Closely pay attention to the undetected and excess markers; page behavior with marks that have not been terminated correctly cannot be determined. Use only elements that can be included to the body; do not use <head> or <body> tag. To get a list of tags that should be avoided, see General prompts for taggers. Avoid lengthy, complex chtml, because portlets may share the page with other objects. Avoid excessively use images, do not use alignment and positioning parameters to images. Do not use a string of more than 24 symbols for the phone number used as reference to the <A>. Do not use more than 200 words for a URL.</p> <p>HTML</p> <p>Use standard HTML. For the official HTML specification, see http://www.w3.org. Closely pay attention to the undetected and excess markers; page behavior with marks that have not been terminated correctly cannot be determined. Use only elements that are correctly output in the HTML table unit. For example, the frame will not appear when the table is inserted. Do not use nesting tables because they reduce the performance on the Netscape browser. Avoid lengthy, complex HTML. Portlets share the page with other portlets, the more the contents generated by each portlet, the more you need to do before you display content. Use Portal Server style sheet. If the font and color are hard, the portlet may be disaggregated when the user changes page style settings. For information on using CSS in the portal, see Changing the appearance and feelings. Format the text using the CSS API. This ensures that the style sheet is modified even in the future, the portlet works fine. Avoid using CSS for absolute positioning, as this cannot be ensured that the portlet is displayed at a specific location. Keep the portlet content is simple. Don't try to get and display the content of the full screen through a small portlet. Do not create a fixed width of the HTML table in the portlet, as this is not possible to determine the width of the column of the portlet. Avoid long unbained text; the result is similar to the case where a fixed width is used. Check the behavior of the page size portlet to make sure the portlet can use a different browser size. Check that the behavior of the portlet when changing the default browser font; portlet should seamlessly process these situations. Don't draw the portlet banner, such as the title bar, because the portal gathering will provide them. Make sure that any JavaScript provided by the portlet does not interfere with the portal page, the features of other portlets on the browser window, or page. Also, use the <portletAPI: EncodeNamespace value = "function" /> to prevent JavaScript functions and other portlet conflicts with the portal page in JSP generating JavaScript's JSP. To get more information, see Using the Portlet API tag to get more information. WML</p> <p>Use standard WML. To get information, see http://www.wapforum.org. When designing the portlet, it is assumed that it can be displayed separately, or can be displayed with other portlets. Closely pay attention to the undetected and excess markers; page behavior with marks that have not been terminated correctly cannot be determined. Use only elements that can be included in cards (possibly plus portlets and elements), and do not create a separate card. Do not set the card title. Do not use templates. Avoid using lengthy, complex WML, because the buffer length may be limited by the user agent, and the portlet may share the page with other portlets. Avoid using images too much. When using an image, it is necessary to define meaningful ALT names because it is necessary for an apparatus that does not support image or when an image cannot be taken. If possible, define the LocalSRC. Do not use intrinsic events because these events such as OneventForward and OneventBackWard are added only by the aggregation level. Avoid using timers. Use the user triggered events only when needed, and always define the label and name parameters. Use the unique identity of the portlet as a name prefix, otherwise a conflict may be generated between the different portlets on a page. Use a meaningful name for the label. Do not create a fixed width WML table or image in the portlet. Avoid using long, non-surrounded text, which helps prevent unwanted scrolls. Use portlet API tag</p> <p>This section describes the flag identified by the portlet container. Portlet container provides tags used in portlet jsp. To make these tags available for JSP, the following pseudo instructions must be required at the beginning of JSP:</p> <p><% @ Taglib Uri = "/ Web-INF / TLD / Portlet.tld" prefix = "portletApi"%></p> <p><portletAPI: IF</p> <p>Attribute = "</p> <p>Value></p> <p>Several conditions can be checked by the attributes of this tag. If the condition is true, the tag is written to the page. Otherwise, skip this content. Multiple conditions can be evaluated. For written tag content, all conditions must be evaluated as true. In addition, each parameter may contain a plurality of values ​​separated by a comma or semicolon. For conditions for evaluating True, only one value in the list needs TRUE.</p> <p>At least one of the following properties:</p> <p>Mode = [portlet.mode]</p> <p>Assess the current way of portlet. For example, if the user places the portlet in editing, mode = "edit" is TRUE.</p> <p>PreviousMode = [portlet.mode]</p> <p>Assess the former way of the portlet. For example, after transferring the portlet to the edit method, previomMode = "View" is true.</p> <p>State = [portletWindow.State]</p> <p>Assess the status of the portlet. For example, after the user clicks the minimum icon of the portlet, state = "minimized" is true.</p> <p>Markup = [String]</p> <p>Evaluate the markup language supported by the client. For example, if the client supports WML, Markup = "WML" is TRUE.</p> <p>MimeType = [string]</p> <p>Evaluate the MIME type supported by the client. For example, if the client supports html, mimeType = "test / html" is true. Capability = [Capability]</p> <p>Assess the ability of the client. For example, if the client supports the cascading style sheet, Capability = "HTML_CSS" is TRUE.</p> <p>In the following examples, the portlet must be a way of viewing, and the portlet status to be rendered must be normal or maximized:</p> <p><portletAPI: if mode = "view" state = "normal, maximized"></p> <p><img src = "images / results.gif"></p> <p></ portletAPI: if></p> <p><portletAPI: log text = "</p> <p>TEXT "level ="</p> <p>Level>></p> <p>Write a string in the portlet log.</p> <p>Text = [string]</p> <p>Indicates the message or trace string recorded in the portlet log. This property is required.</p> <p>Level = [Error | Warn | Info | Debug]</p> <p>Indicates the message level to record. See</p> <p>Messages and Track Record Logs for more information about writing. This parameter is optional; if the level is not specified, Error is the default.</p> <p><portletAPI: log text = "This is an error message!" /></p> <p><portletAPI: text bundle = "</p> <p>Properties_file "key ="</p> <p>String "></p> <p>Write localized strings to output streams. When the resource bundle is not found, the content between the start and end tags is written to the output stream.</p> <p>bundle = [string]</p> <p>Specify the resource bundle. This parameter is required.</p> <p>Key = [String]</p> <p>The keys found in the resource bundle. This parameter is required.</p> <p>In the following example, the value of the Welcome_Message parameter is retrieved from the portlet of the stockport.properties file.</p> <p><portletapi: text bundle = "nls.stockportlet" key = "welcome_message"></p> <p>welcome!</p> <p></ portletAPI: Text></p> <p><portletAPI: BIDI IS = "RTL | LTR"></p> <p>This tag is used to support two-way language text. The two-way language refers to reading from right to left or downward. Attributes</p> <p>IS is required.</p> <p><WPS: BIDI IS = "RTL"> Write content only when the text is two-way. <WPS: BIDI IS = "LTR"> Write the content only when the text is not bolding.</p> <p><portletAPI: DataLoop></p> <p>Through the current specific portlet instance</p> <p>All attributes in PortletData loops. Use the <DataTtribute> tag to get the properties between the Dataloop start and the end tag.</p> <p>Pattern =</p> <p>String</p> <p>Optional. Define regular expressions that should be loop which attributes.</p> <p>See DataAttribute to get an example of how to use this tag.</p> <p><portletAPI: DataTribute></p> <p>Returns one or more</p> <p>The value of the portletdata property. This attribute can be specified by the name parameter. You can also use this tag in the <DATALOOP> tag to retrieve all properties or from</p> <p>A subset of the properties of portletdata. Name =</p> <p>String</p> <p>Optional. Indicates the name of the attribute.</p> <p>The following example loops through the portletdata attribute, only the name of the name in stock.user.</p> <p>User settings for your stock portlet: <br></p> <p><portletAPI: Dataloop Pattern = "stock.user. *."></p> <p><portletAPI: DataAttribute /> <br></p> <p></ portletAPI: DataLoop></p> <p>A specific user settings for stock portlets: <br></p> <p><portletAPI: datattribute name = "stock.user.quotes-count" /> <br></p> <p><portletAPI: Settingsloop></p> <p>Currently specific portlet</p> <p>All attributes in PortletSettings loops. Use the <settingsattribute> tag to get the properties between the start and end tags.</p> <p>Pattern =</p> <p>String</p> <p>Define regular expressions that should be loop which attributes.</p> <p>See SettingsAttribute to get an example of how to use this tag.</p> <p><portletAPI: SettingsAttribute></p> <p>Returns one or more</p> <p>The value of the portletSettings property. This attribute can be specified by the name parameter. You can also use this tag in the SettingsLoop tag to retrieve all properties or from</p> <p>A subset of the properties of PortletSettings.</p> <p>Name =</p> <p>String</p> <p>Optional. Indicates the name of the attribute.</p> <p>The following example loops through the PortletSettings property, only returns a name at Stock.config.</p> <p>Configuration settings for your stock portlet: <br></p> <p><portletAPI: settingsloop pattern = "stock.config. *."></p> <p><portletAPI: SettingsAttribute /> <br></p> <p></ portletAPI: Settingsloop></p> <p>Stock portlet A specific configuration setting: <br></p> <p><portletAPI: settingsattribute name = "stock.config.hostname" /> <br></p> <p><portletAPI: Createreturnuri></p> <p>Create the URI of the caller pointing to the portlet. Can pass</p> <p>CreateReturnuri starts and end tags</p> <p>Uriparameter or uriaction to deliver parameters or operations in the URI.</p> <p>The following example creates a URI to provide a link to the user to the previous way or status of the portlet.</p> <p><a href="<portletapi: CreatereeturnuRNuRF "></p> <p><portletAPI: text bundle = "nls.my_portlet" key = "back_label"></p> <p>Previous</p> <p></ portletAPI: Text></p> <p></a></p> <p>To get an example of a parameter or an operation with this tag, see Uriparameter and Uriaction.</p> <p><Createuri></p> <p>Create a URI that points to the current portlet with a given parameter. Can be included between Createuri start and end tags</p> <p>URIPARAMETER or</p> <p>Uriaction to deliver parameters or operations in the URI.</p> <p>State = [portletWindow.State] is optional. Indicates the status of the portlet. For example, state = "maximize" creates the URI of the maximized portlet. If the state is not specified, the URI points to the current state of the portlet.</p> <p>See Uriparameter and Uriaction.</p> <p><Uriparameter></p> <p>Add parameters to</p> <p>CREATEURI and</p> <p>CreateReturnuri tagged URI.</p> <p>Name =</p> <p>String</p> <p>Required. The name of the parameter to be added.</p> <p>Value =</p> <p>String</p> <p>Required. The value of the parameters to be added.</p> <p>In the following example, parameter showquote and value IBM are added to the URI.</p> <p><portletAPI: Createuri State = "maximized"></p> <p><portletAPI: uriparameter name = "showquote" value = "ibm" /></p> <p></ portletapi: Createuri></p> <p><Uriaction></p> <p>Add a default operation</p> <p>CREATEURI and</p> <p>CreateReturnuri tagged URI. Portlets must provide an operation listener to handle events.</p> <p>Name =</p> <p>String</p> <p>Required. The name of the parameter to be added.</p> <p><portletAPI: Createuri></p> <p><portletAPI: uriaction name = "add" /></p> <p></ portletapi: Createuri></p> <p><portletAPI: EncodeNameSpace Name = "</p> <p>String "></p> <p>Map the given string value to this portlet namespace. Use this tag for a naming element (eg, a form field or JavaScript variable) in the portlet output to uniquely associate the element with this specific portlet instance and avoid other portlets on other elements or pages on the portal page. Name conflict.</p> <p>The following parameter names are not available for Portlet JSP without namespace, because they are WPS frameworks:</p> <p>The name of the underlined '_' started with the name ". '</p> <p>Name =</p> <p>String</p> <p>Required. Specifies the value of the namespace to be mapped to the portlet.</p> <p>In the following example, the text field with name 'Email' is encoded to ensure uniqueness on the portal page.</p> <p><Input Border = "0"</p> <p>TYPE = "text"</p> <p>Name = "<portletAPI: EncodeNameSpace Name = 'email' />>>></p> <p><portletAPI: init></p> <p>The following JSP can be used to access the variables of the corresponding objects of the portlet API:</p> <p>PortletRequest PortletResponse PortletConfig</p> <p>After using the init mark, the JSP calls the portletResponse's EncodeNameSpace () method.</p> <p><portletapi: init /></p> <p><% = portletResponse.EncodenameSpace ("test")%></p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-93137.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="93137" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.044</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = '5qwB4Po80BhvKrS3rszjxcgFfQDdoO0OzWWH5aR1Wjj67Y8cIQ3WOzxNg9mfRG0UAhC5E6GRczkBHSUS2KjZ9g_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>