Message Boards

Error after update. Velocity.

ildar sl, modified 2 Years ago.

Error after update. Velocity.

Regular Member Posts: 158 Join Date: 12/12/11 Recent Posts

Hi!

    #set($assetEntryLocalService = $serviceLocator.findService("com.liferay.portlet.asset.service.AssetEntryLocalService"))

    #set($assetEntryQuery = $portal.getClass().forName('com.liferay.portlet.asset.service.persistence.AssetEntryQuery').newInstance())
	
    #set($V = $assetEntryQuery.setAttribute("isNews", true))
    #set($V = $assetEntryQuery.setAttribute('startDate', $startDate))
    #set($V = $assetEntryQuery.setAttribute('endDate', $endDate))
    #set($V = $assetEntryQuery.setAnyCategoryIds($getterUtil.getLong($categoryId.getData())))
    #set($V = $assetEntryQuery.setOrderByCol1('expirationDate'))
    #set($V = $assetEntryQuery.setOrderByType1('ASC'))
    #set($V = $assetEntryQuery.setOrderByCol2('title'))
    #set($V = $assetEntryQuery.setOrderByType2('ASC'))

    #set($eventCount = $assetEntryLocalService.getEntriesCount($assetEntryQuery))
    #set($entries = $assetEntryLocalService.getEntries($assetEntryQuery))



	${entries.size()}

 

This piece of code worked in Liferay 6.2 GA3
But he doesn't want to work in 6.2 GA6 in any way, after updating the version
Will not throw errors. It just writes the name of the variable "$ {entries.size ()}" in the browser.


Any ideas please?

 

 

ildar sl, modified 2 Years ago.

RE: Error after update. Velocity.

Regular Member Posts: 158 Join Date: 12/12/11 Recent Posts
<#assign
	assetEntryLocalService = serviceLocator.findService("com.liferay.portlet.asset.service.AssetEntryLocalService")
	assetEntryQuery = objectUtil('com.liferay.portlet.asset.service.persistence.AssetEntryQuery')

	V = assetEntryQuery.setAttribute("isNews", true)
	V = assetEntryQuery.setAttribute('startDate', startDate?date)
	V = assetEntryQuery.setAttribute('endDate', endDate?date)
	V = assetEntryQuery.setAnyCategoryIds([getterUtil.getLong(categoryId.getData())])
	V = assetEntryQuery.setOrderByCol1('expirationDate')
	V = assetEntryQuery.setOrderByType1('ASC')
	V = assetEntryQuery.setOrderByCol2('title')
	V = assetEntryQuery.setOrderByType2('ASC')
	
	eventCount = assetEntryLocalService.getEntriesCount(assetEntryQuery)
	entries = assetEntryLocalService.getEntries(assetEntryQuery)
/>	

 

it almost works like that. But date limitation doesn't work

 

ildar sl, modified 2 Years ago.

RE: Error after update. Velocity.

Regular Member Posts: 158 Join Date: 12/12/11 Recent Posts
Calendar startDate = Calendar.getInstance();
startDate.add(Calendar.MONTH, -8);
Calendar endDate = Calendar.getInstance();
endDate.add(Calendar.MONTH, -1);
System.out.println(startDate.getTime());
System.out.println(endDate.getTime());
DynamicQuery dynamicQuery2 = 
			DynamicQueryFactoryUtil.forClass(AssetEntry.class, PortalClassLoaderUtil.getClassLoader());
dynamicQuery2.add(PropertyFactoryUtil.forName("groupId").eq(themeDisplay.getScopeGroupId()));
dynamicQuery2.add(RestrictionsFactoryUtil.between("createDate", startDate.getTime(),endDate.getTime()));
dynamicQuery2.addOrder(OrderFactoryUtil.asc("createDate"));

 

Remained only assetEntryQuery.setAnyCategoryIds([getterUtil.getLong(categoryId.getData())])