提升 CRUD“列出所有”问题
我正在尝试遵循此教程。我有一个非空数据库。但该表不会被传播。我尝试调试它:toShow
方法返回正确的记录,在flatMap
的每次迭代中,它都有一个正确的、非空的项目实例,但结果,这个方法返回的是:List(\n{这里有16个空格},\n{这里有16个空格})
。并且该表不会被传播。 我更新的代码如下:
ListCar snippet:
class ListCar {
def list(xhtml: NodeSeq) : NodeSeq = {
toShow.flatMap(car =>
bind("car", xhtml,
"name" -> car.name.is,
"owner" -> car.owner.name
)
)
}
private def toShow = {
Car.findAll();
}
}
list.xhtml:
<table>
<thead>
<tr>
<th>Name</th>
<th>Owner</th>
</tr>
</thead>
<tbody>
<lift:list_car.list>
<tr>
<td>
<car:name/>
</td>
<td>
<car:owner/>
</td>
</tr>
</lift:list_car.list>
</tbody>
</table>
这里可能有什么问题?
I'm trying to follow this tutorial. I've got a non empty db. But the table does not get propagated. I tried debugging it: correct records are returned by the toShow
method, on each iteration of the flatMap
it has a correct, non-empty instance of the item, but the result, this method returns is this: List(\n{16 spaces here},\n{16 spaces here})
. And the table does not get propagated.
My updated code is as follows:
ListCar snippet:
class ListCar {
def list(xhtml: NodeSeq) : NodeSeq = {
toShow.flatMap(car =>
bind("car", xhtml,
"name" -> car.name.is,
"owner" -> car.owner.name
)
)
}
private def toShow = {
Car.findAll();
}
}
list.xhtml:
<table>
<thead>
<tr>
<th>Name</th>
<th>Owner</th>
</tr>
</thead>
<tbody>
<lift:list_car.list>
<tr>
<td>
<car:name/>
</td>
<td>
<car:owner/>
</td>
</tr>
</lift:list_car.list>
</tbody>
</table>
What could be the problem here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅此处的示例(在最底部): http://www.assembla.com/spaces /liftweb/wiki/View_First 。不幸的是我现在无法尝试代码。您可以尝试另外两个选项:
"name" -> car.name.is
与"name" --> car.name
(-->
而不是->
)"name" -> car.name.is
类似于"name" -> SHtml.text(car.name.is)
See example here (in the very bottom): http://www.assembla.com/spaces/liftweb/wiki/View_First . Unfortunately I can't try code right now. You may try two more options:
"name" -> car.name.is
with"name" --> car.name
(-->
instead of->
)"name" -> car.name.is
with something like"name" -> SHtml.text(car.name.is)
我通过编辑 html 文件解决了这个问题:
我没有将
包装在
中,而是将其更改为,并且成功了。
I resolved this one by editing the html file:
instead of wrapping
<tr>
in<lift:list_car.list>
, I changed it to<tr class="lift:listCar.list">
, and it worked.