Pravin
Pravin

Reputation: 471

Grails URLMapping multiple views

This is a continuation to the question : Grails multiple views implementation

I am trying to combine two grails application ( 2 domains combined, 2 controllers combined, 2 views NOT able to combine)

So, I tried various code snippets with "g:link" which are not working still. I have two views : "index.gsp" & "pagetype.gsp". I want to display "index.gsp" first and then after clicking on a hyperlink it should go to "pagetype.gsp" How do I do this?

I tried as follows: Now, I went into "UrlMappings.groovy" and understood how the main index.gsp is accessed by this line :

"/"(view:"/index")

This is the default view, so I changed this to :

"/"(view:"/pagetype")

And now, it loads the second view as the default view successfully.

But, I want the "pagetype.gsp" to be loaded after clicking on a hyperlink so I tried :

"/."(view:"/pagetype")

And in index.gsp code :

<a href="/." class="myButton">Pagetype view</a>

But, this is not working.

All approaches/suggestions are most welcome.

Upvotes: 0

Views: 164

Answers (1)

MKB
MKB

Reputation: 7619

Add link in gsp like:

<a href="pagetype">Click Here</a>

and update UrlMappings:

"/"(view:"/index")
"/pagetype"(view:"/pagetype")

assuming you have pagetype.gsp in parallel of index.gsp in views.

Upvotes: 1

Related Questions