我已将其添加到我的Boot.scala中
LiftRules.viewDispatch.append({
case List("admin", "categories") => Right(Admin)
})
这是我的 Admin.scala 在 (管理员/视图包)
object Admin extends LiftView{
def dispatch = {
case "add" => editCategory
}
def editCategory(): NodeSeq = {
<lift:embed what="/admin/add_category"></lift:embed>
}
}
这是我add_category模板 -
<lift:surround with="admin" at="content">
<div class="container-fluid" id="main_container">
<lift:Admin:addCategory form="POST" class="form-horizontal">
<fieldset>
<legend>Add Category</legend>
<div class="control-group">
<label class="control-label" for="cat_name">Name</label>
<div class="controls">
<cat:name></cat:name>
</div>
</div>
<div class="control-group">
<label class="control-label" for="cat_desc">Description</label>
<div class="controls">
<cat:desc></cat:desc>
<cat:submit></cat:submit>
</div>
</div>
</fieldset>
</lift:Admin:addCategory>
</div>
</lift:surround>
我正在尝试使用addCategory
方法将其与(管理员/片段包)中的代码片段 -Admin.scala 绑定。
object name extends RequestVar("")
object desc extends RequestVar("")
def addCategory(in: NodeSeq): NodeSeq = {
def doAdd() {
//todo: Save Category
}
bind("cat", in,
"name" -> SHtml.text(name.is, (n: String) => name(n), ("id", "cat_name"), ("class", "input-large")),
"desc" -> SHtml.textarea(desc.is, (d: String) => desc(d), ("id", "cat_desc"), ("class", "input-large")),
"submit" -> SHtml.submit("Save", doAdd, ("class", "btn btn-info"))
)
}
我收到此错误 -
Error processing snippet: admin:addcategory
Reason: Method Not Found
XML causing this error:
<lift:admin:addcategory class="form-horizontal" form="POST">
<fieldset>
<legend>Add Category</legend>
<div class="control-group">
<label for="cat_name" class="control-label">Name</label>
<div class="controls">
<cat:name></cat:name>
</div>
</div>
<div class="control-group">
<label for="cat_desc" class="control-label">Description</label>
<div class="controls">
<cat:desc></cat:desc>
<cat:submit></cat:submit>
</div>
</div>
</fieldset>
</lift:admin:addcategory>
在日志中 -
[net.liftweb.http.LiftRules] - Snippet Failure: SnippetFailure(/admin/categories/add -> ParsePath(List(admin, categories, add),,true,false),Full(admin:addcategory),Method Not Found)
需要这方面的帮助。我无法弄清楚为什么 lift 找不到该方法。
您是否已将admin
包添加到 LiftRules 中?像这样的事情应该允许 Lift 搜索admin.snippets
以查找分辨率:
LiftRules.addToPackages("admin")
另外,我相信您需要将代码片段称为Admin.addCategory
而不是:
。
编辑:
我相信 Lift HTML5 解析器区分大小写,并且在驼峰大小写方法名称方面存在问题。您可能想尝试将方法重命名为全部小写,或者尝试将代码段调用为(而不是使用<lift:
样式):
<div class="lift:admin.addCategory"> ... </div>
or
<div data-lift="admin.addCategory"> ... </div>