Auto-refreshing of a portlet after another portlet finished its work - refresh

I have two portlets:
One is for displaying a list of files (and more)
The second is to import files into Liferay's document library.
If I have both portlets on one page how can I achieve that the 'listing' portlet refreshes after the import portlet has finished its work? This is mandatory because the hyperlinks in the listing portlet will change after the import.

Here is a pointer on how to refresh a portlet using ajax call.
Liferay.Portlet.refresh("p_p_id_<targetportletnamespae>_");
Its upto you to decide when to call this js method, based on your requirement.

Related

Calling multiple (python) functions from a single web page

I'm going through several tutorials on Flask and Vue and until now I've seen only the pattern, one route corresponding to one python function. What I would like to do is from a single web page (single route) be able to call multiple functions without reloading the page e.g. by pressing a button x call function x on the server and present the results on the same web page, by pressing a button y call function y on the server and present the results on the same web page etc.
Is this possible and if yes how? (I mean tips not necessarily code)
I think what are you searching for is Ajax Calls.
you can specify for each action to trigger an Ajax Call to the server as each route has his own action in server ( Flask in your case ) for more details search for REST API. For that you can look to axios library.

Why should I use {{#link-to}} instead of <a></a> in EmberJS?

This is a pretty newbie question. However, in EmberJS, I've found that both of the methods work for linking to the blog page in my application.
<p>{{#link-to 'posts'}} See my blog{{/link-to}}</p>
See my blog
Is it better to use {{link-to}} in EmberJS? How come?
The difference is that the {{link-to}} component will navigate to the specified route within the current running Ember application, while <a href="posts"> will do a new browser request to that location and re-start your Ember app at that route. You should use {{link-to}} since you'll be using the Ember internals to navigate within your single-page application and it will be a smoother user experience.
While they both can work, watch your browser closely and you'll see the anchor tag will give you a page refresh and re-launch your Ember app (though in the right location). Using a {{link-to}} will feel faster since Ember is presenting the new page via javascript rather than restarting after a page refresh. It's the difference between navigating within a single-page application, and jumping into a SPA from an external page.
While Ember does render an anchor tag in place of the {{link-to}} at run-time, it interjects to stop the default anchor tag behaviour. The docs explain it like so:
By default the {{link-to}} component prevents the default browser
action by calling preventDefault() as this sort of action bubbling is
normally handled internally and we do not want to take the browser to
a new URL (for example).
(from https://emberjs.com/api/classes/Ember.Templates.helpers.html#toc_allowing-default-action)
Also, with the {{link-to}} component you can pass a model directly into the route. This is a bit more advanced, but the Ember guides have some good examples.
https://guides.emberjs.com/v2.13.0/templates/links/

Create a web page in odoo 8

I create a web page in odoo 8,
I created a template in /mymodule/views/my_template.xml
<template id="dms_web_client.webclient_bootstrap1" name="FTP server Webclient">
<t t-call="website.layout">
<a id="create_new_directory" href="#" data-action="new_dir">New Directory</a>
</t>
</template>
When I click on a link New Directory I need to open up a pop up with a text box and file browse and save & cancel button. Like create a new page in website module.
I don't know what to do next. Please help.
If you need to interact with other models within your module (or even Odoo in general), you're probably going to want to create a controller, which can contain python code and allow your web page to interact with models. On a simple level, a controller can go in your main folder (ie /mymodule/my_template_controller.py) and be declared in your init.py file (import my_template_controller). You can then set a route that matches your template id and create forms that post to the controller, allowing python code to be run and models to be interacted with. That can allow you to have your file browse and save and cancel button.
As far as the front end, you can use html, css, and Javascript like any normal website and they can be declared via normal links in the page header.
Odoo does have some documentation, but it is pretty poor, unfortunately. It took me a long time to decipher how to fully build a web application within it. However, it works great once you figure it out and it generally follows the guidelines of any other model/controller/view application.
http://www.odoo.com/documentation/9.0/howtos/website.html
https://www.odoo.com/documentation/9.0/reference/http.html

Reload googlemaps after user clicks a link in Django

I am doing a project in Django and i want to have some google maps displayed in my site. So, i installed django-easy-maps and successfully used it in a sample template. So, i am ready with my maps.
The interface i want to implement is this
http://i49.tinypic.com/sowm74.png
I want to display the maps where the Hellow World! container is and with different links on the sidebar i want to refresh the map being displayed on user click without reloading the page.
I did some researching and it seems Ajax is the solution...
Can anybody tell me how i might achieve this (with or without Ajax ) ?
Sorry for sounding like a noob but i am fairly new to this.
The basic steps are:
Create a view for the Google Maps section to the right. This view does not return a full HTML page but only the HTML for that section (which contains your Google Maps map).
When the user clicks on a link on the left, use JavaScript to perform an ajax call to request that page. In short this means: attach an event handler to the onclick event of those links and in code you can perform an ajax call .Many people use a JavaScript library for this purpose, such as jQuery (which has $.ajax()).
You can then use JavaScript to put the received HTML inside the container on the right (using $.html()).

Plone-like search box in Django?

Plone has a beautiful search box with a "Google suggest" like functionality for its site. It even indexes uploaded documents like PDFs. Does anyone know of a module that can provide this kind of functionality in a Django site?
Plone implements it's LiveSearch feature by maintaining a separate metadata table of indexed attributes (fields such as last modified, creator, title are copied from the content objects into this table). Content objects then send ObjectAdded/ObjectModified/ObjectRemoved events, and an event subscriber listens for these events and is responsible for updating the metadata table (in Django events are named signals). Then there is a Browser View exposed at a fixed URL that searches the metadata and returns the appropriate LiveSearch HTML, and finally each HTML page is sent the appropriate JavaScript to handle the autocomplete AJAX functionality to query this view and slot the resulting HTML results into the DOM.
If you want your LiveSearch to query multiple Models/Content Types, you are likely going to need to send your own events and have a subscriber handle them appropriately. This isn't necessary for a smaller data sets or lower traffic sites, where the performance penalty for doing multiple queries for a single search isn't a concern (or you only want to search a single content type) and you can just do several queries from your View.
As for the JavaScript side, you can roll-your-own or use an existing JavaScript library. This is usually called autocomplete in the JS library. There is YUI autocomplete and Scriptaculous autocomplete for starters, and likely lots more JavaScript autocomplete implementations out there. Plone uses KSS for it's JavaScript library, the KSS livesearch plugin is a good place to start if looking for example code to pluck from.
http://pypi.python.org/pypi/kss.plugin.livesearch
And a tutorial on using KSS with Django:
http://kssproject.org/docs/tutorial/kss-in-django-with-kss-django-application
KSS is quite nice since it cleanly separates behaviour from content on the client side (without needing to write JavaScript), but Scriptaculous is conceptually a little simpler and has somewhat better documentation (http://github.com/madrobby/scriptaculous/wikis/ajax-autocompleter).