Referencing asset polices using Alternate approach instead if “mobilePortletContent” TagAdded by Sathish Maiya on January 5, 2014 | Version 1
|Instead of using mobilePortletContent you can reference images/scripts(asset policies) using alternate approaches.
In MPA 8.0
use of tag to reference the images outside the portlet is deprecated. Instead of using this tag follow the following steps to reference image/assets. There are two approaches to reference the assets.
A) Reference image through a static project .
Create a new definition of the project in mcs-config.xml file. The file is present at two locations \installedApps\hostname\mcs.ear\mcs.war\WEB-INF\mcs-config.xml and \PortalServer\wp.mobile\wp.mobile.mcs\mcs-config.xml . You should add the details like below in both copies of mcs-config.xml file .Please note the attributes identity (project), directory (xml-policies), base-url(assets) and prefix-url(In child element of assets) in the above example.
Put all the policy files like .mimg, scripts etc in directory "xml-policies" used in project definition .In the following example all polices are placed in below directory.
Place different policy files in different sub folders. See the snap below.
Put all the assets in the directory which is accessible via base-url provided in tag. Eg: image "magnifying-glass.png” should become available if you hit this url http://host:port/mcs/projects/examples/assets/images/magnifying-glass.png.
For this purpose you can create a directory inside mcs.ear/mcs.war/projects folder and put assets under that directory.
See in this example the assets are placed in below directory.
Similarly you can create script policy. While creating image/script policy just use simple file name in place of url (if you have followed the exact url pattern described above)
Restart the server.
Follow the following syntax to add image/script policy in custom jsp's.
B) Referencing the assets through dynamic projects
Create a String Buffer having details of project. (or portelt ) from where customer can access policies.
In the following example you can create
StringBuffer sb2=new StringBuffer(""+
"http://www.volantis.com/xmlns/mcs/project\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.volantis.com/xmlns/mcs/project http://www.volantis.com/schema/project/3-5/mcs-project.xsd\" name=\"PA_offlineSample\">"+
Follow the steps to encode the String Buffer using BASE64Encoder.
ProjectString = new sun.misc.BASE64Encoder().encode(sb2.toString().getBytes());
ProjectString = "data:text/xml;base64," + ProjectString;
ProjectString = ProjectString.replaceAll("\r\n", "");
ProjectString = ProjectString.replaceAll("\r", "");
ProjectString = ProjectString.replaceAll("\n", "");
Details of variable used In xml-configuration file are given below
a) name = Name of Web Module(portlet) installed . (In my case inside InstalledApps)
b) Policy directory = Absolute directory path to policies
c) assets-base-url = context root of the portlet (Can be found from /wps/PA_offlineSample variable in "application.xml" file inside META-INF )
Step 3: By using below method all policy file of the PA_offllineSample can be used in any portlet
policy can be used in any portlet .