JSF h:form标签到底是什么 [英] What exactly does JSF h:form tag

查看:83
本文介绍了JSF h:form标签到底是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以用自己的话来解释h:form到底是如何工作的,这有什么用? 我对JSF完全陌生,并且注意到了奇怪的行为. 假设我有一个按钮可以像这样将我重定向到首页:

Could someone explain in own words how exactly h:form works and what is it good for ? I am completely new to JSF and I noticed strange behaviour. Let's say I have a button which redirect me to home page like this:

h:commandButton value ="back" action ="home?faces-redirect = true"

当我不将此按钮包装到h:form标记按钮中时,它根本不起作用... h:在幕后究竟是什么?我已经阅读了官方文档,但是我不知道我的工作原理...

When I don't wrap this button into h:form tag button simply doesn't work... What exactly do h:form behind the scene ? I have read official documentation but I don't feel that I know how it works...

谢谢

推荐答案

它将<form /> HTML标记放入渲染结果中(将纯HTML发送给客户端).这样做的好处是<h:form />中的所有元素都可以使用POST(或最终GET)请求将信息发送到服务器.

It places <form /> HTML tag into rendered result (pure HTML sent to client). The benefit of this is that all elements inside <h:form /> can use POST (or GET eventually) request to send informations to the server.

<h:commandButton />使用这种请求,因此仅在<h:form />中有效.其他表单元素(如<h:inputText />等)也是如此.这些元素必须包含在<h:form />中,以便用户输入的信息可以发送到服务器并进行处理.

The <h:commandButton /> uses this kind of request so it works only in <h:form />. So do other form elements like <h:inputText /> etc. These elements need to be contained in <h:form /> so information entered by user can be sent to the server and processed.

此外,似乎不是表单元素的其他一些组件也需要使用<h:form />,因为它们会将信息发送到服务器.这样的组件的一个示例可能是PrimeFaces(JSF的扩展库)数据表(<p:dataTable />).

Also, some other components that don't seem to be form elements also need to use <h:form /> because they send information to the server. An example of such component may be PrimeFaces (extension library of JSF) data table (<p:dataTable />).

这篇关于JSF h:form标签到底是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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