简体   繁体   English

Spring MVC 3.0-多种形式还是一种?

[英]Spring MVC 3.0 - multiple forms or one?

I'm building a page that has a search box that will populate a grid on the same page. 我正在建立一个带有搜索框的页面,该搜索框将在同一页面上填充一个网格。 There is also a button the user can select to bring up a "window" (JQuery UI "pop-up" in the same page) that lets the user configure said grid. 用户还可以选择一个按钮来打开一个“窗口”(在同一页面中,JQuery UI“弹出”),该按钮使用户可以配置所述网格。

These are two separate forms but I don't want what was submitted as part of one to undo the other (so when the user submits to change the grid layout the search needs to re-run as well. 这是两种不同的形式,但是我不希望作为一种形式提交的内容撤消另一种形式(因此,当用户提交更改网格布局时,搜索也需要重新运行。

I'd rather not store things in session for this since that brings with it its own issues (search results may be large, shouldn't be saved when the page is re-entered later, etc.). 我不想为此在会话中存储内容,因为这带来了它自己的问题(搜索结果可能很大,以后再输入页面时不应该保存搜索结果,等等)。

I've considered doing "one large form" (ie surrounding all the inputs) for the entire page that is backed by a form backing bean. 我考虑过对由表单支持bean支持的整个页面执行“一种大形式”(即围绕所有输入)。 I would then use which button is clicked to determine the action to take. 然后,我将使用单击哪个按钮来确定要采取的措施。 There will eventually be other buttons on the page as well to add more functionality. 最终页面上还将出现其他按钮,以添加更多功能。 This would be similar to how .NET (non-MVC) handles things. 这将类似于.NET(非MVC)处理事物的方式。

I'm interested in how others may have solved similar challenges. 我对其他人如何解决类似的挑战感兴趣。 Are there potential issues with my approach that I'm not seeing? 我的方法是否存在未见的潜在问题? Better ways that work with the framework? 与框架配合使用的更好方法?

What do you mean with: 你是什​​么意思:

but I don't want what was submitted as part of one to undo the other 但我不希望其中一个提交的内容撤消另一个

. Are you referring to posting the form and loading the whole page, which in turn will "reset" the other form? 您是指发布表单并加载整个页面,而这又将“重置”另一个表单吗?

If that is the case I would still keep one page with two forms and make the posts using Ajax (as you may know jQuery makes this a breeze). 如果是这样的话,我仍然会用两种形式保留一页,并使用Ajax进行发布(您可能知道jQuery使这变得轻而易举)。 Upon receiving a response for either call you will need to update the other form accordingly. 收到任一电话的回复后,您将需要相应地更新其他表格。

Note that you may still have your forms in two separate views if it helps keeping the code clean and then pull their html with Ajax calls into another view. 请注意,如果表单有助于保持代码的清洁度,然后将其带有Ajax调用的html拉到另一个视图,则可能仍在两个单独的视图中保留表单。 But my point is that at the end I would still keep both in one page since it sounds like they depend on each other so updating one when the other changes may be easier this way, 但我的意思是,最后,我仍然将两者都保留在一页中,因为听起来好像它们相互依赖,所以当其他更改可能更容易通过这种方式更新时,

Let me know if I misunderstood your question. 如果我误解了您的问题,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM