- class ShowRoleTagLib {
- int num = 4
- def createAllAction = {attrs, body ->
- println '[ShowRoleTagLib.createAllAction]'
- def allurl = attrs['allurl']
- allurl = allurl.findAll {elem -> !elem.propertyName.startsWith('login') && !elem.propertyName.startsWith('logout') }
- String js = ''
- String mess = ''
- body()
- out << '<table border="1">'
- int size = allurl.size()
- allurl.eachWithIndex {elem, i ->
- ((i % num) == 0) ? out << "<tr>" : out << ""
- out << "<td>"
- out << "<ul> ${g.message(code: elem.propertyName)} "
- elem.getURIs().eachWithIndex {elem1, j ->
- if (elem1.endsWith('**')) {
- js = "changeDisabled('$i$j')"
- mess = g.message(code: elem1)
- out << "<li > <input type='checkBox' id= 'box$i$j' onclick=$js /> <input disabled=true type='hidden' id= '$i$j' name='url' value='$elem1' /> <label for='box$i$j' >$mess</label> </li>"
- }
- }
- out << "</ul> "
- out << "</td>"
- if (i == (size - 1)) {
- for (int x = (i % num + 1); x < num; x++) {
- out << "<td> </td>"
- }
- }
- ((i % num) == num - 1) ? out << "</tr>" : out << ""
- }
- out << '</table>'
- }
- def editAllAction = {attrs, body ->
- println '[ShowRoleTagLib.editAllAction]'
- def allurl = attrs['allurl']
- allurl = allurl.findAll {elem -> !elem.propertyName.startsWith('login') && !elem.propertyName.startsWith('logout') }
- def checkedurls = attrs['checkedurl'].collect {elem ->
- elem.url
- }
- int size = allurl.size()
- String js = ''
- String mess = ''
- body()
- out << '<table border="1">'
- allurl.eachWithIndex {elem, i ->
- ((i % num) == 0) ? out << "<tr>" : out << ""
- out << "<td>"
- out << "<ul> ${g.message(code: elem.propertyName)} "
- elem.getURIs().eachWithIndex {elem1, j ->
- if (elem1.endsWith('**')) {
- js = "changeDisabled('$i$j')"
- mess = g.message(code: elem1)
- if (checkedurls.contains(elem1.toLowerCase())) {
- out << "<li > <input type='checkBox' id= 'box$i$j' onclick=$js checked='checked'/> <input type='hidden' id= '$i$j' name='url' value='$elem1' /> <label for='box$i$j' >$mess</label> </li>"
- } else {
- out << "<li > <input type='checkBox'id= 'box$i$j' onclick=$js /> <input type='hidden' disabled=true id= '$i$j' name='url' value='$elem1' /> <label for='box$i$j' >$mess</label> </li>"
- }
- }
- }
- out << "</ul> "
- out << "</td>"
- if (i == (size - 1)) {
- for (int x = (i % num + 1); x < num; x++) {
- out << "<td> </td>"
- }
- }
- ((i % num) == num - 1) ? out << "</tr>" : out << ""
- }
- out << '</table>'
- }
- def showAllAction = {attrs, body ->
- println '[ShowRoleTagLib.showAllAction]'
- def allurl = attrs['allurl']
- allurl = allurl.findAll {elem -> !elem.propertyName.startsWith('login') && !elem.propertyName.startsWith('logout') }
- def selecturl = attrs['selecturl']
- int size = allurl.size()
- String js = ''
- String mess = ''
- body()
- out << '<table border="1">'
- def urls = selecturl.collect {elem -> //��requestMap�л�õ�urls
- elem.url
- }
- allurl.eachWithIndex {elem, i ->
- ((i % num) == 0) ? out << "<tr>" : out << ""
- out << "<td>"
- out << "<ul> ${g.message(code: elem.propertyName)} "
- elem.getURIs().eachWithIndex {elem1, j ->
- if (elem1.endsWith('**')) {
- mess = g.message(code: elem1)
- if (urls.contains(elem1.toLowerCase())) {
- out << "<li > <input type='checkBox' disabled=true checked='checked' /> <input type='hidden' disabled=true id= '$i$j' name='url' value='$elem1' /> $mess </li>"
- } else {
- //println elem1
- out << "<li > <input type='checkBox' disabled=true /> <input type='hidden' disabled=true id= '$i$j' name='url' value='$elem1' /> $mess </li>"
- }
- }
- }
- out << "</ul> "
- out << "</td>"
- if (i == (size - 1)) {
- for (int x = (i % num + 1); x < num; x++) {
- out << "<td> </td>"
- }
- }
- ((i % num) == num - 1) ? out << "</tr>" : out << ""
- }
- out << '</table>'
- }
- }