留言板
Dependent Combo Box
hai..Pls..Let me know how to achieve dependent combo box,
Like selecting Country has to populate regions of country..
Like selecting Country has to populate regions of country..
Hai...thanks for the reply de..Pls Let me know by using Ajax, and calling serveResource method of JSR 286..
and also state should be populated from database..
Thanks
and also state should be populated from database..
Thanks
Hi,
I think following liferay forum post will be helpful
http://www.liferay.com/community/forums/-/message_boards/message/5722974
I think following liferay forum post will be helpful
http://www.liferay.com/community/forums/-/message_boards/message/5722974
Hi sheela,
The functionality that you are looking for is already present in liferay.
Please find the screen shot for the same.
You can refer jsp file from the path html/portlet/users_admin/common/addressess.jsp
Regards,
Amit Doshi
The functionality that you are looking for is already present in liferay.
Please find the screen shot for the same.
You can refer jsp file from the path html/portlet/users_admin/common/addressess.jsp
Regards,
Amit Doshi
Hai..Thanks for the reply..de..
I'm using liferay CE..In address page of user...regions are not populating after selecting Country..
So..I'm trying to do using serveResource() as per JSR 286..that uses Ajax, at the same time values shoud be from DB..
Pls let me knw..any solutions...
Let me knw which Edition of liferay you are using..
Thanks,
I'm using liferay CE..In address page of user...regions are not populating after selecting Country..
So..I'm trying to do using serveResource() as per JSR 286..that uses Ajax, at the same time values shoud be from DB..
Pls let me knw..any solutions...
Let me knw which Edition of liferay you are using..
Thanks,
Hai..That address.jsp is really confusing..can you know me as simple as possible..
ex. defining one to many relationship between Country and Regions in service.xml
so that I do get Collection of regions based on Country Id..
Thanks
ex. defining one to many relationship between Country and Regions in service.xml
so that I do get Collection of regions based on Country Id..
Thanks
There is no implicit handling for 1 to m relationshiop in service.xml (using service builder tool). Liferay just provides a utitily method if we declare one entity in particular way as column in other entity (we can get list of entities of one entity in another). The 2 entities you are referring to are liferay's OOTB entities - normally we should though those for any changes. The one mentioned by Amit was good start for this use case
Hai..Nagendra..Pls..is it possible share any example code for dependent combo box..
I saw your..post.. about..using JSonObject...and populating thr' XUtil.m1();...but..bit not in clear..
It helps me a lot if you eloborate..it..
I saw your..post.. about..using JSonObject...and populating thr' XUtil.m1();...but..bit not in clear..
It helps me a lot if you eloborate..it..
Hi!
I had trouble with dynamic select a time ago, you can take a look to this thread where I put my code (and it works fine)
Hope it helps
Regards.
I had trouble with dynamic select a time ago, you can take a look to this thread where I put my code (and it works fine)
Hope it helps
Regards.
hai..this is my..service.xml..
I has to populate capabilityName based on industryId...
Pls..Let me know what code to add into js,jsp,portlet class...
Pls..Also let me know flow also..if possible..
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_0_0.dtd">
<service-builder package-path="com.database">
<author>sourceone</author>
<namespace>J</namespace>
<entity name="IndustryCategory">
<column name="industryCategoryId" type="long" primary="true" />
<column name="industryName" type="String" />
<column name="getAllCapability" type="Collection" entity="Capability" mapping-key="industryCategoryId"/>
</entity>
<entity name="Capability">
<column name="CapabilityId" type="long" primary="true" />
<column name="capabilityName" type="String" />
<column name="industryCategoryId" type="long"/>
</entity>
</service-builder>
I has to populate capabilityName based on industryId...
Pls..Let me know what code to add into js,jsp,portlet class...
Pls..Also let me know flow also..if possible..
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_0_0.dtd">
<service-builder package-path="com.database">
<author>sourceone</author>
<namespace>J</namespace>
<entity name="IndustryCategory">
<column name="industryCategoryId" type="long" primary="true" />
<column name="industryName" type="String" />
<column name="getAllCapability" type="Collection" entity="Capability" mapping-key="industryCategoryId"/>
</entity>
<entity name="Capability">
<column name="CapabilityId" type="long" primary="true" />
<column name="capabilityName" type="String" />
<column name="industryCategoryId" type="long"/>
</entity>
</service-builder>
Hi again,
Did you build the WSDD of your service.xml? If you did, you should have a service.js file in your code, which registers the methods generated by the service builder (copy paste from my example):
That's the code you need to make your combos work. In my example, I copied this code into the view.jsp file. Then, you can use the Dynamic Select function just like in the adress example above.
Regards
Did you build the WSDD of your service.xml? If you did, you should have a service.js file in your code, which registers the methods generated by the service builder (copy paste from my example):
Liferay.Service.register("Liferay.Service.plxmiperfil", "com.plexus.educantabria.miperfilescritorio.service", "mi-perfil-escritorio-portlet");
Liferay.Service.registerClass(
Liferay.Service.plxmiperfil, "Localidad",
{
getLocalidadesByMunicipio: true,
getCentrosPorLocalidad: true,
getAulasPorCentro: true
}
);
Liferay.Service.registerClass(
Liferay.Service.plxmiperfil, "Municipio",
{
getMunicipios: true
}
);
That's the code you need to make your combos work. In my example, I copied this code into the view.jsp file. Then, you can use the Dynamic Select function just like in the adress example above.
Regards
Hai..I'm not able understand code syntax itself..
May I know your Mother Tongue..your code not in english i think..I'm understanding...properly...
After building services I got...only this much...
Liferay.Service.register("Liferay.Service.J", "com.database.service", "job-portlet");
in /js/service.js..then what to add in service.js ...What are those..getX:true???
Liferay.Service.registerClass(
Liferay.Service.plxmiperfil, "Localidad",
{
getLocalidadesByMunicipio: true,
getCentrosPorLocalidad: true,
getAulasPorCentro: true
}
);
Liferay.Service.registerClass(
Liferay.Service.plxmiperfil, "Municipio",
{
getMunicipios: true
}
);
As per my table..Let me know
May I know your Mother Tongue..your code not in english i think..I'm understanding...properly...
After building services I got...only this much...
Liferay.Service.register("Liferay.Service.J", "com.database.service", "job-portlet");
in /js/service.js..then what to add in service.js ...What are those..getX:true???
Liferay.Service.registerClass(
Liferay.Service.plxmiperfil, "Localidad",
{
getLocalidadesByMunicipio: true,
getCentrosPorLocalidad: true,
getAulasPorCentro: true
}
);
Liferay.Service.registerClass(
Liferay.Service.plxmiperfil, "Municipio",
{
getMunicipios: true
}
);
As per my table..Let me know
Liferay.Service.registerClass(
Liferay.Service.J,"IndustryCategory ",
{
//what to add here??
}
);
Liferay.Service.registerClass(
Liferay.Service.J,"Capability ",
{
//What to add here??
}
);
Following is just a general idea on implementing dependent combo box in general. Create 2 entities to fill the combo box.
Create api by generating them by service builder - enable JSON interfaces. Set up to use jQuery to fill these combo boxes.
Some of liferay's portlets were written a long time ago and the codes doesn't seem to be maintained too well. It's easier to just
write from scratch.
Create api by generating them by service builder - enable JSON interfaces. Set up to use jQuery to fill these combo boxes.
Some of liferay's portlets were written a long time ago and the codes doesn't seem to be maintained too well. It's easier to just
write from scratch.
Liferay.Service.register("Liferay.Service.J", "com.database.service", "job-portlet");
in /js/service.js..then what to add in service.js ...What are those..getX:true???
Those methods, are my own service builder finder methods, implemented on the *ServiceImpl classes. I use them to populate my combo boxes.
Hai..I tried..out your example..I'm able..to populate for only Country Id of 1..ie canada..But Others are not populating..
And..Also..Not your entities also..not geting populating..
I ve uploaded my jsp and service.xml ..Pls see where went wrong..is there any file to share..regarding this example..
Pls Let me know ..What I'm missing..Whare I should ..see for getting correctness..
And..Also..Not your entities also..not geting populating..
I ve uploaded my jsp and service.xml ..Pls see where went wrong..is there any file to share..regarding this example..
<%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui" %>
<%-- <%@page import="database.service.ConcellosServiceUtil"%>
<%@ page import="com.liferay.portal.kernel.exception.SystemException" %> --%>
<%-- <%@ page import="database.model.Concellos" %>
<%@ page import="database.model.Localidade" %>
<%@ page import="database.service.ConcellosLocalServiceUtil" %>
<%@ page import="database.service.LocalidadeLocalServiceUtil" %>
<%@ page import="java.util.List" %> --%>
<%@ page import="com.liferay.portal.theme.ThemeDisplay" %>
<%@ page import="com.liferay.portal.kernel.util.WebKeys" %>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
//What is inside..jQuery file???
<!-- <script src="/js/liferay/service.js" type="text/javascript"></script>
<script src="/html/js/jquery/jquery.js" type="text/javascript"></script> -->
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineobjects />
<%
ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
themeDisplay.setIncludeServiceJs(true);
%>
<script type="text/javascript">
Liferay.Service.register("Liferay.Service.D", "database.service", "double-portlet");
Liferay.Service.registerClass(
Liferay.Service.D, "Concellos",
{
getConcellos: true //But..Where this method 'l be present..in generated code??
}
);
Liferay.Service.registerClass(
Liferay.Service.D, "Localidade",
{
localidadesPorMunicipio: true //Where this method 'l be present..in generated code??
}
);
</script>
<script type="text/javascript">
Liferay.Localizaciones = {
getMunis: function(callback) {
Liferay.Service.D.Concellos.getConcellos(
{
},
callback
);
},
getLocs: function(callback, selectKey) {
Liferay.Service.D.Localidade.localidadesPorMunicipio(
{
municipioId:Number(selectKey)
},
callback
);
}
};
</script>
<%
/*
//TESTING THE METHODS FROM SERVICE BUILDER
List<localidade> locs = LocalidadeLocalServiceUtil.localidadesPorMunicipio(1);
for (int i = 0; i < locs.size(); i++){
System.out.println("LOC: "+locs.get(i).getNombreloc());
}
System.out.println("OK");
List<concellos> concellos = ConcellosServiceUtil.getConcellos();
for (int i = 0; i < concellos.size(); i++){
System.out.println("LOC: "+concellos.get(i).getNombre());
}
*/
%>
<aui:select label="Municipio" name="Municipio" />
<aui:select label="Localidad" name="Localidad" />
<aui:script use="liferay-dynamic-select">
new Liferay.DynamicSelect(
[
{
select: '<portlet:namespace />Municipio',
selectData: Liferay.Localizaciones.getMunis,
selectDesc: 'nombre',
selectId: 'municipioId',
selectVal: '<%= 1 %>'
}, {
select: '<portlet:namespace />Localidad',
selectData: Liferay.Localizaciones.getLocs,
selectDesc: 'nombreloc',
selectId: 'localidadId',
selectVal: '<%= 1 %>'
}
]
);
</aui:script>
<aui:select label="country" name="addressCountryId" />
<aui:select label="region" name="addressRegionId" />
<aui:script use="liferay-dynamic-select">
new Liferay.DynamicSelect(
[
{
select: '<portlet:namespace />addressCountryId',
selectData: Liferay.Address.getCountries,
selectDesc: 'name',
selectId: 'countryId',
selectVal: '<%= 1 %>'
},
{
select: '<portlet:namespace />addressRegionId',
selectData: Liferay.Address.getRegions,
selectDesc: 'name',
selectId: 'regionId',
selectVal: '<%= 1 %>'
}
]
);
</aui:script>
</concellos></localidade>
<!--?xml version="1.0" encoding="UTF-8"?-->
<service-builder package-path="database">
<author>sourceone</author>
<namespace>D</namespace>
<entity name="Concellos" local-service="true" remote-service="true">
<!-- PK fields -->
<column name="municipioId" type="long" primary="true" />
<!-- Audit fields -->
<column name="nombre" type="String" />
<!-- Order -->
<order by="asc">
<order-column name="nombre" />
</order>
<!-- Finder methods -->
<finder name="Nombre" return-type="Collection">
<finder-column name="nombre" />
</finder>
</entity>
<entity name="Localidade" local-service="true" remote-service="true">
<!-- PK fields -->
<column name="localidadId" type="long" primary="true" />
<column name="municipioId" type="long" />
<!-- Audit fields -->
<column name="nombreloc" type="String" />
<!-- Order -->
<order by="asc">
<order-column name="nombreloc" />
</order>
<!-- Finder methods -->
<finder name="Concello" return-type="Collection">
<finder-column name="municipioId" />
</finder>
</entity>
</service-builder>
Pls Let me know ..What I'm missing..Whare I should ..see for getting correctness..
Ok, first of all, sorry for the language details in my code. "Concello" stands for County, -not exactly the same, but enough for understanding, and "Localidad" stands for village, or something like that.
So, you pick a "Concello" and, then, you pick one of the "localidades" that belong to the selected one...
You need, then, a method that retrieves all the concellos (it would be just something like concelloPersistence.findAll() ), and a method that retrieves all the localidades for a particular one concello (localidadPersistence.findByConcello(concelloId), -maybe the name are not exactly the same, just remembering... )
If you run the previous service.xml, you will get all the model and service classes for both entities, you can then implement the methods you need on their respective *ServiceImpl classes.
Finally, you call the methods you've created in the RegisterClass:
Remember to build WSDD in ServiceBuilder or it won't work!
and, as far as I know, that should do the trick
Of course, you have to populate the database tables with some "concellos" and "localidades" with the right IDs to get it work!
Hope it helps
Good luck!
So, you pick a "Concello" and, then, you pick one of the "localidades" that belong to the selected one...
You need, then, a method that retrieves all the concellos (it would be just something like concelloPersistence.findAll() ), and a method that retrieves all the localidades for a particular one concello (localidadPersistence.findByConcello(concelloId), -maybe the name are not exactly the same, just remembering... )
If you run the previous service.xml, you will get all the model and service classes for both entities, you can then implement the methods you need on their respective *ServiceImpl classes.
Finally, you call the methods you've created in the RegisterClass:
Liferay.Service.registerClass(
Liferay.Service.D, "Concellos",
{
getConcellos: true
}
);
Liferay.Service.registerClass(
Liferay.Service.D, "Localidade",
{
localidadesPorMunicipio: true
}
);
Remember to build WSDD in ServiceBuilder or it won't work!
and, as far as I know, that should do the trick
Of course, you have to populate the database tables with some "concellos" and "localidades" with the right IDs to get it work!
Hope it helps
Good luck!
Hai..Thanks for reply..
I'm getting..these error in console..even if doing WSDD..
My ConcellosServiceImpl
My LocalidadeServiceImpl
Pls..Let me know..What i left..
I'm getting..these error in console..even if doing WSDD..
My ConcellosServiceImpl
public class ConcellosServiceImpl extends ConcellosServiceBaseImpl {
/*
* NOTE FOR DEVELOPERS:
*
* Never reference this interface directly. Always use {@link database.service.ConcellosServiceUtil} to access the concellos remote service.
*/
List<concellos> getConcellos() throws SystemException
{
List<concellos> concellos=concellosPersistence.findAll();
return concellos;
}
}</concellos></concellos>
My LocalidadeServiceImpl
public class LocalidadeServiceImpl extends LocalidadeServiceBaseImpl {
/*
* NOTE FOR DEVELOPERS:
*
* Never reference this interface directly. Always use {@link database.service.LocalidadeServiceUtil} to access the localidade remote service.
*/
List<localidade> localidadesPorMunicipio(long muncipoiId) throws SystemException
{
List<localidade> alllocali=localidadePersistence.findByConcello(muncipoiId);
return alllocali;
}
}</localidade></localidade>
06:13:06,718 ERROR [JSONServiceAction:471] No method found for class class database.service.ConcellosServiceUtil, method getConcellos, and parameters
06:13:06,720 ERROR [JSONServiceAction:471] No method found for class class database.service.LocalidadeServiceUtil, method localidadesPorMunicipio, and parameters municipioId
Pls..Let me know..What i left..
Hi,
If still there are some doubts, follow the following link
http://michi-path.blogspot.in/2012/07/three-dynamic-dropdowns-in-liferay.html
If still there are some doubts, follow the following link
http://michi-path.blogspot.in/2012/07/three-dynamic-dropdowns-in-liferay.html