I'm using liferay 6.1, jsf 2 and primeface 4.0. I've two different project running on a liferay tomcat. I want to insert a portlet of "Project 1" into primefaces dialog of "project 2".
I tried by using ui:insert, but it takes the source path of current project. How to proceed in this scenario?
with ui:insert, you can insert html code, not a whole portlet!
So you should either:
Create a common xhtml page that could be visible from both portlets. This would require that you have both portlets in the same plugin project
In the dialog, instead of inserting code, you can include a link to another page of your portal, where a "project2" portlet is placed
I'm managed to fixed that issue.
Liferay provides a generate URL functionality of each portlet. So I created a URL for target portlet.
then pass that url to liferay pop up.
Here is my code :
<script type="text/javascript" charset="utf-8">
var url;
function createRenderURL() {
AUI().ready('liferay-portlet-url', function(A) {
var renderURL = Liferay.PortletURL.createRenderURL();
renderURL.setName("Banner");
renderURL .setPortletMode("view");
renderURL .setWindowState("pop_up");
renderURL.setPortletId("addUser_WAR_UserManagementportlet");
url = renderURL.toString();
showPopup(url);
});
}
function showPopup(url){
console.log("En el showPopup ");
AUI().ready('aui-dialog', 'aui-io', function(A) {
alert(url);
window.myDialog = new A.Dialog({
title: 'Banner',
width: 640,
centered: true
}).plug(A.Plugin.IO, {
uri: url
}).render();
});
}
Hope it will help to another. Thanks.
Related
Here is my index.html file. I have required loading lex-web-ui.js and config.js files in script but still getting the error.
The error I am getting is ChatBotUiLoader is not defined
<html>
<head>
<title>My Parent Page</title>
</head>
<body>
<h1>Welcome to my parent page</h1>
<!-- loader script -->
<script src="./dist/lex-web-ui.js"></script>
<script>
/*
The loader library creates a global object named ChatBotUiLoader
It includes the IframeLoader constructor
An instance of IframeLoader has the load function which kicks off
the load process
*/
// options for the loader constructor
var loaderOptions = {
// you can put the chatbot UI config in a JSON file
configUrl: './config.json',
// the full page chatbot UI that will be iframed
iframeSrcPath: './chatbot-index.html#/?lexWebUiEmbed=true'
};
// The following statement instantiates the IframeLoader
var iframeLoader = new ChatBotUiLoader.IframeLoader(loaderOptions);
// chatbot UI config
// The loader can also obtain these values from other sources such
// as a JSON file or events. The configUrl variable in the
// loaderOptions above can be used to put these config values in a file
// instead of explicitly passing it as an argument.
var chatbotUiConfig = {
ui: {
// origin of the parent site where you are including the chatbot UI
// set to window.location.origin since hosting on same site
parentOrigin: window.location.origin,
},
iframe: {
// origin hosting the HTML file that will be embedded in the iframe
// set to window.location.origin since hosting on same site
iframeOrigin: window.location.origin,
},
cognito: {
// Your Cognito Pool Id - this is required to provide AWS credentials
poolId: 'xxx'
},
lex: {
// Lex Bot Name in your account
botName: 'xxx'
}
};
// Call the load function which returns a promise that is resolved
// once the component is loaded or is rejected if there is an error
iframeLoader.load(chatbotUiConfig)
.then(function () {
console.log('iframe loaded');
})
.catch(function (err) {
console.error(err);
});
</script>
</body>
</html>
I am trying to integrate AWS lex on my website. I am using this repo https://github.com/aws-samples/aws-lex-web-ui/tree/master/dist
But getting an error: ChatBotUiLoader is not defined. Can anyone help?
enter image description here
Simply, the error is that an instance of ChatBotUiLoader cannot be created as the library/script containing that object was not found within the scope of the page.
It could be that the demo application is broken but the fix is fairly simple.
You need to include the lex-web-ui-loader.js script file (and its dependencies) in your web page to resolve the issue.
Currently developing a ASP MVC site.
Some sections of the site will use VueJS for displaying some list, forms etc.
The project setup is Bower, Grunt, standard C# ASP project using TypeScript.
This is my first time using Vue, and the simple stuff is pretty stragt forward. Seting up a page with a form, getting data from a WebService etc.
My problem/question is, what, and how, do i get the best setup, for using Single File Components (Vue) in my cshtml view files.
So, lets say I have a section on my site, where i want to display orders from the user.
Layout, navigation etc is setup by my excisting ASP code. I have a CSHTML viewpage for the current page, pretty vanilla:
#inherits MyViewPage<MyViewModel>
#{
Layout = "~/Views/layout.cshtml";
}
<div id"app">
</div>
Thats it for the excisting view page. In this page, i want to include a Vue Single File Component.
Previously i had the markup directly in the CSHTML page, which works fine. But when i want to user Vue-router, it becomes a problem to maintain the different views. So i should move the markup into a Component.
This is the basic setup;
const page1 = { template: '<div>Page1</div>' }
const page2 = { template: '<div>Page2</div>' }
const routes = [
{ path: '/', component: page1 },
{ path: '/page2', component: page2 }
]
const router = new VueRouter({
routes
})
var vm = new Vue({
router,
el: "#app"
})
Lets say i create a .vue file called page1.vue instead. This contains
<template>
my new page
</template>
<script>
export default {
name: '?',
date: function() {
}
}
</script>
How do i get this file included in my CSHTML file for instance?
You need to develop with webpack to build Single File Components.
See the Vue documentation on this.
Use the Vue Cli and drop a web pack build into your cshtml page.
I am using latest google recaptcha in my ASP.Net MVC project. By default, it takes up the language set in the browser.
However, I want it to be displayed always in english.
Here is what I have tried so far:
My Script for onload:
var onloadCallback = function () {
// Renders the HTML element with id 'example1' as a reCAPTCHA widget.
// The id of the reCAPTCHA widget is assigned to 'widgetId1'.
//widgetId1 = grecaptcha.render(document.getElementById('g-recaptcha'), {
// 'sitekey': '6Lc2Zf8SAAAAAOC9_6L7k5mCnxGao7vCv5_1KxrL'
//});
grecaptcha.render('g-recaptcha', {
'sitekey': '6LdRfv8SAAAAAOagkckxW72cHAQKrvNGLasbU6G2',
'callback': verifyCallback,
'theme': 'dark',
'lang': 'en'
});
};
Can we force recaptcha to be always displayed in a certain language?
I finally got the answer.
In the link to include the Google recaptcha, you can pass your language in form of query string:
<script src="https://www.google.com/recaptcha/api.js?hl=fr&onload=onloadCallback&render=explicit" async defer></script>
How does one go about displaying a controller action inside of jquery modal dialog?
Firstly you'll need your Javascript to load a url via ajax, this will depend on which kind of modal you are using etc, there's a ton of libraries out there. I will assume you are using the basic JQuery UI dialog Modal.
Example Link
<!-- this points to your action below.. -->
<a class="some-link" title="title here" href="mycontroller/test">testing</a>
Example Javascript (quick example found on google, many examples out there..)
$(document).ready(function() {
$('.some-link').each(function() {
var $link = $(this);
var $dialog = $('<div></div>')
.load($link.attr('href'))
.dialog({
autoOpen: false,
title: $link.attr('title'),
});
});
});
Now you need to make sure your action doesn't render the main layout when providing the content for the modal via the ajax request.
Here's a really simple method of doing that by replacing the base layout with an empty view for ajax requests. This isn't the best method but it's the simplest for this case ;)
Example Action
public function testAction()
{
if($this->getRequest()->isXmlHttpRequest()) {
$this->layout('application/layout/ajax-layout');
}
return new ViewModel(array()); // ..
}
application/layout/ajax-layout.phtml
<?php echo $this->content ?>
I think you want this kind of code http://jqueryui.com/dialog/#modal-message
inside the just display your action
Otherwise it's about to open an url into your modal it's like that http://blog.nemikor.com/2009/04/18/loading-a-page-into-a-dialog/
I am looking to standardize the processing of ajax #anchors at the server side, using MVC.
Before a controller action is invoked I want to convert every request with ajax anchors into a request without ajax anchors, so that the controller code does not know there were anchors in the request:
For example:
1) /user/profile#user/photos should be treated as /user/photos
2) /main/index#user/profile/33 should be treated as /user/profile/33
What is the best technique in MVC to accomplish that?
This should necessarily be done on the client side, probably using jquery as everything that follows the # sign is never sent to the server.
I too struggle with same issue and I solved this problem after looking at Visual Studio 11 Developer Preview template code. I added following code in my _layout.cshtml, please note we must load jquery.mobile*.js file after following script tag:
<script type="text/javascript">
$(document).bind("mobileinit", function () {
// As of Beta 2, jQuery Mobile's Ajax navigation does not work in all cases (e.g.,
// when navigating from a mobile to a non-mobile page, or when clicking "back"
// after a form post), hence disabling it. http://jquerymobile.com/demos/1.0a3/#docs/api/globalconfig.html
#{
if (ViewBag.JqueryMobileAjaxEnabled != null && ViewBag.JqueryMobileAjaxEnabled == true)
{
#: $.mobile.ajaxEnabled = true;
}
else
{
#: $.mobile.ajaxEnabled = false;
}
}
});
</script>
**<script src="http://code.jquery.com/mobile/1.0b3/jquery.mobile-1.0b3.min.js"></script>**