Fóruns

Início » Liferay Portal » English » 3. Development

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
andres digiovanni
velocity template get assetEntry
26 de Fevereiro de 2013 01:54
Resposta

andres digiovanni

Ranking: New Member

Mensagens: 14

Data de entrada: 18 de Setembro de 2012

Mensagens recentes

Hi!

I'm developping a web content template. I'm trying to get the ID of a AssetEntry but I can't get the attributs.


My code is :
1#set ($assetEntryLocalService = $serviceLocator.findService("com.liferay.portlet.asset.service.AssetEntryLocalService"))
2#set ($assetEntry = $assetEntryLocalService.getEntry("com.liferay.portlet.journal.model.JournalArticle", $resourceprimKey))
3
4$assetEntry



When I print $assetEntry I get:
1
2{entryId=11731, groupId=10528, companyId=10154, userId=10196, userName=Test Test, createDate=Fri Feb 15 09:16:17 GMT 2013, modifiedDate=Thu Feb 21 10:47:54 GMT 2013, classNameId=10108, classPK=11729, classUuid=0b9aeff3-63b8-4ac6-9db3-fa7dfafbbd70, classTypeId=11703, visible=true, startDate=null, endDate=null, publishDate=Fri Feb 15 09:15:00 GMT 2013, expirationDate=null, mimeType=text/html, title=, description=, summary=, url=, layoutUuid=, height=0, width=0, priority=0.0, viewCount=432}


This is a table row.

How can I get the entryId's value? I try to use the functions getEntryId(), split(","), ...... But doesn't work!

Edit: I'm using liferay 6.1.1

If anyone knows how to solve this problem I be gratefull.

Thanks!
Andrew
Juhi Kumari
RE: velocity template get assetEntry
26 de Fevereiro de 2013 02:20
Resposta

Juhi Kumari

Ranking: Expert

Mensagens: 347

Data de entrada: 12 de Dezembro de 2011

Mensagens recentes

Hi,

Your $resourceprimKey is 0 so you are not getting $assetEntry.
I set value for $resourceprimKey then its wirking fine.
BTW from where you are getting $resourceprimKey ???

Regards
Juhi
andres digiovanni
RE: velocity template get assetEntry
26 de Fevereiro de 2013 02:26
Resposta

andres digiovanni

Ranking: New Member

Mensagens: 14

Data de entrada: 18 de Setembro de 2012

Mensagens recentes

Hi,

I put all the code:

 1#set ($groupId = $themeDisplay.getLayout().getGroupId())
 2
 3#set ($journalArticleLocalService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalService"))
 4#set ($ja = $journalArticleLocalService.getArticle( $groupId, $reserved-article-id.data ))
 5#set ($resourceprimKey = $ja.getResourcePrimKey())
 6
 7#set ($assetEntryLocalService = $serviceLocator.findService("com.liferay.portlet.asset.service.AssetEntryLocalService"))
 8#set ($assetEntry = $assetEntryLocalService.getEntry("com.liferay.portlet.journal.model.JournalArticle", $resourceprimKey))
 9
10$assetEntry



The $resourceprimKey is diferent to 0. It has the correct value.

$assetEntry has the values I need but I can't access in it.


Regards,
Andrew
Juhi Kumari
RE: velocity template get assetEntry
26 de Fevereiro de 2013 03:45
Resposta

Juhi Kumari

Ranking: Expert

Mensagens: 347

Data de entrada: 12 de Dezembro de 2011

Mensagens recentes

Hi,
Replace your 4th line with this
1#set ($ja = $journalArticleLocalService.getArticle($getterUtil.getLong($groupId),$getterUtil.getString($reserved-article-id.data)))

Now it will work.

Regards
Juhi
James Falkner
RE: velocity template get assetEntry
26 de Fevereiro de 2013 06:40
Resposta

James Falkner

LIFERAY STAFF

Ranking: Liferay Legend

Mensagens: 1216

Data de entrada: 17 de Setembro de 2010

Mensagens recentes

andres digiovanni:


$assetEntry has the values I need but I can't access in it.


You should be able to call $assetEntry.getEntryId() - if that does not work then something has gone horribly wrong emoticon Also, make sure you uncheck 'cacheable' when editing the template.
andres digiovanni
RE: velocity template get assetEntry
26 de Fevereiro de 2013 08:52
Resposta

andres digiovanni

Ranking: New Member

Mensagens: 14

Data de entrada: 18 de Setembro de 2012

Mensagens recentes

I tried to use the methods getEntryId() but doesn't work. I don't know what has gone wrong.

I try your solution Juhi Kumari, but doesn't work.

Anyone has gone a similar error?

Thank you for the answers!
Andrew
Juhi Kumari
RE: velocity template get assetEntry
26 de Fevereiro de 2013 21:19
Resposta

Juhi Kumari

Ranking: Expert

Mensagens: 347

Data de entrada: 12 de Dezembro de 2011

Mensagens recentes

Hi,

Did you put this line in your portal-ext.properties ???
1journal.template.velocity.restricted.variables=


Regards
Juhi
Devendra Patel
RE: velocity template get assetEntry
26 de Fevereiro de 2013 22:04
Resposta

Devendra Patel

Ranking: Junior Member

Mensagens: 71

Data de entrada: 25 de Setembro de 2011

Mensagens recentes

Hi,

Do you want to get entryID?

If yes then you can achieve it by string split operation.$assetEntry is a String.so you can write like

#set ($arrayTemp = $assetEntry.split("entryId="))
#set($entryID = $arrayTemp[1].split(",")[0])

Hope this help you.

Regards,

Dev Patel
andres digiovanni
RE: velocity template get assetEntry
27 de Fevereiro de 2013 09:32
Resposta

andres digiovanni

Ranking: New Member

Mensagens: 14

Data de entrada: 18 de Setembro de 2012

Mensagens recentes

Hi!

It works!

I modified the portal-ext.properties.

Juhi Kumari:
Hi,

Did you put this line in your portal-ext.properties ???
1journal.template.velocity.restricted.variables=


Regards
Juhi



I had this:

1journal.template.velocity.restricted.variables=true


And I replaced it for:

1journal.template.velocity.restricted.variables=



I don't understand why the others methods works fine.

Thanks everybody for the answers!!

Regards,
Andrew
Devendra Patel
Re: [Liferay Forums][3. Development] RE: velocity template get assetEntry
28 de Fevereiro de 2013 22:11
Resposta

Devendra Patel

Ranking: Junior Member

Mensagens: 71

Data de entrada: 25 de Setembro de 2011

Mensagens recentes

Hi,

Do you want to get entryID?

If yes then you can achieve it by string split operation.$assetEntry is a
String.so you can write like

#set ($arrayTemp = $assetEntry.split("entryId="))
#set($entryID = $arrayTemp[1].split(",")[0])

Hope this help you.

Regards,

Dev Patel
Devendra Patel
Re: [Liferay Forums][3. Development] RE: velocity template get assetEntry
28 de Fevereiro de 2013 22:11
Resposta

Devendra Patel

Ranking: Junior Member

Mensagens: 71

Data de entrada: 25 de Setembro de 2011

Mensagens recentes

Hi,

Do you want to get entryID?

If yes then you can achieve it by string split operation.$assetEntry is a
String.so you can write like

#set ($arrayTemp = $assetEntry.split("entryId="))
#set($entryID = $arrayTemp[1].split(",")[0])

Hope this help you.

Regards,

Dev Patel
Devendra Patel
Re: [Liferay Forums][3. Development] RE: velocity template get assetEntry
28 de Fevereiro de 2013 22:11
Resposta

Devendra Patel

Ranking: Junior Member

Mensagens: 71

Data de entrada: 25 de Setembro de 2011

Mensagens recentes

Hi,

Do you want to get entryID?

If yes then you can achieve it by string split operation.$assetEntry is a
String.so you can write like

#set ($arrayTemp = $assetEntry.split("entryId="))
#set($entryID = $arrayTemp[1].split(",")[0])

Hope this help you.

Regards,

Dev Patel
Devendra Patel
Re: [Liferay Forums][3. Development] RE: velocity template get assetEntry
28 de Fevereiro de 2013 22:11
Resposta

Devendra Patel

Ranking: Junior Member

Mensagens: 71

Data de entrada: 25 de Setembro de 2011

Mensagens recentes

Hi,

Do you want to get entryID?

If yes then you can achieve it by string split operation.$assetEntry is a
String.so you can write like

#set ($arrayTemp = $assetEntry.split("entryId="))
#set($entryID = $arrayTemp[1].split(",")[0])

Hope this help you.

Regards,

Dev Patel
Devendra Patel
Re: [Liferay Forums][3. Development] RE: velocity template get assetEntry
28 de Fevereiro de 2013 22:11
Resposta

Devendra Patel

Ranking: Junior Member

Mensagens: 71

Data de entrada: 25 de Setembro de 2011

Mensagens recentes

Hi,

Do you want to get entryID?

If yes then you can achieve it by string split operation.$assetEntry is a
String.so you can write like

#set ($arrayTemp = $assetEntry.split("entryId="))
#set($entryID = $arrayTemp[1].split(",")[0])

Hope this help you.

Regards,

Dev Patel
Pravin Pawar
RE: velocity template get assetEntry
10 de Abril de 2013 04:46
Resposta

Pravin Pawar

Ranking: Junior Member

Mensagens: 62

Data de entrada: 17 de Novembro de 2009

Mensagens recentes

James,

$assetEntry.getEntryId(). It's working fine