单击commandButton后禁用页面跳转到顶部 [英] Disable page jumping to the top after commandButton is clicked

查看:54
本文介绍了单击commandButton后禁用页面跳转到顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个< h:commandbutton> 类似

<h:commandButton value="Neuer Abschnitt"
styleClass="btn btn-primary btn-info"
action="#{beitragBearbeitenBean.erstelleAbschnitt}" />

好吧,我单击按钮,该方法被调用,然后,页面跳到顶部(前提是您不在顶部!)

Well, I click onto the button, the method is called and after that, the page is jumping to the top (provied you are not at the top!)

有趣的是

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

确实提供了一些跳跃.

通常如何避免跳跃?

推荐答案

< h:commandButton> 不会显示页面的全部内容,也没有ajax内容.因此,跳回到同一页面的顶部是正常的(假设您的操作返回null或为void).< f:ajax> 使其刷新表单,并且很可能跳至表单顶部(如果您使用的按钮也在该表单中).更新表单的某些部分(例如表单内的面板)而不更新按钮,因为它很可能会停留在面板旁,这将导致您停留在同一位置.但是,如果面板的大小发生变化,则可能不会改变(但是,例如,您可以使面板可滚动,以使按钮不会移动).

an <h:commandButton> doess a full post of the page, no ajax stuff. So it is normal to jump back to the top of the same page (assuming your action returns null or is void). The <f:ajax> makes it refresh the form and most likely jumps to the top of the form (if the button you use is also in that form). Updating parts of the form (e.g. a panel inside the form) and not update the button since it can stay ourtside the panel most likely will cause that you stay at the same spot. But if the size of the panel changes, it might not (but then you can e.g. make your pannel scrollable so the button will not move).

这篇关于单击commandButton后禁用页面跳转到顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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