URL Mapping Issue

M

manoharan

Guest
In a Grails web application (Grails Version 1.3.7 0 ), it is needed to implement URL Mapping to make some pages SEO friendly. For that we created a URL Mapping class.

Requirement:
There are two searches.
1. Doctor Page
2. Hospital page,

What we have done:

URL Mapping class as follows.

import grails.util.GrailsUtil
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?"{
constraints {
// apply constraints here
}
}

name personList: "/$id?" {
controller = 'doctorProfileDetails'
action = 'doctorprofile'
}

name abc: "/$id?" {
controller = 'hospitalSearch'
action = 'hospitalProfile'
}


"/login/$action"(controller: login)
"/logout/$action"(controller: logout)

"/"(view:"/index")
"500"(view:'/error')
}
}



In the code it is being called from the respective pages as follows.
The value to be displayed is taken from DB Tables.

doctorprofile.gsp

<g:link mapping="personList" params='[id:"{doctorInstance.slug}"]' title="{hospitalAddress}">{doctorInstance.doctorFirstName +" "+ doctorInstance.doctorLastName}
{(doctorInstance.education)? " - " + doctorInstance.education : ""}
</g:link>


hospitalProfile.gsp

<g:link mapping="abc" params='[id:"{hospitalInstance.slug}"]'>
{hospitalInstance.hName}
</g:link>





Problem:

What is happening is the second one (hospital search) is being mapped and the page is being displayed. But when the Doctor search is clicked, the page is broken with an error.

If the second one (Hospital Search) in the URL mapping class is commented, the doctor search will work.

Please advise to sort out this issue.
 
Top