Foros de discusión

How to create dynamic selection list in web content.

Ashwani Kumar, modificado hace 11 años.

How to create dynamic selection list in web content.

Junior Member Mensajes: 26 Fecha de incorporación: 19/10/12 Mensajes recientes
Hi,
In my web content structure, I have created a field with name "Country" as selection-list. I want to populate this selection-list with values stored in my data-base table. So that at actual content creation time only predefined values are available for the country field.

Basic requirement is , Instead of giving the static values for the selection-list in web content structure, selection-list must be populated with database table value.

Thanks in advance. any suggestion is highly appreciated.

-.
Ashwani
thumbnail
Juhi Kumari, modificado hace 11 años.

RE: How to create dynamic selection list in web content.

Expert Mensajes: 347 Fecha de incorporación: 12/12/11 Mensajes recientes
Hi Ashwani,

Put these lines in template vm file of web content to get Countries drop down
#set ($count= $serviceLocator.findService("com.liferay.portal.service.CountryService" ))
#set($countrlist = $count.getCountries())
<select>
#foreach($item in $countrlist)
   <option value="$item.getCountryId()">$item.getName()</option>
#end
</select>


And in portal-ext.properties
journal.template.velocity.restricted.variables=  


Regards
Juhi
Ashwani Kumar, modificado hace 11 años.

RE: How to create dynamic selection list in web content.

Junior Member Mensajes: 26 Fecha de incorporación: 19/10/12 Mensajes recientes
Hi Juhi,

Thanks for your valuable response.

After configuring your code "country-list" drop-down displayed in web content display portlet (Once I select the web content for which i configure the given code.)

My requirement is, When I create the web content itself, at that time country list should be available.
eg. My web content Structure contains two fields. 1. Name(Text) 2. Country Name(drop-down)

at the same time , Is it possible to fill-up this drop-down list from my custom table value.??

-
Regards
Ashwani Kumar
thumbnail
Juhi Kumari, modificado hace 11 años.

RE: How to create dynamic selection list in web content.

Expert Mensajes: 347 Fecha de incorporación: 12/12/11 Mensajes recientes
Hi Ashwani,

What is problem with that?? While creating web content with structure and template you can write these code in template.

Regards
Juhi
Ashwani Kumar, modificado hace 11 años.

RE: How to create dynamic selection list in web content.

Junior Member Mensajes: 26 Fecha de incorporación: 19/10/12 Mensajes recientes
Hi Juhi,

The code written in template will be executed when we add a web content to the Web-content-display portlet not at the time when we create the web content itself(Make me correct if i am wrong.).
Below are the steps I am doing.
1> Created the structure with one selection-list(eg. countryList).
2> Created the template and place your code.
Now I am creating the web content based on structure created at step -1, Here it is showing a blank selection-list. But my requirement is to get Country list here.

-
Regards
Ashwani Kumar
thumbnail
Manoj Kumar, modificado hace 9 años.

RE: How to create dynamic selection list in web content.

New Member Mensajes: 3 Fecha de incorporación: 11/12/13 Mensajes recientes
I have the same requirement where I need to modify the initial Content Entry form to populate a selection list values using a service.

If you do anything in template its only applicable on the front end side when you display the content.

I am using Liferay 6.2. Can any one give some direction on how to achieve this ?

Thanks in Advance
Manish Singh, modificado hace 9 años.

RE: How to create dynamic selection list in web content.

New Member Mensajes: 10 Fecha de incorporación: 22/08/14 Mensajes recientes
Ashwani Kumar:

The code written in template will be executed when we add a web content to the Web-content-display portlet not at the time when we create the web content itself(Make me correct if i am wrong.).
Below are the steps I am doing.
1> Created the structure with one selection-list(eg. countryList).
2> Created the template and place your code.
Now I am creating the web content based on structure created at step -1, Here it is showing a blank selection-list. But my requirement is to get Country list here.



Hi,

While creating the Structure you will get options to add value for the Selection List.
In "XML Schema Definition" there will be a button called "Launch Editor"
Click on Launch Editor and place your code as below..

<dynamic-element name="City" type="list" index-type="" repeatable="false">
<dynamic-element name="Dhanbad" type="0" index-type="" repeatable="false"/>
<dynamic-element name="Bangalore" type="1" index-type="" repeatable="false"/>
</dynamic-element>

-
Regards
Manish Singh
Firoza Saiyed, modificado hace 8 años.

RE: How to create dynamic selection list in web content.

New Member Mensaje: 1 Fecha de incorporación: 26/04/14 Mensajes recientes
Hi Ashwini,
Did you get the solution of your requirement? I also has the same requirement of filling up the list by reading the values from database table.

Thanks,
Firoza
thumbnail
Mayur Patel, modificado hace 7 años.

RE: How to create dynamic selection list in web content.

Expert Mensajes: 358 Fecha de incorporación: 17/11/10 Mensajes recientes
Hi All,

Is there any solution for this requirement?

Thanks !