Should I use f:event or action element in PrettyFaces?

送分小仙女□ 提交于 2019-12-06 06:32:00
Lincoln

The <f:event> and <action> tags seem very similar, but have a few large differences that might influence your decision:

  1. <action> allows you to perform navigation by returning a navigation string.
  2. <f:event> is native JSF and lets you stay portable if you want to switch URL-rewriting tools in the future.
  3. <action> lets you choose which phase to invoke the action via the <action phaseId="..." /> attribute. <f:event> usually always invokes at the same time during RENDER_RESPONSE, after you really need it to invoke if you are using this information in JSF action method or in the INVOKE_APPLICATION phase.

By default, <action>s are invoked after the RESTORE_VIEW phase, but as I said before, you can control this yourself.

Usually I prefer to use <action> because it works without the need for any <f:viewParam> elements, and it also lets me navigate before any lifecycle processing has occurred (keeping things a bit more secure).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!