Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC on Lift/Scala

Has anyone tried to do a scala/lift application using MVC instead of view-first?

I know that you can create Controllers/views as:

package test.test.test.view
...
Lots of imports
...
class MvcRocks extends LiftView {
  def dispatch = { 
    case "rule" => ruleDispatch _
    case "bar" => barDispatch _
  }
  def barDispatch(): Box[NodeSeq] = {
        Full(<lift:embed what="/mvc_rucks/bar" />)
  }
}

And this code will be accessible if you add it to the menu(in the boot), even if its hidden as:

val entries = Menu(Loc("Home", List("index"), "Home")) ::
List(Menu(Loc("MvcRock", List("mvc_rocks", "bar"), "Mvc really Rocks", Hidden)))
LiftRules.setSiteMap(SiteMap(entries:_*))

Now, of course this will make it so, you declare every action in the menu, then have a case for each action(per controller) and that would open the "view" (that would be a file in /mvc_rucks/bar.html).

My question is, if you would implement a full mvc, you would need to put all your logic in the action barDispatch, but how would you send those variables to the HTML template? and how would you receive post/get information?

(Notice that if you html code has lift bindings, it will of course act as view-first, even after you did MVC before).

like image 324
DFectuoso Avatar asked Jun 22 '09 23:06

DFectuoso


1 Answers

Since your question is not specific to Lift, I'd recommend you the Playframework. The version 1.1 supports Scala 2.8.

Playframework is totally MVC with a fantastic template engine and allows you to choose freely between java/scala.

And I say: To use Play, you don't need 'nuclear scientist knowledge'. Try it!

like image 141
paulosuzart Avatar answered Oct 19 '22 00:10

paulosuzart