Introduction:
The project team asked me if A Portlet has multiple modes, for example, a previously developed portlet has both the view mode and the config mode), and the front-end uses the extjs mvc Architecture, and the main file is main. js, the main. js is defined in liferay-portlet.xml with the following <footer-portlet-javascript>:
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/11140J4b-0.png "title =" 31.png" alt = "091752436.png"/>
So it is impossible to load main. js twice for view. jspview mode and config. jsp (config mode page file) instead of sharing the same main. js?
Analysis:
I studied it carefully and found that this was impossible. The following are my reasons and my thoughts.
First, for loading js files we define in this way in the iferay-portlet.xml, it will eventually be read and processed by 1,549th-1551 lines of PortletLocalServiceImpl of the Liferay framework.
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/11140H620-1.png "title =" 32.png" alt = "093259799.png"/>
In other words, all of our <footer-portlet-javascript> configurations will be read by the framework and added to the footerPortletJavaScriptList list.
How can these list js files be used? After reading the Liferay source code, we found it in the bottom_portlet_resources_js.jspf file. For details, see row 33rd:
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/11140G2T-2.png "title =" 33.png" alt = "093422257.png"/>
It can be found that it will read the footerPortletJavaScriptList just now, resolve all the resource file paths to absolute paths, and then introduce them in <script src> mode.
Bottom_portlet_resource_js.jspf will be introduced by bottom. jsp:
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/11140G947-3.png "title =" 34.png" alt = "0935202.16.png"/>
Bottom. jsp will be saved to a vm variable named $ bottom_include in line 364 of init. vm:
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/11140M314-4.png "title =" 35.png" alt = "093603252.png"/>
$ Bottom_include will be introduced in line 65 of portal_normal.vm in our theme:
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/11140G0T-5.png "title =" 36.png" alt = "093639932.png"/>
Summary:
Because theme is always used, no matter which one we use the default or custom, such as platform_theme in this example, it will certainly contain portal_normal.vm, which will contain bottom. and then include bottom_portlet_resources_js.jspf.
The jspf page frame contains all js resource files in the form of footer-portlet-javascript. Because portal_normal.vm is of the project framework level, it will only be parsed once, and all the pages are in this framework.
This is why js resources are loaded only once, and both iframe and extra pop-up pages are in this framework, so these js files are read, and it is the same js file.
In this sense, let us introduce js files separately, and they are all main. js files, and all given in footer-portlet-javascript are not feasible unless this js file is not defined in the <footer-portlet-javascript> element of the liferay-portlet.xml.
This article from "parallel line cohesion" blog, please be sure to keep this source http://supercharles888.blog.51cto.com/609344/1302437