Pass model to main.gsp

View: New views
9 Messages — Rating Filter:   Alert me  

Pass model to main.gsp

by Dean Del Ponte :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is it possible to pass a model to main.gsp?  I would like to render  
some information dynamically.  This information applies to all pages  
of the site.  From what I can see, main.gsp does not have a controller  
associated with it, so I cannot pass it a model.  Is this true?

Thanks,

Dean

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



AW: Pass model to main.gsp

by Daniel J. Lauk-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Dean,

I'd put that stuff in the session object.

Cheers,
DJ
--
Daniel J. Lauk

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Pass model to main.gsp

by Daniel Honig :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I would   not put it in the session object as there is no need
You can create a controller named home and then use URLMappings
  to map /
  to  controller="home"
       action="index"


see the grails user guide for more definitive information about
URLMappings.groovy
holler if you need examples.

On Mon, Jul 21, 2008 at 11:42 PM, Dean Del Ponte <ddelponte@...> wrote:

> Is it possible to pass a model to main.gsp?  I would like to render some
> information dynamically.  This information applies to all pages of the site.
>  From what I can see, main.gsp does not have a controller associated with
> it, so I cannot pass it a model.  Is this true?
>
> Thanks,
>
> Dean
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



AW: Pass model to main.gsp

by Daniel J. Lauk-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Daniel,

If I understand correctly, that would only change the first/default page
from the web-app/index.gsp to views/home/index.gsp (or whatever the home
controller's index action redirects to), wouldn't it?

Although you clearly can use a model with that single page, it would not
make that information available on all sites, would it?

Cheers,
DJ
--
Daniel J. Lauk

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Pass model to main.gsp

by Daniel Honig :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Correct.  Perhaps I missed something or read too fast.
What did you mean by "all sites"

On Tue, Jul 22, 2008 at 2:19 AM, Lauk Daniel <Daniel.Lauk@...> wrote:

> Daniel,
>
> If I understand correctly, that would only change the first/default page
> from the web-app/index.gsp to views/home/index.gsp (or whatever the home
> controller's index action redirects to), wouldn't it?
>
> Although you clearly can use a model with that single page, it would not
> make that information available on all sites, would it?
>
> Cheers,
> DJ
> --
> Daniel J. Lauk
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Pass model to main.gsp

by Dean Del Ponte :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I will try loading the dynamic application in the bootstrap, and then  
access it from the ServletContext.  I think that will provide what I'm  
looking for.

Thanks!

On Jul 22, 2008, at 1:33 AM, Daniel Honig wrote:

> Correct.  Perhaps I missed something or read too fast.
> What did you mean by "all sites"
>
> On Tue, Jul 22, 2008 at 2:19 AM, Lauk Daniel <Daniel.Lauk@...>  
> wrote:
>> Daniel,
>>
>> If I understand correctly, that would only change the first/default  
>> page
>> from the web-app/index.gsp to views/home/index.gsp (or whatever the  
>> home
>> controller's index action redirects to), wouldn't it?
>>
>> Although you clearly can use a model with that single page, it  
>> would not
>> make that information available on all sites, would it?
>>
>> Cheers,
>> DJ
>> --
>> Daniel J. Lauk
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>   http://xircles.codehaus.org/manage_email
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Pass model to main.gsp

by Dean Del Ponte :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Okay... this didn't work.  Any other ideas?

My problem is that views/layouts/main.gsp defines the overall layout  
of the site.  Specifically there is a column on the left which  
contains dynamic content.  It is the same for all pages of the  
website.  It appears that it is not possible to load dynamic content  
in main.gsp.

Thanks,

Dean

On Jul 22, 2008, at 9:16 PM, Dean Del Ponte wrote:

> I will try loading the dynamic application in the bootstrap, and  
> then access it from the ServletContext.  I think that will provide  
> what I'm looking for.
>
> Thanks!
>
> On Jul 22, 2008, at 1:33 AM, Daniel Honig wrote:
>
>> Correct.  Perhaps I missed something or read too fast.
>> What did you mean by "all sites"
>>
>> On Tue, Jul 22, 2008 at 2:19 AM, Lauk Daniel <Daniel.Lauk@...>  
>> wrote:
>>> Daniel,
>>>
>>> If I understand correctly, that would only change the first/
>>> default page
>>> from the web-app/index.gsp to views/home/index.gsp (or whatever  
>>> the home
>>> controller's index action redirects to), wouldn't it?
>>>
>>> Although you clearly can use a model with that single page, it  
>>> would not
>>> make that information available on all sites, would it?
>>>
>>> Cheers,
>>> DJ
>>> --
>>> Daniel J. Lauk
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>  http://xircles.codehaus.org/manage_email
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>   http://xircles.codehaus.org/manage_email
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Pass model to main.gsp

by Jon Gunnip :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Jul 22, 2008 at 8:26 PM, Dean Del Ponte <ddelponte@...> wrote:
>
> My problem is that views/layouts/main.gsp defines the overall layout of the
> site.  Specifically there is a column on the left which contains dynamic
> content.  It is the same for all pages of the website.  It appears that it
> is not possible to load dynamic content in main.gsp.

I use "after" filters for this sort of thing.  It makes content added
to the viewModel available in every view.

layout(uri: "/**") {
    after = {viewModel ->
        viewModel.siteTitle = "My Site"
        ...
    }
}

See http://grails.org/doc/1.0.x/guide/6.%20The%20Web%20Layer.html#6.6.2%20Filter%20Types

HTH,
Jon

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Pass model to main.gsp

by Dean Del Ponte :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Awesome!  That worked.  First time I've heard of the viewModel  :)

On Jul 22, 2008, at 9:32 PM, Jon Gunnip wrote:

> On Tue, Jul 22, 2008 at 8:26 PM, Dean Del Ponte  
> <ddelponte@...> wrote:
>>
>> My problem is that views/layouts/main.gsp defines the overall  
>> layout of the
>> site.  Specifically there is a column on the left which contains  
>> dynamic
>> content.  It is the same for all pages of the website.  It appears  
>> that it
>> is not possible to load dynamic content in main.gsp.
>
> I use "after" filters for this sort of thing.  It makes content added
> to the viewModel available in every view.
>
> layout(uri: "/**") {
>    after = {viewModel ->
>        viewModel.siteTitle = "My Site"
>        ...
>    }
> }
>
> See http://grails.org/doc/1.0.x/guide/6.%20The%20Web%20Layer.html#6.6.2%20Filter%20Types
>
> HTH,
> Jon
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


LightInTheBox - Buy quality products at wholesale price