Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Srikanth Adepu
How to write a hook to add new select list field in Web Content Structures
October 31, 2012 7:40 AM
Answer

Srikanth Adepu

Rank: New Member

Posts: 11

Join Date: October 31, 2012

Recent Posts

Hi,

I need to write a hook to add new drop down list field in Web Content Structures and i have to get that drop down list values from database instead hard coding in structure itself.

How can i update the newly added drop down list from the database?
Pavel Savinov
RE: How to write a hook to add new select list field in Web Content Structu
October 31, 2012 7:57 AM
Answer

Pavel Savinov

Rank: Junior Member

Posts: 97

Join Date: September 24, 2012

Recent Posts

Hi.

You can use Velocity in your Web content to fill a drop-down list using some your service (or built-in Liferay's service). Without a hook.
Like this (if you get, for example, SomeEntity with name and values fields):
1#set ($someEntityService = $serviceLocator.findService("com.some.package.SomeEntityLocalService"))
2#set ($someEntityList = $someEntityService.findAll())
3<select id="myDropDownList">
4   #foreach ($someEntity in $someEntityList)
5      <option value="$someEntity.getValue()">$someEntity.getName()</option>
6   #end
7</select>