Recent Bloggers

Carlos Hernandez

Staff
2 Mensagens
24 de Fevereiro de 2018

David H Nebinger

68 Mensagens
23 de Fevereiro de 2018

Jonas Choi

Staff
3 Mensagens
23 de Fevereiro de 2018

Jamie Sammons

Staff
11 Mensagens
19 de Fevereiro de 2018

Iacopo Colonnelli

2 Mensagens
17 de Fevereiro de 2018

Christian Klein

1 Mensagens
15 de Fevereiro de 2018

Jose M. Navarro

Staff
8 Mensagens
14 de Fevereiro de 2018

Maria Sanchez

Staff
18 Mensagens
13 de Fevereiro de 2018

Sergio González

Staff
5 Mensagens
13 de Fevereiro de 2018

Minhchau Dang

Staff
15 Mensagens
31 de Janeiro de 2018
« Voltar

Embedding a portlet in web content

Company Blogs 8 de Dezembro de 2010 Por Barrie Selack

 Many people have asked, "How can I embed a portlet in web content". It's actually quite simple, once you know how. So I'll walk you through it.

It;s done via a runtime-portlet tag. The actual syntax looks like this:

<div id="embedded-welcome-portlet">
  <runtime-portlet name="47" instance="4433" queryString=""/>
</div>

(47 is the Hello World portlet)
 
The divs are not necessary, but in order to style the embeded portlet later we need them there.
 
So here is the Structure for the web content with the three pieces of information to pass to the runtime-portlet tag. (If you want, you can use hard coded values in the template of the web content)
 
 
And the template for the web content..
 
 
The template contains...
 
<p>
This is web content, with an embedded portlet!
</p>
 
<div id="embedded-welcome-portlet-$instance-id.getData()">
   <runtime-portlet name="$portlet-id.getData()" instance="$instance-id.getData()" queryString="$query-string.getData()"/>
</div>
 
Where the values from the template are passed in. We're not using the query string for this example.
 
So when rendered, it looks like this...
 
 
And there we have the Hello World portlet in our web content. But I really don't like that frame and title, so lets use CSS to style it.
 
In the web content use the configuration (little wrench) and select "Look and Feel"
 
Then we'll put the CSS under "Advanced Styling" This will use standard portlet CSS styles to change the look. Below is what gets set. Here's where we use the div id to make sure we only style out portlet.

 

 

Then the rendered web content will look like this.

 

But what if you want to use your own portlet? No problem, just use the name it is given by Liferay. In this case we'll use the Web Form portlet since it's not a Liferay built in portlet.

 

 

And now the web content looks like...

 

If the embedded portlet has a configuration option, you can configure it like any portlet to have different values on every page. You can also use the portlet's own Look and Feel to remove the borders or set a custom title. The WebForm portlet does have it's own configuration options (Hello World does not) Unfortunately at this time, you cannot use it's own configuration Look and Feel to style it, as the Web Content that contains it, overrides it's styling. 

 

Since one of the parameters is an instance-id, you can have multiple embedded instances of the same portlet on the page as below.

And there you are! A portlet embedded in web content.

If you're interested in more leave a comment. Thanks for reading.

 

Respostas do tópico Autor Data
It is a good inception explained: Unraveling... Shepherd Ching 8 de Dezembro de 2010 20:10
Ok, so I can put portlet instance in my... Szymon Gołębiewski 9 de Dezembro de 2010 03:48
I added a section to the blog to explain this.... Barrie Selack 9 de Dezembro de 2010 04:51
Same Web Content can be displayed automaticaly... Szymon Gołębiewski 9 de Dezembro de 2010 05:18
Can you give me an example of what you would... Barrie Selack 9 de Dezembro de 2010 05:44
For example I have news portal with such... Szymon Gołębiewski 9 de Dezembro de 2010 10:44
this is very cool.. .thanks for sharing! Chris Whittle 9 de Dezembro de 2010 05:52
Nice article, Barrie! Thanks for sharing Juan Fernández 9 de Dezembro de 2010 09:55
very cool article. thanks barrie! Wilson Man 9 de Dezembro de 2010 10:00
Thanks for sharing Barry. This is one of the... Mika Koivisto 9 de Dezembro de 2010 17:23
Good article and good example how you can use... Sampsa Sohlman 10 de Dezembro de 2010 02:12
Hi Barrie, we are using this runtime portlet... Olaf Fricke 15 de Dezembro de 2010 12:47
Nice example.... Dhrutika Vyas 15 de Dezembro de 2010 21:37
Wonderful example.. I tried this its working... Mohammed Azam 15 de Dezembro de 2010 23:13
Hello, can You give a simple example how to... gofri _ 16 de Dezembro de 2010 00:46
Like! Scott Lee 18 de Janeiro de 2011 11:09
Hello Everybody! I'm a student come from... ly tm 19 de Janeiro de 2011 19:14
Cool feature, but how do you set portlet... Francesco Marangi 28 de Janeiro de 2011 06:22
I'm have real trouble getting this to work. I'm... Phill Pover 21 de Março de 2011 07:47
Okay, I fixed the first issue I was having... Phill Pover 21 de Março de 2011 09:35
A serious question... Can this runtime-portlet... Dave Weitzel 23 de Março de 2011 06:51
Hi, Thanks for Good Article.But I am not... vasv kumar 19 de Julho de 2011 00:05
[...] Take a look at this blog entry Als... Anônimo 26 de Julho de 2011 06:54
[...] Hi philip, you are right...you can also... Anônimo 27 de Julho de 2011 00:14
What about WSRP: could both the embedding... P F 4 de Agosto de 2011 02:10
Hi I was wondering how you would use this to... Mat Gritt 21 de Agosto de 2011 17:50
[...] Please check this blog which explains how... Anônimo 10 de Setembro de 2011 08:56
[...] Here's another link that may help... Anônimo 14 de Novembro de 2011 09:57
do anyone say me how i search name and instance... Miguel Ángel González 23 de Outubro de 2012 09:13
Hi, All the pictures are gone. Thanks, Akos Ákos Gábriel 17 de Dezembro de 2013 07:22

It is a good inception explained: Unraveling the portlet within the dream

http://www.cinemablend.com/new/inception-explained-unraveling-the-dream-wit­hin-the-dream-19615.html
Postado em 08/12/10 20:10.
Ok, so I can put portlet instance in my webcontent. Does it mean that on every page that web content is displayed that portlet will have the same configuration? An when I change this portlet config will it change on all sites? As I recall I can have many pages with same portlet instance (for example by using Page Templates) but their configuration is separated for every page
Postado em 09/12/10 03:48.
I added a section to the blog to explain this. If the embedded portlet has a configuration option, you can configure it like any portlet to have different values on every page. Thanks for your question.
Postado em 09/12/10 04:51 em resposta a Szymon Gołębiewski.
Same Web Content can be displayed automaticaly on different pages of Portal. In such case you will have to configure you portlet on multiply pages. In websites as big as news portals you want have time to do that. Is there any way to prepare global configuration for portlet instance?
Postado em 09/12/10 05:18 em resposta a Barrie Selack.
Can you give me an example of what you would you are trying to do?
Postado em 09/12/10 05:44 em resposta a Szymon Gołębiewski.
this is very cool.. .thanks for sharing!
Postado em 09/12/10 05:52.
Nice article, Barrie! Thanks for sharing
Postado em 09/12/10 09:55.
very cool article. thanks barrie!
Postado em 09/12/10 10:00.
For example I have news portal with such sitemap:
- home page
-- Sport
---- football
---- tennis
-- Moto
---- Cars
---- Vans

In news portals same web content is displayed in various places. In this case My article will be shown on pages like Cars, Moto and Home Page (beacuse it's about Batmans new batmobile). Now I want to show under that article a lists of other articles related to this one by tags. So I embedded Asset Publisher and configure it (using Cars page) to show "Web contents containing any tag: batmobile, car".

The problem is I want to define this configuration just once and for every place this article will be shown at (home page and Moto). Is there any way to do that?
Postado em 09/12/10 10:44 em resposta a Barrie Selack.
Thanks for sharing Barry. This is one of the cool features that got me started using Liferay back in version 3.x.
Postado em 09/12/10 17:23.
Good article and good example how you can use web content.

Adding portlet to wcm template was new for me - anyway with same principles, it is possible to integrate iframe, flash .. youtube.. etc. to Liferay also. This is just by clever using of Web content as configuration repository (which already have editor also).

Btw, how this effect on Liferay and page caching, mainly to cache filter, which does not recognize if the page has embedded portlets on resources (like theme)?
Postado em 10/12/10 02:12.
Hi Barrie, we are using this runtime portlet tag since two years in our web sites as well. In most cases, it is just working fine.

But we encountered some limitations you should be aware of:
1. The tag can only be used in templates; raw HTLM articles just ignore it.
2. The portlets that are included via the runtime portlet tag are not considered when exporting a community into a lar file, doing staging or remote publishing.
3. If you include a web content portlet, it will not be found by a community search, because the entry in the JournalArticleSearchEntry table is missing.
4. You must not include a web content portlet into itself (i.e. use the instance id of the web content portlet that contains the runtine portlet tag as value). If you do so, you will end up with a stack overflow due to infinite recursion.

Best regards,
Olaf
Postado em 15/12/10 12:47.
Nice example....
Postado em 15/12/10 21:37 em resposta a Olaf Fricke.
Wonderful example.. I tried this its working .But My question is is that possible to show the embedded portlet only to the user who has logged in
Postado em 15/12/10 23:13.
Hello,
can You give a simple example how to embed (core) portlet in another portlet (in view.jsp)? Which libs and tld will be needed?
Postado em 16/12/10 00:46.
Postado em 18/01/11 11:09.
Hello Everybody!
I'm a student come from VietNam!
I'm studying about Richface framework!
I had got a problem in JSF(Richface) Portlet when I used JavaScript!
That problem is : I could not get a value into a <h:inputText /> with JavaScript!
Can anybody help me?
Thank you very much!

This is my code:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html">

<f:view>
<script type="text/javascript">
function check() {
var result = document.getElementById("myform:form").value;
alert(result);
}
</script>

<h:form id="myform">

<h3>Hello :</h3>

<h:inputText value="" id="form" />

<h:commandButton value="OK" onclick="check();"/>

</h:form>

</f:view>

</ui:composition>
Postado em 19/01/11 19:14 em resposta a Scott Lee.
Cool feature, but how do you set portlet preferences? I saw the runtime-portlet tag has a defaultPreferences attribute... how would you pass preferences in a VM journal article template?
Postado em 28/01/11 06:22.
I'm have real trouble getting this to work. I'm running this from a development system, so the potential for a permissions issue is there, but even copying the Hello World example code above is not letting me put the portlet into my template.

What am I missing here? The portlet-runtime tag is coming through, but it doesn't appear to be getting parsed into an actual portlet.
Postado em 21/03/11 07:47.
Okay, I fixed the first issue I was having (this ONLY works through the web content portlet, not asset manager or any of the others), but now I'm having an issue with the queryString parameter. I'm trying to invoke the webProxy portlet in a template and set the url of the page that the portlet is proxying, but no matter how I format the queryString, this is not working.

<runtime-portlet name="66" instance="1284" queryString="initUrl=http://somewebaddress.com"/>

Please help.
Postado em 21/03/11 09:35 em resposta a Phill Pover.
A serious question...

Can this runtime-portlet tag be used in all other portlets (eg document and image "properties" or blogs and wiki)? I alos think it needs a bit more information - or a link to another blog/wiki article about the query string and other parameters that can be passed to the runtime-portlet tag.

You will see form my forum postings I have been trying to add a pagelet from a new portlet (handling Dublin Core categorization items) into a lot of other portlets but no one even suggested this tag. I would need to pass the current groupId and object Id (blog post etc) to make it work.
Postado em 23/03/11 06:51.
Hi,
Thanks for Good Article.But I am not getting my custom portlets.I am getting Default portlets.
Postado em 19/07/11 00:05 em resposta a Dave Weitzel.
[...] Take a look at this blog entry Als Antwort markieren [...] Read More
Postado em 26/07/11 06:54.
[...] Hi philip, you are right...you can also customize that if you are embedding OOTB portlets for not showing icons and borders, Refer this link,... [...] Read More
Postado em 27/07/11 00:14.
What about WSRP: could both the embedding portlet and the embedded portlet be WSRP portlets?
Thanks.
Postado em 04/08/11 02:10.
Hi I was wondering how you would use this to insert a webform portlet in to the theme. specifically portal_normal.vm.

any help gratefully received
Postado em 21/08/11 17:50 em resposta a Veronym Kroun.
[...] Please check this blog which explains how we can add or link a portlet from the Web Content . ~Kamesh Mark as an Answer [...] Read More
Postado em 10/09/11 08:56.
[...] Here's another link that may help http://www.liferay.com/web/barrie.selack/blog/-/blogs/embedding-a-portlet-in-web­-content You can embed one web content within another... Flag Please sign in to flag... [...] Read More
Postado em 14/11/11 09:57.
do anyone say me how i search name and instance of my runtime-portlet?

thanks you in advance
Postado em 23/10/12 09:13 em resposta a .
Hi,

All the pictures are gone.

Thanks,
Akos
Postado em 17/12/13 07:22.