01.開始新的專案

  1. Lift 是視圖先行模式的開發框架
  2. Lift 使用預設的模版來建立專案


Lift project templates


This file contains multiple Lift project templates:
  1. lift_basic
    1. is a basic Lift application with a built-in user class and nice use of Blueprint CSS and HTML5
    2. 包含產生 Users 的 H2 DB檔
  2. lift_xhtml
    1. is a basic Lift application with a built-in user class and nice use of Blueprint CSS and XHTML
  3. lift_blank
    1. is a blank Lift project that does not have any model or CSS
  4. lift_mvc
    1. is a Lift project that uses Lift's MVC support rather than view-first. No model stuff, but Blueprint CSS


.hgignore



#Editor: Kuo, ChaoYi (WisdomFish.ORG)
syntax: glob
# Mac OS
.DS_Store

# Lift
## H2DB
*.db
*.war

# Eclipse conf files
.settings
.classpath
.project
.manager
.externalToolBuilders
## SbtEclipsify
.scala_dependencies

# sbt
target
lib_managed
src_managed
project/boot

# building
null
tmp*
dist
test-output





SBT



#!/bin/sh
java -Xmx512M -Xss2M -XX:+CMSClassUnloadingEnabled -jar `dirname $0`/sbt-launcher.jar "$@"
# chmod u+x sbt


$ sbt update ~jetty-run

There is another Eclipse plugin to create an Eclipse project from an sbt project. See the mailing list post for details.


[info] == jetty-run ==
2011-04-19 20:49:33.729:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
[info] jetty-6.1.22
[info] NO JSP Support for /, did not find org.apache.jasper.servlet.JspServlet
20:49:34.805 [main] DEBUG net.liftweb.mapper.MetaMapper - Initializing MetaMapper for User
20:49:35.257 [main] DEBUG net.liftweb.db.ProtoDBVendor - Created new pool entry. name=ConnectionIdentifier(lift), poolSize=1
20:49:35.307 [main] INFO  net.liftweb.mapper.Schemifier - CREATE TABLE users (id BIGINT NOT NULL AUTO_INCREMENT , firstname VARCHAR(32) , lastname VARCHAR(32) , email VARCHAR(48) , locale VARCHAR(16) , timezone VARCHAR(32) , password_pw VARCHAR(48) , password_slt VARCHAR(20) , textarea VARCHAR(2048) , validated BOOLEAN , uniqueid VARCHAR(32) , superuser BOOLEAN) 
20:49:35.313 [main] INFO  net.liftweb.mapper.Schemifier - ALTER TABLE users ADD CONSTRAINT users_PK PRIMARY KEY(id)
20:49:35.458 [main] INFO  net.liftweb.mapper.Schemifier - CREATE INDEX users_email ON users ( email )
20:49:35.462 [main] INFO  net.liftweb.mapper.Schemifier - CREATE INDEX users_uniqueid ON users ( uniqueid )
20:49:35.468 [main] DEBUG net.liftweb.db.ProtoDBVendor - Released connection. poolSize=1
[info] Started SelectChannelConnector@0.0.0.0:8080
[info] == jetty-run ==
[success] Successful.
[info] 
[info] Total time: 17 s, completed Apr 19, 2011 8:49:35 PM
1. Waiting for source changes... (press enter to interrupt)


....
[info] 
[info] Total session time: 9 s, completed Apr 19, 2011 11:20:13 PM
[success] Build completed successfully.
23:20:14.034 [main] INFO  net.liftweb.db.ProtoDBVendor - Closing all connections
23:20:14.072 [main] INFO  net.liftweb.db.ProtoDBVendor - Closing all connections
23:20:14.073 [main] DEBUG net.liftweb.http.LiftServlet - Destroyed Lift handler.
Kuo-ChaoYis-MacBook:Lift23Demo kuochaoyi$ 




src/main/webapp/*



index.html

<!DOCTYPE html>
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
    <title>Home</title>
  </head>
  <body class="lift:content_id=main">
    <div id="main" class="lift:surround?with=default;at=content">
      <h2>Welcome to your project! - WisdomFish.ORG </h2>
      <p>
        <span class="lift:helloWorld.howdy">
          Welcome to your Lift app at <span id="time">Time goes here</span>
        </span>
      </p>
    </div>
  </body>
</html>

The <lift:surround> element basically tells Lift to find the template named by the with attribute (default, in our case) and to put the contents of our element inside of that template. The at attribute tells Lift where in the template to place our content. In Lift, filling in the blanks like this is called binding, and it’s a fundamental concept of Lift’s template system. Just about everything at the HTML and XML level can be thought of as a series of nested binds.


templates-hidden/default.html

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:lift="http://liftweb.net/">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    <title class="lift:Menu.title">App: </title>
    <style class="lift:CSS.blueprint"></style>
    <style class="lift:CSS.fancyType"></style>
    <script id="jquery" src="/classpath/jquery.js" type="text/javascript"></script>
    <script id="json" src="/classpath/json.js" type="text/javascript"></script>
    <style type="text/css">
/* <![CDATA[ */
.edit_error_class {
  display: block;
  color: red;
}

.sidebar ul {
margin:0;
padding:0;
border-bottom:1px solid #ccc;
}
 

.sidebar ul li {
margin:0;
padding:0;
list-style:none;
border:1px solid #ccc;
border-bottom:none;
}

.sidebar ul li a {
display:block;
padding:3px;
text-indent:30px;
text-decoration:none;
}

.sidebar ul li span {
display:block;
padding:3px;
text-indent:30px;
text-decoration:none;
}

.sidebar ul li a:hover {
background-color: #eee;
}


  /* ]]> */
  </style>
  </head>
  <body>
    <div class="container">
      <div class="column span-12 last" style="text-align: right">
        <h1 class="alt">app<img alt="" id="ajax-loader" style="display:none; margin-bottom: 0px; margin-left: 5px" src="/images/ajax-loader.gif"></h1>
      </div>

      <hr>

      <div class="column span-6 colborder sidebar">
        <hr class="space" >

<span class="lift:Menu.builder"></span>

        <div class="lift:Msgs?showAll=true"></div>
        <hr class="space" />
      </div>

      <div class="column span-17 last">
        <div id="content">The main content will get bound here</div>
      </div>

      <hr />
      <div class="column span-23 last" style="text-align: center">
        <h4 class="alt">
          <a href="http://www.liftweb.net"><i>Lift</i></a> 
 is Copyright 2007-2011 WorldWide Conferencing, LLC.
 Distributed under an Apache 2.0 License.</h4>
      </div>
    </div>
  </body>
</html>



src/main/scala/



  • bootstrap/:啟動專案相關
  • code/
    • comet/
    • lib/
    • model/
    • snippet/
    • view/
src/main/scala/bootstrap/liftweb/Boot.scala
    // where to search snippet
    LiftRules.addToPackages("code")





WEB-INF/web.xml (Filter)

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<filter>
  <filter-name>LiftFilter</filter-name>
  <display-name>Lift Filter</display-name>
  <description>The Filter that intercepts lift calls</description>
  <filter-class>net.liftweb.http.LiftFilter</filter-class>
</filter> 

<filter-mapping>
  <filter-name>LiftFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

</web-app>






Q&A


  • respond JSON?




子網頁 (2): OLD - 1.x The ubiquitous Chat
Comments