Lift If LocParam 奇怪的行为

发布于 2024-10-09 00:01:33 字数 632 浏览 1 评论 0原文

lift框架中有一个LocParam If。我想知道它是如何工作的。我有一个简单的菜单,其中包含几个项目,如下所示:

val scanning = Menu(Loc("scanning","user" :: "scanning" :: Nil, 
S ? "scanning",LocGroup("user")))

效果很好,但是当我添加 If 时,会出现奇怪的行为。首先, 标签中呈现的标签不正确,它们取自其他 Menu 定义。 (我看到的不是资源键“扫描”的内容,而是 S ?“主页”的内容)。其次,我认为它不起作用,条件应该将 /user/scanning 上的所有访问重定向到 / 因为条件每次都是 false,并且它只是让底层代码片段呈现自身,就好像没有任何条件一样。

val scanning = Menu(Loc("scanning","user" :: "scanning" :: Nil, 
S ? "scanning",LocGroup("user"),If(() => false,() => RedirectResponse("/"))))

there is a LocParam If in lift framework. I'm wondering how it is meant to work. I have a simple menu of several items like this one:

val scanning = Menu(Loc("scanning","user" :: "scanning" :: Nil, 
S ? "scanning",LocGroup("user")))

which works just good, but when I add the If, there is weird behaviour. Firstly, the labels that are rendered in the <a> tag are not correct, they are taken from other Menu definitions. (Instead of the content of resource key "scanning", I see the contents of S ? "homepage"). Secondly, it just doesn't work, I assume, that the condition should redirect all accesses on /user/scanning to / since the condition is false everytime and it just lets the underlying snippet to render itself as if there wasn't any condition.

val scanning = Menu(Loc("scanning","user" :: "scanning" :: Nil, 
S ? "scanning",LocGroup("user"),If(() => false,() => RedirectResponse("/"))))

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

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

发布评论

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

评论(1

尴尬癌患者 2024-10-16 00:01:33
() => false

这告诉电梯永远不会显示您的菜单条目。所以你看到的可能是一个不同的条目......

() => false

That tells lift to never show your menu entry. So what you see is probably a different entry...

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