如何在多表单页面中保留表单数据 [英] How to retain form data in a multi form page

查看:68
本文介绍了如何在多表单页面中保留表单数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究JSF.我有一个具有多种形式的xhtml页面.当我提交一种表单时,如果我对另一种表单进行了一些更改,我就会失去它,因为在提交时,页面正在刷新.我不能使用单一表格.有什么办法可以做.

I am working on JSF. I have an xhtml page with multiple forms. when i am submitting one form, and if i had made some changes on other form i am loosing it, as on submit the page is getting refreshed. I cannot use a single form. is there any way to do.

任何解决方案将受到高度赞赏.

any solution will be highly appreciated.

谢谢!

推荐答案

如果您已经在使用JSF 2.x(您使用XHTML的声明(Facelets)证实了这一点或多或少),则只需提交表单通过ajax.

If you're already using JSF 2.x (your statement that you're using XHTML (Facelets) confirms this less or more), just submit the form by ajax.

只需在表单的命令链接/按钮中添加以下标签即可:

It's a matter of adding the following tag to the command links/buttons of the form:

<f:ajax execute="@form" render="@form" />

这样,当前的<h:form>将由ajax提交,而当前的<h:form>仅将被呈现(更新/刷新).您可以根据需要通过添加其他客户端ID在render属性中指定其他要更新的组件.

This way the current <h:form> will be submitted by ajax and the current <h:form> only will be rendered (updated/refreshed). You can if necessary specify other to-be-updated components in the render attribute by adding other client ID(s).

如果您仍然使用旧的JSF 1.x,则可能需要查看RichFaces的Ajax4jsf子库,该子库基本支持相同的功能.

If you're still on the old JSF 1.x, you may want to look at Ajax4jsf sublibrary of RichFaces which supports basically the same.

这篇关于如何在多表单页面中保留表单数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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