Dynamic select + Service classes access

7240012, modified 15 Years ago. Junior Member Posts: 61 Join Date: 1/25/11 Recent Posts
I want to make one Dynamic Select, but all my tests falls...
First I start with standalone select that is filled in JQuery call, but doesn't work.

1.- I create one entity:
types

2.- I generated all service classes, with remote-service="true"

3.- JSON classes were generated and service.js has:

Liferay.Service.register("Liferay.Service.servicenamespace", "com.work.portal.servicenamespace.service");


4.- My jsp has:

<%
	themeDisplay.setIncludeServiceJs(true);
%>

.
.

<select name="<portlet:namespace />typesselect"></select><br>

.
....and at the jsp's bottom

<script type="text/javascript">
    JQuery(function () {
        new Liferay.DynamicSelect([{
	select: '<portlet:namespace />typesselect',
	selectId: 'typesId',   //primary key
	selectDesc: 'typesDes',//desciption field
	selectVal: '',
	selectData: function(callback){					    Liferay.Service.servicenamespace.types.findAll(callback);
	}
	);
</script>


I used the notation : Liferay.Service.servicenamespace.types.findAll
where:
servicenamespace=the <namespace></namespace> from service.xml
types=entity name
findAll= findAll method, that I defined (and ant build-service) at typesLocalServiceImpl

The combo is not filled, and if I debug, findAll method is not reached never...

What's wrong?
7240012, modified 15 Years ago. Junior Member Posts: 61 Join Date: 1/25/11 Recent Posts
New tests:

1.- I comment themeDisplay.setIncludeJs(true), because with firebug I discover that include js service access for inside portal services (like getAddresses from Addresses). I want to access to my own service classes.

2.- I put the next code at the begining of the jsp:

<script type="text/javascript">
	Liferay.Service.register("Liferay.Service.servicenamespace", "com.work.portal.servicenamespace.service");
	Liferay.Service.registerClass(Liferay.Service.servicenamespace,"types",{
		findAll:true
	});
</script>


3.- At the middle of the jsp:

<select name="<portlet:namespace />typesselect"></select><br>


4.- At the jsp bottom:

<script type="text/javascript">
	jQuery(function () {
		new Liferay.DynamicSelect(
			[
				{
					select: '<portlet:namespace />typesselect',
					selectId: 'typesId',
					selectDesc: 'typesDes',
					selectVal: '',
					selectData: function(callback) {
						Liferay.Service.servicenamespace.types.findAll({}, callback);
					}
				}
			]
		);
	});
</script>


I see at firebug that error:
Liferay.DynamicSelect is not a constructor

The combo not shows any value

There is any tutorial or example to see how works DynamicSelect? addresses.jsp not help for my problem.