简体   繁体   English

如何在 JSF2.0 中使用导航规则?

[英]How would one use navigation rules in JSF2.0?

I'm trying to wrap my head around navigation rules in JSF2.0.我正试图围绕 JSF2.0 中的导航规则。 If I have a button with an action method, is the purpose of the navigation rule to move me to a 'results' page?如果我有一个带有操作方法的按钮,导航规则的目的是将我移动到“结果”页面吗? This seems too simple I guess, couldn't you just f:ajax and update a result area on the page?我想这似乎太简单了,你不能只 f:ajax 并更新页面上的结果区域吗? What is the real purpose of navigation rules and how can one effectively use them in JSF 2.0?导航规则的真正目的是什么?如何在 JSF 2.0 中有效地使用它们?

Bonus points for metaphors that use ponies.使用小马的隐喻加分。

The point of navigation rules is that they allow the server to decide, based on the data in a request, which view to show next - a results page, an error page, the next of several possible following pages in a workflow, whatever.导航规则的要点是,它们允许服务器根据请求中的数据来决定下一个显示哪个视图——结果页面、错误页面、工作流中几个可能的后续页面中的下一个,等等。

They're not always useful - most applications only have linear workflows and show errors in-page so that you never really need navigation rules.它们并不总是有用 - 大多数应用程序只有线性工作流并在页面中显示错误,因此您永远不需要导航规则。 I've always considered it a bit weird that such an (in my experience) rarely-useful feature became a core concept in Struts and JSF.我一直认为这样一个(根据我的经验)很少有用的特性成为 Struts 和 JSF 的核心概念有点奇怪。 But it would certainly be useful for a workflow with lots of branching logic.但这对于具有大量分支逻辑的工作流肯定会很有用。

As for AJAX - that's a different use case.至于 AJAX - 这是一个不同的用例。 If you're switching to a completely different view, you should do a full update rather than use AJAX.如果要切换到完全不同的视图,则应该进行完整更新,而不是使用 AJAX。

Why not let your pony jump you on this site and find out the basics from a good tutorial:)为什么不让你的小马在这个网站上跳你,并从一个好的教程中找出基础知识:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM