留言板

Array en VM

Juan Manuel Beas,修改在9 年前。

Array en VM

New Member 帖子: 10 加入日期: 15-1-11 最近的帖子
Gracias a todos,

Estoy intentando hacer un array de long para buscar en los blog sobre un tagIds especifico, pero me esta dando problemas al crear el long o eso al menos creo porque en la propiedad no aparece el valor y luego no me devuelve ningún blog.


Mi codigo:

<section class="mod-borde-azul mod-right-ideas">
    <header>
	    <p>Ideas: Deportes y Aventuras</p>
    </header>

#set ($entriesInstance = $portal.getClass().forName("com.liferay.portlet.blogs.service.BlogsEntryLocalServiceUtil").newInstance())
#set($assetEntryQuery = $portal.getClass().forName( "com.liferay.portlet.asset.service.persistence.AssetEntryQuery" ).newInstance())

#set($tagIds = [$getterUtil.getLong("36928")])

<p>$tagIds</p><p>

#set ($void = $assetEntryQuery.setAllTagIds($tagIds))

</p><p>$assetEntryQuery</p><p>

#if (!$entries.isEmpty())
    #foreach ($Entry in $entries)
    	....    	
    #end
#end
</p></section>




En :
<p>$assetEntryQuery</p>

Me devuelve: {allCategoryIds=, [b]allTagIds=[/b], anyCategoryIds=, anyTagIds=, classNameIds=, classTypeIds=null, description=, end=-1, excludeZeroViewCount=false, expirationDate=Wed Jan 14 13:12:59 GMT 2015, groupIds=null, keywords=, linkedAssetEntryId=0, notAllCategoryIds=, notAllTagIds=, notAnyCategoryIds=, notAnyTagIds=, orderByCol1=null, orderByCol2=null, orderByType1=null, orderByType2=null, paginationType=null, publishDate=Wed Jan 14 13:12:59 GMT 2015, start=-1null, title=, visible=true}



Entiendo que aqui deberia de poner el id que he insertado allTagIds=, pero no es así.

Un saludo y gracias por vuestro tiempo
Nam Phung,修改在9 年前。

RE: Array en VM

New Member 帖子: 3 加入日期: 14-12-11 最近的帖子
I have same problem with query by CategoryIds. This is my code:


#set ($assetEntryLocalService = $serviceLocator.findService('com.liferay.portlet.asset.service.AssetEntryLocalService'))
#set ($assetEntryQuery = $portal.getClass().forName("com.liferay.portlet.asset.service.persistence.AssetEntryQuery").newInstance())
#set ($catIds = [$getterUtil.getLong(27410)])
#set ($VOID = $assetEntryQuery.setAllCategoryIds($catIds))
#set ($assetEntryList = $assetEntryLocalService.getEntries($assetEntryQuery))


Here is my setting on "portal-ext.properties"


journal.template.velocity.restricted.variables=
velocity.engine.restricted.variables=


When I debuged, I saw the input parameter assetEntryQuery on AssetEntryLocalService is null.
Please help me. Thanks all !
thumbnail
Arunjyoti Banik,修改在9 年前。

RE: Array en VM

Junior Member 帖子: 74 加入日期: 14-8-26 最近的帖子
Hi Nam and Juan,

Refer this. https://www.liferay.com/community/wiki/-/wiki/Main/Custom+Velocity+Variables.

Arun
Nam Phung,修改在9 年前。

RE: Array en VM

New Member 帖子: 3 加入日期: 14-12-11 最近的帖子
Thanks Arun for your reply. I solved my problem, and here is what I did:

Put more line setting for "portal-ext.properties" for enables load class AssetEntryQuery on Velocity Template


velocity.engine.restricted.classes=


and here is the work around for populate array in velocity:

#set($tempArr=[])
#set($tempArr=$catIds)
#set($arr=$tempArr.toArray($catIds))
#set($longArray=$arrayUtil.toArray($arrayUtil.toLongArray($arr)))
#set ($VOID = $assetEntryQuery.setAllCategoryIds($longArray))


Hope this help for others.