Fórumok

Dependent Combo Box

thumbnail
sheela mk, módosítva 11 év-val korábban

Dependent Combo Box

Regular Member Bejegyzések: 111 Csatlakozás dátuma: 2012.02.17. Legújabb bejegyzések
hai..Pls..Let me know how to achieve dependent combo box,

Like selecting Country has to populate regions of country..
DarshanKumar N Bhatia, módosítva 11 év-val korábban

RE: Dependent Combo Box

Junior Member Bejegyzések: 85 Csatlakozás dátuma: 2010.03.02. Legújabb bejegyzések
Hi...

Check this ...

Using Javascript : Link : http://javascript.about.com/library/bl3drop.htm

Using JQuery : Link : http://www.erichynds.com/examples/jquery-related-selects/

Even u can use any jQuery Plugins .


HTH ...

Mr.D
thumbnail
sheela mk, módosítva 11 év-val korábban

RE: Dependent Combo Box

Regular Member Bejegyzések: 111 Csatlakozás dátuma: 2012.02.17. Legújabb bejegyzések
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..

Thanksemoticon
Subhash Shah, módosítva 11 év-val korábban

RE: Dependent Combo Box

Junior Member Bejegyzések: 78 Csatlakozás dátuma: 2011.11.30. Legújabb bejegyzések
Hi,

I think following liferay forum post will be helpful
http://www.liferay.com/community/forums/-/message_boards/message/5722974
thumbnail
Amit Doshi, módosítva 11 év-val korábban

RE: Dependent Combo Box

Liferay Master Bejegyzések: 550 Csatlakozás dátuma: 2010.12.29. Legújabb bejegyzések
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

Mellékletek:

thumbnail
sheela mk, módosítva 11 év-val korábban

RE: Dependent Combo Box

Regular Member Bejegyzések: 111 Csatlakozás dátuma: 2012.02.17. Legújabb bejegyzések
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,emoticon
thumbnail
sheela mk, módosítva 11 év-val korábban

RE: Dependent Combo Box

Regular Member Bejegyzések: 111 Csatlakozás dátuma: 2012.02.17. Legújabb bejegyzések
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 emoticon
thumbnail
Nagendra Kumar Busam, módosítva 11 év-val korábban

RE: Dependent Combo Box

Liferay Master Bejegyzések: 678 Csatlakozás dátuma: 2009.07.07. Legújabb bejegyzések
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
thumbnail
sheela mk, módosítva 11 év-val korábban

RE: Dependent Combo Box

Regular Member Bejegyzések: 111 Csatlakozás dátuma: 2012.02.17. Legújabb bejegyzések
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..
thumbnail
Emilio José Lamas Fraga, módosítva 11 év-val korábban

RE: Dependent Combo Box

Junior Member Bejegyzések: 57 Csatlakozás dátuma: 2011.11.29. Legújabb bejegyzések
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) emoticon

Hope it helps

Regards.
thumbnail
sheela mk, módosítva 11 év-val korábban

RE: Dependent Combo Box

Regular Member Bejegyzések: 111 Csatlakozás dátuma: 2012.02.17. Legújabb bejegyzések
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>
thumbnail
Emilio José Lamas Fraga, módosítva 11 év-val korábban

RE: Dependent Combo Box

Junior Member Bejegyzések: 57 Csatlakozás dátuma: 2011.11.29. Legújabb bejegyzések
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):
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
thumbnail
sheela mk, módosítva 11 év-val korábban

RE: Dependent Combo Box

Regular Member Bejegyzések: 111 Csatlakozás dátuma: 2012.02.17. Legújabb bejegyzések
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
Liferay.Service.registerClass(
Liferay.Service.J,"IndustryCategory  ",
{
//what to add here??

}
);

Liferay.Service.registerClass(
Liferay.Service.J,"Capability  ",
{

//What to add here??
}
);

Mellékletek:

thumbnail
Hitoshi Ozawa, módosítva 11 év-val korábban

RE: Dependent Combo Box

Liferay Legend Bejegyzések: 7942 Csatlakozás dátuma: 2010.03.24. Legújabb bejegyzések
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.
thumbnail
Emilio José Lamas Fraga, módosítva 11 év-val korábban

RE: Dependent Combo Box

Junior Member Bejegyzések: 57 Csatlakozás dátuma: 2011.11.29. Legújabb bejegyzések

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.
thumbnail
sheela mk, módosítva 11 év-val korábban

RE: Dependent Combo Box

Regular Member Bejegyzések: 111 Csatlakozás dátuma: 2012.02.17. Legújabb bejegyzések
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..




&lt;%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui" %&gt;
&lt;%-- &lt;%@page import="database.service.ConcellosServiceUtil"%&gt;
&lt;%@ page import="com.liferay.portal.kernel.exception.SystemException" %&gt; --%&gt;
&lt;%-- &lt;%@ page import="database.model.Concellos" %&gt;
&lt;%@ page import="database.model.Localidade" %&gt;
&lt;%@ page import="database.service.ConcellosLocalServiceUtil" %&gt;
&lt;%@ page import="database.service.LocalidadeLocalServiceUtil" %&gt;
&lt;%@ page import="java.util.List" %&gt; --%&gt;
&lt;%@ page import="com.liferay.portal.theme.ThemeDisplay" %&gt;
&lt;%@ page import="com.liferay.portal.kernel.util.WebKeys" %&gt;
&lt;%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %&gt;

//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> -->


&lt;%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %&gt;

<portlet:defineobjects />

&lt;% 
ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
themeDisplay.setIncludeServiceJs(true);
%&gt;

<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>

&lt;%




/*
//TESTING THE METHODS FROM SERVICE BUILDER
List<localidade> locs = LocalidadeLocalServiceUtil.localidadesPorMunicipio(1);
for (int i = 0; i &lt; 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 &lt; concellos.size(); i++){
	System.out.println("LOC: "+concellos.get(i).getNombre());
}
*/

%&gt;

	    <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: '&lt;%= 1 %&gt;'
					},					{
						select: '<portlet:namespace />Localidad',
						selectData: Liferay.Localizaciones.getLocs,
						selectDesc: 'nombreloc',
						selectId: 'localidadId',
						selectVal: '&lt;%= 1 %&gt;'
					}
				]
			);
		</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: '&lt;%= 1 %&gt;'
					},
					{
						select: '<portlet:namespace />addressRegionId',
						selectData: Liferay.Address.getRegions,
						selectDesc: 'name',
						selectId: 'regionId',
						selectVal: '&lt;%= 1 %&gt;'
					}
				]
			);
		</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..
thumbnail
Emilio José Lamas Fraga, módosítva 11 év-val korábban

RE: Dependent Combo Box

Junior Member Bejegyzések: 57 Csatlakozás dátuma: 2011.11.29. Legújabb bejegyzések
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. emoticon

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 emoticon

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!
thumbnail
sheela mk, módosítva 11 év-val korábban

RE: Dependent Combo Box

Regular Member Bejegyzések: 111 Csatlakozás dátuma: 2012.02.17. Legújabb bejegyzések
Hai..Thanks for reply..

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..
thumbnail
Priyanka Dhingra, módosítva 11 év-val korábban

RE: Dependent Combo Box

Liferay Master Bejegyzések: 501 Csatlakozás dátuma: 2011.12.20. Legújabb bejegyzések
Hi,
check this out...if it helps you
http://www.liferay.com/community/forums/-/message_boards/message/14575500
thumbnail
Priyanka Dhingra, módosítva 11 év-val korábban

RE: Dependent Combo Box

Liferay Master Bejegyzések: 501 Csatlakozás dátuma: 2011.12.20. Legújabb bejegyzések
Hi,
If still there are some doubts, follow the following link
http://michi-path.blogspot.in/2012/07/three-dynamic-dropdowns-in-liferay.html
thumbnail
Bhavik Kama, módosítva 11 év-val korábban

RE: Dependent Combo Box

Junior Member Bejegyzések: 55 Csatlakozás dátuma: 2012.09.24. Legújabb bejegyzések
Can any one guide me about this this drop down list box not showing value fetched from database..here goes my problem link..http://www.liferay.com/community/forums/-/message_boards/message/16983953