It has been fun to play with lift framework during evenings and really good way to get your thoughts away from work. There are many things that I like about it - especially the templating system is pretty neat.
The creator of lift (David Pollak) mentioned wicket as the inspiration of the lift's templating system so I thought that I should try it. Already with very short experience I can say that it is fun thing to code with and is valuable tool for any Java web developer.
Showing posts with label lift. Show all posts
Showing posts with label lift. Show all posts
Jun 7, 2009
Apr 28, 2009
Chicken and Lift Community
A good reason to try the Lift framework is just the people in the community. They are really, really helpful and nice. I had a bit struggle with the Scala compiler + Lift and it got it solved really quickly with help of the people and the amazing Lift forum. Thanks!
Then something different. I think there is just too few pictures of chicken - that marvelous bird that feed me so many times.
Then something different. I think there is just too few pictures of chicken - that marvelous bird that feed me so many times.
Mar 30, 2009
View's in Lift
I think Lift framework is really interesting and fun thing to play with. Here is my ultra short guide how to try out the framework's Views.
Views are classes that returns content as scala.xml.NodeSeq. Lift maps a browser request to view class and its method. For example /TestView/showme would be mapped to TestView view- class and to showme method. The method name in the request is actually not an actual method in the class - it is a name that is dispatched to the dispatch method of the view class. The method returns a method to handle the request. To make it possible for Lift to find your view classes you sould store them to your.package.view package.
Next we need to tell Lift that we have this View available and allow it to display it. This happens by modifying our SiteMap. Go to your bootstrap.liftweb package and open the Boot class. Then go to the part where the SiteMap is defined. Assuming that you are playing with the skeleton created by the maven archetypes you should modify it to this:
What we have done here? Created a new Menu entry called "TestView". With the part "TestView"::Nil we tell to Lift that map /TestView/* to this link. We have now allowed that /TestView/testPath maps to our TestView class and then to the method inside it. If you don't add the link into the SiteMap then Lift prevents anybody to access the link. It only shows 404 error. This is way to ensure that you as a developer can control what parts should be accessed.
Views are classes that returns content as scala.xml.NodeSeq. Lift maps a browser request to view class and its method. For example /TestView/showme would be mapped to TestView view- class and to showme method. The method name in the request is actually not an actual method in the class - it is a name that is dispatched to the dispatch method of the view class. The method returns a method to handle the request. To make it possible for Lift to find your view classes you sould store them to your.package.view package.
Lets create a simple view that shows simple response in XML. First we need to create the View class. It should be put into your [Package name].view package. Lets call the class TestView:
So the class extends the trait LiftView. It defines the method dispatch that maps the requests with real class methods. In our case we only have testPath that matps to provideTestPath method. That method then returns the NodeSeq.
package your.package.view
import net.liftweb.http.LiftView
import scala.xml.NodeSeq
class TestView extends LiftView {
def dispatch = {
case "testPath" = > provideTestPath _
}
def provideTestPath(): NodeSeq = <html><body>Test</body></html>
}
Next we need to tell Lift that we have this View available and allow it to display it. This happens by modifying our SiteMap. Go to your bootstrap.liftweb package and open the Boot class. Then go to the part where the SiteMap is defined. Assuming that you are playing with the skeleton created by the maven archetypes you should modify it to this:
...
// Build SiteMap
val viewEntry = Menu(Loc("testView",
("TestView" :: Nil) -> true,
"TestView",
Loc.Hidden))
val entries = Menu(Loc("Home", List("index"), "Home")) :: viewEntry :: User.sitemap
LiftRules.setSiteMap(SiteMap(entries:_*))
...
What we have done here? Created a new Menu entry called "TestView". With the part "TestView"::Nil we tell to Lift that map /TestView/* to this link. We have now allowed that /TestView/testPath maps to our TestView class and then to the method inside it. If you don't add the link into the SiteMap then Lift prevents anybody to access the link. It only shows 404 error. This is way to ensure that you as a developer can control what parts should be accessed.
Thats it. Now just point to your server /TestView/testPath and you will see the results!
Mar 5, 2009
Lift me!
It has been a while when I last time played with web coding. After wondering a while - should I start to play more with Google App engine (which is really great stuff), Ruby or go and try some stuff from Java world I bumped into Lift. Lift is a Scala based web framework that promises to do thing differently (surprise, surprise). Because I have long wanted to really dig into Scala I knew that this would be my next playground. Lets see how different it really is...
Subscribe to:
Posts (Atom)


