掲示板

Dependent Combo Box

thumbnail
11年前 に sheela mk によって更新されました。

Dependent Combo Box

Regular Member 投稿: 111 参加年月日: 12/02/17 最新の投稿
hai..Pls..Let me know how to achieve dependent combo box,

Like selecting Country has to populate regions of country..
11年前 に DarshanKumar N Bhatia によって更新されました。

RE: Dependent Combo Box

Junior Member 投稿: 85 参加年月日: 10/03/02 最新の投稿
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
11年前 に sheela mk によって更新されました。

RE: Dependent Combo Box

Regular Member 投稿: 111 参加年月日: 12/02/17 最新の投稿
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
11年前 に Subhash Shah によって更新されました。

RE: Dependent Combo Box

Junior Member 投稿: 78 参加年月日: 11/11/30 最新の投稿
Hi,

I think following liferay forum post will be helpful
http://www.liferay.com/community/forums/-/message_boards/message/5722974
thumbnail
11年前 に Amit Doshi によって更新されました。

RE: Dependent Combo Box

Liferay Master 投稿: 550 参加年月日: 10/12/29 最新の投稿
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

添付ファイル:

thumbnail
11年前 に sheela mk によって更新されました。

RE: Dependent Combo Box

Regular Member 投稿: 111 参加年月日: 12/02/17 最新の投稿
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
11年前 に sheela mk によって更新されました。

RE: Dependent Combo Box

Regular Member 投稿: 111 参加年月日: 12/02/17 最新の投稿
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
11年前 に Nagendra Kumar Busam によって更新されました。

RE: Dependent Combo Box

Liferay Master 投稿: 678 参加年月日: 09/07/07 最新の投稿
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
11年前 に sheela mk によって更新されました。

RE: Dependent Combo Box

Regular Member 投稿: 111 参加年月日: 12/02/17 最新の投稿
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
11年前 に Emilio José Lamas Fraga によって更新されました。

RE: Dependent Combo Box

Junior Member 投稿: 57 参加年月日: 11/11/29 最新の投稿
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
11年前 に sheela mk によって更新されました。

RE: Dependent Combo Box

Regular Member 投稿: 111 参加年月日: 12/02/17 最新の投稿
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
11年前 に Emilio José Lamas Fraga によって更新されました。

RE: Dependent Combo Box

Junior Member 投稿: 57 参加年月日: 11/11/29 最新の投稿
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
11年前 に sheela mk によって更新されました。

RE: Dependent Combo Box

Regular Member 投稿: 111 参加年月日: 12/02/17 最新の投稿
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??
}
);

添付ファイル:

thumbnail
11年前 に Hitoshi Ozawa によって更新されました。

RE: Dependent Combo Box

Liferay Legend 投稿: 7942 参加年月日: 10/03/24 最新の投稿
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
11年前 に Emilio José Lamas Fraga によって更新されました。

RE: Dependent Combo Box

Junior Member 投稿: 57 参加年月日: 11/11/29 最新の投稿

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
11年前 に sheela mk によって更新されました。

RE: Dependent Combo Box

Regular Member 投稿: 111 参加年月日: 12/02/17 最新の投稿
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
11年前 に Emilio José Lamas Fraga によって更新されました。

RE: Dependent Combo Box

Junior Member 投稿: 57 参加年月日: 11/11/29 最新の投稿
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
11年前 に sheela mk によって更新されました。

RE: Dependent Combo Box

Regular Member 投稿: 111 参加年月日: 12/02/17 最新の投稿
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
11年前 に Priyanka Dhingra によって更新されました。

RE: Dependent Combo Box

Liferay Master 投稿: 501 参加年月日: 11/12/20 最新の投稿
Hi,
check this out...if it helps you
http://www.liferay.com/community/forums/-/message_boards/message/14575500
thumbnail
11年前 に Priyanka Dhingra によって更新されました。

RE: Dependent Combo Box

Liferay Master 投稿: 501 参加年月日: 11/12/20 最新の投稿
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
11年前 に Bhavik Kama によって更新されました。

RE: Dependent Combo Box

Junior Member 投稿: 55 参加年月日: 12/09/24 最新の投稿
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