The Artima Developer Community
Sponsored Link

Java Buzz Forum
Rails for the poor Struts guys #2

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
dion

Posts: 5028
Nickname: dion
Registered: Feb, 2003

Dion Almaer is the Editor-in-Chief for TheServerSide.com, and is an enterprise Java evangelist
Rails for the poor Struts guys #2 Posted: Feb 25, 2005 3:27 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by dion.
Original Post: Rails for the poor Struts guys #2
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
Latest Java Buzz Posts
Latest Java Buzz Posts by dion
Latest Posts From techno.blog(Dion)

Advertisement
Brian has written his second part article, Rails for Struts-ters, Part 2: The Views. As the title implies, he goes into detail, comparing the view side of Struts vs. Rails. If you grok Struts, you will understand the rails side from this. It also clears some myths such as "Rails doesn't have SiteMesh capability" which I have heard from quite a few Java developers. Rails Layouts Final thing to look at in views is layouts. The quasi-official tool for this in Struts is Tiles, but I prefer Sitemesh, so will use a sitemesh example. Rails has Layouts, which are the same conceptually as Sitemesh decorators. Here is one <html> <head> <title>Brian and Joy's Wedding</title> <link href="/stylesheets/scaffold.css" rel="stylesheet" type="text/css" /> </head> <body> <%= render_menu %> <%= @content_for_layout %> </body> </html> The layout gets wrapped around any rendered output, with the output going at the <%= @content_for_layout %> point. The easiest way to use a layout for all views is to just have a layout named application.html, and it will be used implicitely. You can explicitely use a layout by declaring it in the controller, a la class GiftController < ApplicationController layout 'scaffold' before_filter :require_logged_in which will have it look for scaffold.rhtml to use as a layout. Sitemesh uses an external XML file to configure these, under typical usage, but it is conceptually the same. Great stuff Brian!

Read: Rails for the poor Struts guys #2

Topic: XML DOM Considered Harmful Previous Topic   Next Topic Topic: [Feb 19, 2005 17:37 PST] 5 Links

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use