I have created a grails liferay portlet. I need to dynamically show/hide portlets in certain pages through IPC events.
For example based on my first page's submit action, i need to publish an event to the other portlets. Rest of the portlets need to process the event value and it should be decided whether portlets needs to be displayed or not. :(
Please help me out !
In your eventhandler, you can easily set
response.setRenderParameter("showSomething", "true");
and then, in render
if(response.getParameter("showSomething").equals("true")) {
// actually show something
} else {
// just render nothing
}
(Pseudocode: Add null-checks & make more elegant as appropriate)
You'll want to hide portlet borders for those portlets that you don't show. Alternatively, you might want to find out CSS classes of your portlet and render a CSS instruction to { display:none; } for your portlet, although this is dangerous: Your page admin needs a way to move the portlet around or delete it. Completely hiding all controls effectively makes it impossible to know what portlet is on the page.
Related
I have a problem with refreshing a single Liferay portlet. I wrote a bit of javascript code to refresh a single Liferay portlet every 120s:
function refreshPortlet() {
Liferay.Portlet.refresh("SOME_KEY")
};
setInterval("refreshPortlet()", 120000);
It works fine and the portlet refreshes, but the problem is that content of the portlet does not. I tried to clear the cache of the portlet with WebCachePoolUtil:
function refreshPortlet() {
WebCachePoolUtil.remove("SOME_KEY");
Liferay.Portlet.refresh("SOME_KEY")
};
setInterval("refreshPortlet()", 120000);
But now the function does not execute at all. Any hints?
Thanks in advance,
Stjepko
WebCachePoolUtil is a Java class, thus not available on the JS side. The reason the method is not executing is that it's running into the unavailability of that class.
If you want to execute browser-side code like you did, you'd need to identify where caching is done - e.g. on the browser or on the server. Observe your Developer Tool's network tab and inspect what's going across the wire.
Depending on the portlet that you're trying to refresh - specifically if it's a custom portlet - I'd recommend to implement Ajax explicitly and refresh either from a REST API or through the portlet's serveResource method.
hi i wanna have a filter pre every web pages that check someting and if that thing was incorrect show me an error page
and if it was fine just show me the page
Vaadin is mostly based on individual interactions such as clicking buttons or scrolling in a grid, rather than viewing pages. What you can still do is to use UI::addBeforeEnterListener to get an event before navigating to a new target. You can use a VaadinServiceInitListener to register that listener for all your UI instances.
For more information, have a look at this blog post that I've written on the topic.
I've noticed that sometimes liferay loads the content of a portlet using ajax. For example, we've done some heavy duty web content templates and sometimes I can see a loading spinner while rendering the page.
I know about ajaxable and render-weight properties in liferay-portlet.xml, but... how does liferay know whether to render a portlet content using ajax or not? and second question, is it any way to disable this feature for asset publisher and web content display portlets without changing liferay's internal liferay-portlet.xml?
By default ajaxable is set to true.
In order to modify this you can try updating the render-weight and ajaxable attributes using the class PortletPreferences.
Read more here: https://www.liferay.com/community/forums/-/message_boards/message/11904281
I am working with someone else's code. The code was originally designed so that data would dynamically create controls (and sub-controls of those controls...) on the OnInit event on numerous web control panels. And then later validation methods would check those dynamically created controls for valid data. This continues to work just fine for my web site. However, I need to be able to validate that data without my website (as in this will just be server side). The simpilist solution appeared to be to just have the panels initialize and then run the validation methods. That'd be great...if I could figure out how to initialize those panels server side without a web page.
Can this be done? Is there any way to get a panel to initialize without having a page to display that panel?
That way lies madness - you could use reflection to call the control's InitRecursive method, but it needs a Page (among other things) to run correctly.
You should extract the validation code into a new class that you can call from your server code an change your WebControl to use that class as well.
Try RenderControl.
I thought I would ask here about how to develop a wiazrd like control
in ajax for MVC before I started it.
The control will have pages that have data entry controls and
on each page submission insert data into a database.
Any ideas how to go about this?
Malcolm
Are you using a JavaScript library? I know dojo has a wizard in dojox namespace, and I'm pretty sure there are wizards for jquery. If not, I'd do a wizard just like I would tabs, without the tab bar, and each view contains a form and next, previous, cancel and or restart buttons, all of which would handle the ajax calls/state management and change the view.
If it's a wizard you probably actually should use separate web pages rather than having a single page that's updated through ajax calls, that way the forward and back buttons can work as nature intended in the browser for moving forward and back through the wizard.
Of course you can use fragment tricks to get forward / back working in a single page but in my experience this is tricky.