how to get freeMarkerPortletPreferences in the nested template Liferay 7.4 - freemarker

Liferay 7.4, I have web content which has one field to select a web content in it. I am creating the freeMarkerPortletPreferences something like below line in web content's template (parent).
<#assign freeMarkerPortletPreferences =  freeMarkerPortletPreferences.getPreferences({
            "view": "HomeCarousel",
            "mainTitleColor": "${mainTitleColor.getData()}"
        })/>
now in the nested web content's template, freeMarkerPortletPreferences are coming Empty in liferay 7.4. (In liferay 7.0, freeMarkerPortletPreferences was available in the scope of nested template, was able to retrieve it directly )
Can anyone help with how to pass freeMarkerPortletPreferences and get the same in nested template?

Related

How to integrate Gantt Oracle Jet Chart in Oracle Apex 5.1?

Does anyone know how to integrate the Oracle Jet Gantt chart into Oracle Apex version 5.1? The research I have done shows either how to integrate Jet components into version 5.0 (but to my understanding, a lot changed between versions 5.0 and 5.1, specifically with regards to the Oracle JET library) or how to integrate a couple of different Oracle Jet components into Apex 5.1, but the code used to integrate these components seems very specific to the components being integrated. I have tried copying and pasting the javascript code and the HTML code from the Oracle Jet Cookbook into the the appropriate sections in the Page Designer on Apex, but nothing shows up when I run the page. Specifically, I'm wondering how to use the Oracle Jet cookbook code for the Gantt chart to create that Gantt chart on a page in my Apex application?
Has anyone tried to do this yet?
Thank you in advance.
If you do not find a plugin, you can use oracle-jet gantt by making direct references using a CDN to the files on your apex page.
1 - First upload the main.js file to the shared components of your application. He must follow these guidelines https://docs.oracle.com/middleware/jet400/jet/developer/GUID-219A636B-0D0B-4A78-975B-0528497A82DD.htm#JETDG-GUID-219A636B-0D0B-4A78-975B-0528497A82DD
Your main.js look like this:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
function _getCDNPath(paths) {
var cdnPath = "";
var ojPath = "";
var thirdpartyPath = "";
var keys = Object.keys(paths);
var newPaths = {};
function _isoj(key) {
return (key.indexOf('oj') === 0 && key !== 'ojdnd');
}
keys.forEach(function(key) {
newPaths[key] = cdnPath + (_isoj(key) ? ojPath : thirdpartyPath) + paths[key];
});
return newPaths;
}
require.config({
paths: _getCDNPath({
'knockout': 'https://static.oracle.com/cdn/jet/v4.0.0/3rdparty/knockout/knockout-3.4.0',
'jquery': 'https://static.oracle.com/cdn/jet/v4.0.0/3rdparty/jquery/jquery-3.1.1.min',
'jqueryui-amd': 'https://static.oracle.com/cdn/jet/v4.0.0/3rdparty/jquery/jqueryui-amd-1.12.0.min',
'ojs': 'https://static.oracle.com/cdn/jet/v4.0.0/default/js/min',
'ojL10n': 'https://static.oracle.com/cdn/jet/v4.0.0/default/js/ojL10n',
'ojtranslations': 'https://static.oracle.com/cdn/jet/v4.0.0/default/js/resources',
'text': 'https://static.oracle.com/cdn/jet/v4.0.0/3rdparty/require/text',
'promise': 'https://static.oracle.com/cdn/jet/v4.0.0/3rdparty/es6-promise/es6-promise.min',
'hammerjs': 'https://static.oracle.com/cdn/jet/v4.0.0/3rdparty/hammer/hammer-2.0.8.min',
'signals': 'https://static.oracle.com/cdn/jet/v4.0.0/3rdparty/js-signals/signals.min',
'ojdnd': 'https://static.oracle.com/cdn/jet/v4.0.0/3rdparty/dnd-polyfill/dnd-polyfill-1.0.0.min',
'css': 'https://static.oracle.com/cdn/jet/v4.0.0/3rdparty/require-css/css.min',
'customElements': 'https://static.oracle.com/cdn/jet/v4.0.0/3rdparty/webcomponents/custom-elements.min',
'proj4js': 'https://static.oracle.com/cdn/jet/v4.0.0/3rdparty/proj4js/dist/proj4'
})
})
requirejs.config({
baseUrl: '',
// Path mappings for the logical module names
paths: {
},
// Shim configurations for modules that do not expose AMD
shim: {
'jquery': {
exports: ['jQuery', '$']
},
'maps': {
deps: ['jquery', 'i18n'],
}
},
// This section configures the i18n plugin. It is merging the Oracle JET built-in translation
// resources with a custom translation file.
// Any resource file added, must be placed under a directory named "nls". You can use a path mapping or you can define
// a path that is relative to the location of this main.js file.
config: {
ojL10n: {
merge: {
//'ojtranslations/nls/ojtranslations': 'resources/nls/menu'
}
}
}
});
2 - Now you need to load this file (main.js) and require.js on your page. Use the "File URLs" field for this.
require.js: https://static.oracle.com/cdn/jet/v4.0.0/3rdparty/require/require.js
3 - In the header of your page you need to include this code:
<link rel="stylesheet" id="css" href="https://static.oracle.com/cdn/jet/v4.0.0/default/css/alta/oj-alta-min.css">
<script>
if (!document.createElement) {
document.createElement = document.constructor.prototype.createElement;
document.createElementNS = document.constructor.prototype.createElementNS;
document.importNode = document.constructor.prototype.importNode;
}
// The "oj_whenReady" global variable enables a strategy that the busy context whenReady,
// will implicitly add a busy state, until the application calls applicationBoostrapComplete
// on the busy state context.
window["oj_whenReady"] = true;
</script>
4 - Create a region to place the html of your oracle-jet chart
5 - Finally, create a dynamic action to effectively create your gantt chart. The dynamic action event is page loading. It should run a javascript code. This code is the file demo.js on cookbook site.
Ex. https://apex.oracle.com/pls/apex/f?p=145794:23
login on: https://apex.oracle.com/pls/apex/f?p=4550
workspace: stackquestions
user: test
pwd: test
app: 145794
page: 23
Once you make this work, your problem will be how to get the data and update the gantt depending on some filters. I suggest creating a restful service to get this data from your tables. For this you will need some javascript handling to make your data follow the format expected by oracle-jet. You can see the expected format in the ganttData.json file.
Good luck.
I noticed that the css file needed to make the oracle-jet work interferes with the page's css. I tried to use this idea Limit scope of external css to only a specific element? but it did not work completely.
why just not take a plugin ? either write your own or look at apex.world for the gantt plugin

Get portlet type in Liferay 6.2 Hook

Inside Liferay 6.2 hook I want to know the portlet type(Asset Publisher/Web Content Display). Portlet name wont help me because User may have used custom title and in that case "Asset Publisher"/"Web Content Display" wont be accessible to me.
Exact hook file location where i want Portlet-type is: /html/portlet/portlet_css/view.jsp
Well without hooking other parts of Liferay you can't get it there (in java code). Portlet "Portlet CSS" is populated via javascript so there was apparently no need to send portletid as parameter.
To get portletId you should also hook /html/js/liferay/look_and_feel.js
autoLoad: false,
showLoading: false,
data: {
p_l_id: themeDisplay.getPlid(),
p_p_id: 113,
p_p_state: EXCLUSIVE,
doAsUserId: themeDisplay.getDoAsUserIdEncoded()
},
uri: themeDisplay.getPathMain() + '/portal/render_portlet'
modify it to be something like this
autoLoad: false,
showLoading: false,
data: {
p_l_id: themeDisplay.getPlid(),
p_p_id: 113,
p_p_state: EXCLUSIVE,
doAsUserId: themeDisplay.getDoAsUserIdEncoded(),
_113_portletId: instance._portletId
},
uri: themeDisplay.getPathMain() + '/portal/render_portlet'
comma and _113_portletId: instance._portletId were added.
After that you can put in hooked /html/portlet/portlet_css/view.jsp
String portletId = (String) renderRequest.getParameter("portletId");
portletId for Asset publisher will be something like 101_INSTANCE_reKokSN3aDaL
portletId for Web Content Display will be something like
56_INSTANCE_dxNxXuQ7ZuvB
so you can test wether portletId starts with 101, 56, ...
You can also get Portlet object with
PortletLocalServiceUtil.getPortletById(portletId);
UPDATE (answer to question in comment):
This portlet was not intended for such use, once it loads it stays rendered in html and all modifications are made with javascript.
When "Look and feel" is opened for first time after page load XHR request to server is made and "/html/portlet/portlet_css/view.jsp" is rendered.
Second time (for another portlet on the same page), javascript prepares modal for another (or same) porlet, "/html/portlet/portlet_css/view.jsp" will not be rendered again.
To force rerendering of "/html/portlet/portlet_css/view.jsp" modify again "/html/js/liferay/look_and_feel.js".
after (in my source it is line 136)
if (!content) {
content = A.Node.create('<div class="loading-animation" />');
}
add this
if (instance._currentPopup) {
A.one("#" + instance._currentPopup.get("id")).remove()
instance._currentPopup = null;
}
It should be before
if (!instance._currentPopup) {
instance._currentPopup = Liferay.Util.Window.getWindow(
...
Clear Liferay and browser cache.
You could get PortletDisplay object from ThemeDisplay context object and from PortletDisplay, you can get Title, PortletName etc.
Note that themeDisplay is already available and used in your jsp /html/portlet/portlet_css/view.jsp
PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();
String title=portletDisplay.getTitle();
String portletName=portletDisplay.getPortletName();

php ckeditor version 4 adding custom fonts

Iam working on php code igniter with version 4 ck editor.
Trying to add custom fonts.
I have tried adding the following code to ckeditor/config.js
CKEDITOR.editorConfig = function( config )
{
config.contentsCss = 'fonts.css';
config.font_names = 'Dekers/dekers_true' + config.font_names;
}
the font adds to the drop but is not applied to text

Teleric RadEditor - Can I register client OnClientSubmit events in the skin file?

There is a known issue with the Telerik RadEditor that causes odd character insertions, as documented here.
The work around requires the insertion of a client-side script to strip out the offending character in the OnClientSubmit event.
We use this control in many places and have three styles defined in our skins file for it. We also derive a custom control from the RadEditor in a custom control we call RichEdit.
The question is - will this approach work to guarantee that all instances of our RichEdit control receive the required client-side event?
1) In the RichEdit.cs OnLoad, register a client script block containing the required javascript function
2) In the skin file, add the required OnClientSubmit method call to each skin?
So - will it work? And if not, what DO I need to do?
And the answer is yes.
Adding a call to this method in the page load section:
private void AddRichEditGarbageCharacterWorkaround()
{
string scriptName = "RadEditorOnClientSubmit";
Type csType = GetType();
ClientScriptManager csm = Page.ClientScript;
if (!csm.IsClientScriptBlockRegistered(csType, scriptName))
{
StringBuilder sb = new StringBuilder();
sb.Append("<script type=\"text/javascript\">");
sb.Append("\tfunction RadEditorStripGarbage(editor, args) {");
sb.Append("\t\tvar html = editor.get_html();");
sb.Append("\t\thtml = html.replace(/\u200b/g, \"\");");
sb.Append("\t\teditor.set_html(html);");
sb.Append("\t\t}");
sb.Append("</script>");
csm.RegisterClientScriptBlock(csType, scriptName, sb.ToString());
}
}
And adding this to the skin:
<nt:RichEdit runat="server" SkinID="SpellCheckOnly" ...
OnClientSubmit="RadEditorStripGarbage" >
Successfully added the code and the hook to every instance.

Retrieving DOM values after AJAX call

I want to check some DOM values from Perl (I don't want to use browser and debugger manually).
These DOM values are loaded after an AJAX call, and the sample function for one of these values would be:
<script language="javascript">
try {
var openValue = FComma(fnRound(Symbol[24],2));
if (openValue == "0.00") document.write('n/a');
else document.write(openValue);
} catch (exception) {}
</script>
I can't get it directly from AJAX. I'm wondering if there is any possibility to grab the DOM values after the AJAX call was done. This call is done only at the beginning.
What I would do (er, try, because I'm not certain this will do what you want) is: use Firefox with the Web Developer add-on installed. After the page has loaded and the AJAX stuff has finished, go to Web Developer's View Source menu and choose View Generated Source; copy/paste the source into your editor and/or Perl script, and do what you want to do with it.
Try to use WWW::Scripter:
use WWW::Scripter;
$w = new WWW::Scripter;
 
$w->use_plugin('Ajax');  # packaged separately
 
$w->get('http://some.site.com/that/relies/on/ajax');
$w->eval(' alert("Hello from JavaScript") ');
$w->document->getElementsByTagName('div')->[0]->....
 
$w->content; # returns the HTML content, possibly modified
             # by scripts

Resources