Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
working
  • Loading branch information
vahidhedayati committed Oct 12, 2016
1 parent 2a79ec1 commit 28521fc
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 9 deletions.
@@ -1,6 +1,7 @@
package ajaxdependancyselectexample

import grails.converters.JSON
import grails.validation.Validateable

import org.springframework.dao.DataIntegrityViolationException

Expand Down Expand Up @@ -45,12 +46,27 @@ class MyContinentController {
def example5() {
println "--> params ${params}"

MyCountry country=MyCountry.get(params.mycountry.id as Long)
MyCity city=MyCity.get(params.mycity.id as long)
MyContinent continent=MyContinent.get(params.mycontinent.id as Long)
render (view: 'example5', model: [params: params,country:country,city:city,continent:continent])
// MyCountry country=MyCountry.get(params.mycountry.id as Long)
// MyCity city=MyCity.get(params.mycity.id as long)
// MyContinent continent=MyContinent.get(params.mycontinent.id as Long)
render (view: 'example5', model: [params: params]) //,country:country,city:city,continent:continent])

}
}

def beanExample(MyBean bean) {
println "-- my values are ${bean.mycountry} vs ${bean.mycity} ${bean.mycontinent}"
println "-- my values are ${bean.mycountry.getClass()} vs ${bean.mycity.getClass()} ${bean.mycontinent.getClass()}"

render (view: 'example5', model: [params: params, country:bean.mycountry,city:bean.mycity,continent:bean.mycontinent])
}

def beanExample2(MyTestBean bean) {
println "-- my values are ${bean.mycountry} vs ${bean.mycity} ${bean.mycontinent}"
println "-- my values are ${bean.mycountry.getClass()} vs ${bean.mycity.getClass()} ${bean.mycontinent.getClass()}"

render (view: 'example5', model: [params: params, country:bean.mycountry,city:bean.mycity,continent:bean.mycontinent])
}


def listCountry() {

Expand Down Expand Up @@ -184,3 +200,9 @@ class MyContinentController {
}
}
}
@Validateable
class MyBean{
MyCountry mycountry
MyCity mycity
MyContinent mycontinent
}
87 changes: 83 additions & 4 deletions grails-app/views/myContinent/example.gsp
Expand Up @@ -22,7 +22,7 @@
A simple two tier relationship requires a call to selectPrimary with result returned to [] of MyCity1 normal select box<br><br>


<form method=post action=example5>
<g:form action="example5">

<g:selectPrimary id="MyCountry1" name="MyCountry1"
domain='ajaxdependancyselectexample.MyCountry'
Expand All @@ -42,7 +42,7 @@ A simple two tier relationship requires a call to selectPrimary with result retu

<g:select name="MyCity1" id="MyCity1" optionKey="id" optionValue="cityName" from="[]" required="required" noSelection="['': 'Please choose Country']" />
<input type=submit value=go>
</form>
</g:form>



Expand Down Expand Up @@ -80,7 +80,7 @@ A simple two tier relationship requires a call to selectPrimary with result retu
A nested relationship of hasMany and fully dependent relationship with belongsTo in 3<br>


<form method=post action=example5>
<g:form action="beanExample">


<g:selectPrimary
Expand Down Expand Up @@ -155,12 +155,91 @@ name="mycontinent.id"


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

<br><br>



<g:form action="beanExample2">


<g:selectPrimary
id="MyContinent2a"
name="mycontinent.id"
domain='ajaxdependancyselectexample.MyContinent'
searchField='continentName'
collectField='id'

domain2='ajaxdependancyselectexample.MyCountry'
bindid="mycontinent.id"
searchField2='countryName'
appendValue=''
appendName='Updated'
collectField2='id'

hidden="hiddenNew"
noSelection="['': 'Please choose Continent']"
setId="MyCountry11a"
value="${params.MyContinent2}"/>






<g:selectSecondary
id="MyCountry11a"
name="mycountry.id"
domain2='ajaxdependancyselectexample.MyCity'
bindid="mycountry.id"
searchField2='cityName'
collectField2='id'


appendValue=''
appendName='Updated'


noSelection="['': 'Please choose Continent']"
setId="MyCity11a"
value="${params.MyCountry11}"/>





<g:selectSecondary
id="MyCity11a"
name="mycity.id"
optionKey="id" optionValue="name"


domain2='ajaxdependancyselectexample.MyShops'
bindid="mycity.id"
searchField2='shopName'
collectField2='id'
appendValue=''
appendName='Updated'


setId="MyShop12a"
noSelection="['': 'Please choose Country 1111']"
/>



<g:select name="MyShop12a" id="MyShop12a"
optionKey="id" optionValue="shopName"
from="[]" required="required" noSelection="['': 'Please choose City']"
/>


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



<pre>

&lt;form method=post action=example5&gt;
Expand Down
11 changes: 11 additions & 0 deletions src/groovy/ajaxdependancyselectexample/MyTestBean.groovy
@@ -0,0 +1,11 @@
package ajaxdependancyselectexample

import grails.validation.Validateable

@Validateable
class MyTestBean {
MyCountry mycountry
MyCity mycity
MyContinent mycontinent

}

0 comments on commit 28521fc

Please sign in to comment.