Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Dynamic select + Service classes access
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:
4.- My jsp has:
.
.
.
....and at the jsp's bottom
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?
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?
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:
3.- At the middle of the jsp:
4.- At the jsp bottom:
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.
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.