Skip to content

Auto Complete with No Reference

Vahid H edited this page Mar 2, 2014 · 2 revisions

Auto Complete with No Reference

In this example we have :

continent -< hasMany Countries [ Countries has belongsTo continent:continet ]
countries -< hasMany Cities [ Cities has belongsTo country:country ]
Cities -< hasMany Boroughs - [ Boroughs has belongsTo cities ]


Try Europe United Kingdom and London and Camden


Classes:

class MyContinent {
..
	static hasMany=[mycountry: MyCountry]

}
class MyCountry {
..
	MyContinent mycontinent
	static hasMany=[mycity: MyCity]
}

class MyCity {
..
	MyCountry mycountry
	static hasMany=[myborough: MyBorough, shops:MyShops]
}

class MyBorough {
..
	static belongsTo = [MyCity]
	static hasMany=[streets: Streets]
}

The no reference is the binding of MyCity in the belongsTo of MyBorough, here is how it is called:

<form method=post action=example5>
<label>Continent:</label>
<g:autoCompletePrimary id="primarySearch1"  
name="NAMEOFcontinentName"
domain='ajaxdependancyselectexample.MyContinent'
searchField='continentName'
collectField='id'
setId="secondarySearch2"
hidden='hidden3'
value=''/>

<input type=hidden id="hidden3" name="continentId" value=""/>

<label>Country:</label> 
<g:autoCompleteSecondary id="secondarySearch2" 
name="NAMEOFcountryName" 
domain='ajaxdependancyselectexample.MyCountry' 
primarybind='mycontinent.id' 
hidden='hidden3' 
hidden2='hidden4' 
searchField='countryName' 
collectField='id'
setId="secondarySearch3" 
value=''/>

<input type=hidden id="hidden4" name="countryId" value=""/>

<label>City:</label>
<g:autoCompleteSecondary id="secondarySearch3" 
name="NAMEOFcityName" 
domain='ajaxdependancyselectexample.MyCity' 
primarybind='mycountry.id' 
hidden='hidden4' 
hidden2='hidden5' 
searchField='cityName' 
collectField='id' 
setId="secondarySearch4"
value=''/>

<input type=hidden id="hidden5" name="cityId" value=""/>

<label>Borough:</label>
<g:autoCompleteSecondaryNR id="secondarySearch4" 
name="NAMEOFBorough" 
domain='ajaxdependancyselectexample.MyCity' 
domain2='ajaxdependancyselectexample.MyBorough' 
primarybind='myborough' 
hidden='hidden5' 
hidden2='hidden6' 
searchField='actualName' 
collectField='id' 

value=''/>

<input type=hidden id="hidden6" name="BoroughID" value=""/>

<input type=submit value=go> </form>

Clone this wiki locally