LiftWeb 中带有参数的菜单片段的名称和位置?

发布于 2024-12-09 21:15:03 字数 675 浏览 0 评论 0原文

抱歉,如果这听起来很愚蠢,但我对 LiftWeb 真的很陌生,只是在基本的东西上挣扎:)

​​ 所以我在 Lift 的引导程序中有一个参数化的站点地图条目。这应该用于 MyItem 类型的对象的视图页面。 URL 类似于:“/myitems/UUID”。

Menu.param [UUID]("MyItemView", "MyItemView", p=>Full(UUID.fromString(p)), p=>p.toString) / "myitems"

这会正确添加站点地图条目。如果我转到“/myitems/NOT_AN_UUID”,它将按预期抛出“无效的 UUID”异常。但是,如果我转到“/myitems/UUID”,我会得到 404。

我知道我需要一个视图和一个以 UUID 作为参数的片段类才能使其正常工作,但我不知道如何命名这些和将它们放置在哪里

顺便说一句,Lift 的新手如何学习这样的东西?从数百篇文章和示例中,我发现许多提到了更复杂的东西,但没有看到任何提到像这样的基本东西。 你知道人类的秘密创业文档吗?

更新:总结一下,以防您在上面看到的都是胡言乱语:)如何提升定位参数化菜单条目的模板/视图/片段?

Sorry if this sounds stupid but I'm really new to LiftWeb and just struggling with the basic stuff:)

So I have a parametrized site map entry in Lift's bootstrap. This should be for the view page of an object of type MyItem. The URL would be like: "/myitems/UUID".

Menu.param [UUID]("MyItemView", "MyItemView", p=>Full(UUID.fromString(p)), p=>p.toString) / "myitems"

This adds the sitemap entry correctly. If I go to "/myitems/NOT_AN_UUID", it will throw the "Invalid UUID" exception as expected. But if I go to "/myitems/UUID" I get 404.

I know that I need a view and a snippet class that takes UUID as parameter in order for this to work but I have no idea how to name these and where to place them.

Btw, how would one new to Lift learn something like this? From the hundreds of articles and samples out there I found many to mention more complex stuff but haven't seen any to mention a basic thing like this. Do you know any secret start-up documentation for human beings?

Update: To summarize in case all you see above is jibber-jabber :) HOW DOES LIFT LOCATE TEMPLATES/VIEWS/SNIPPETS FOR PARAMETRIZED MENU ENTRIES?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鹊巢 2024-12-16 21:15:03

这实际上是显而易见的答案。模板名称是从路径中获取的,片段可以是任何你想要的,只要你从模板xml中调用它即可。

我需要习惯所有这些约定而不是配置:) 不过,如果有人告诉您约定是什么,那就太好了。

It was actually the obvious answer. The template name is obtained from the path and the snippet can be whatever you want as long as you call it from the template xml.

I need to get used to all this convention over configuration :) However it would be nice for someone to tell you what is the convention.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文