JSF行动与结果属性 [英] JSF Action vs Outcome Attribute

查看:85
本文介绍了JSF行动与结果属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是JSF的新手,正在尝试了解操作与结果属性之间的区别是什么?这不是按钮和命令按钮之间的区别,而是相同按钮标签上的结果属性与操作属性之间的区别.

I'm new to JSF and am trying to understand what the difference is between the action vs the outcome attributes? This is not the difference between buttons and command buttons, but between outcome vs action attributes on the same button tag.

例如,我可以拥有:

<h:button value="Go" outcome="<value>" />

<h:button value="Go" action="<value>" />

我不确定何时使用哪个.另外,如果<value><#{bean.methodThatReturnsStringInNavigationRule}><string literal in navigation rule>,会有所不同吗?

I'm not sure when to use which one. Also, does it make a difference if <value> is <#{bean.methodThatReturnsStringInNavigationRule}> or <string literal in navigation rule>?

谢谢.

推荐答案

区别在于,尽管 action 定义了要执行的服务器方法,而成果指定了一个view-id这将是您页面的目标.您必须根据要实现的目标使用JSF输入:

Difference is that while action defines a server method to be executed, outcome specifies a view-id which will be destination of your page. You must use JSF inputs depending on the goal you're trying to achieve:

  • <h:button outcome="user-management">将您定向到用户管理页面.可以把它想象成一种链接.
  • <h:commandButton action="#{backingBean.goToUserManagement}"如果您在操作方法中返回用户管理" ,其作用与结果相同,但是它允许您将一些逻辑执行到服务器端.它必须嵌入到h:form标记中.
  • <h:button outcome="user-management"> targets you to the user management page. Imagine it as kind of link.
  • <h:commandButton action="#{backingBean.goToUserManagement}" If you return "user-management" in your action method, is doing the same as the outcome but it allows you to execute some logic into the server side. It must be embedded into a h:form tag.

<h:button outcome="user-management"><h:button outcome="#{backingBean.userManagementNavigationResult}">之间也没有区别,只要您的服务器端getter方法返回用户管理"值即可.

Also there's no difference between <h:button outcome="user-management"> or <h:button outcome="#{backingBean.userManagementNavigationResult}">, as far as your server side getter method returns "user-management" value.

这篇关于JSF行动与结果属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆