[英]Clear a JSF form
I am working on an application using JSF and Hibernate. 我正在使用JSF和Hibernate开发应用程序。 The fields on the JSF form are backed by the Hibernate entities. JSF表单上的字段由Hibernate实体支持。
Ex: value=#{bean.entity.value} 例如:值=#{bean.entity.value}
There is a Clear button which should empty all the fields on the form. 有一个清除按钮,它应该清空表单上的所有字段。 There are 3 ways to do this: 有3种方法可以做到这一点:
Which is the most appropriate way to do this? 哪种方法最合适?
If no business is required to calculate the default value I would use JS function to reset fields. 如果不需要任何业务来计算默认值,我将使用JS函数重置字段。 You will save one request to the server. 您将一个请求保存到服务器。 You could also generate JS function by JSF and get the default value from server side. 您还可以通过JSF生成JS函数,并从服务器端获取默认值。 This won't solve the issue on page reload though. 但是,这不能解决页面重新加载的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.