开发者

best way to implement different views of a same webpage depending on certain attributes in grails

I would like to have different views of a webpage depending on certain attri开发者_如何学Gobutes of an item that I am showing.

This is: if the item is in the category X then I show some sections of the page. In other category I show others.

There is others attributes of the item.

I am aware of the multitenant plugin, but I think that is not what I am looking for.

I am thinking of something that maps a hierarchy of attributes with a particular grails view or layout. Maybe obtaining the name of the layout and view concatening the attributes some how to respect convention over configuration.

But I am concern in maintainability.

Can you give me any pointer?


You have a bunch of options

  1. put the branching logic in a controller, and render different views based on the data
  2. put the branching logic in a gsp, and simply don't render different parts based on the model passed into the gsp

You can make the code clean in either way by making use of templates, to stay DRY.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜