Primefaces tabView executes form validation on tab change

荒凉一梦 提交于 2019-12-04 16:35:36

This is how tabView works. Here are the relevant issues from the PrimeFaces tracker:

As you can see the first one is marked as WontFix. The second is a duplicate but at the end you will see another workaround.

If you read that thread carefully you may notice that some workarounds still exists. Try one of them if you are forced to use tabView. Also consider using PrimeFaces - Wizard if you want to use inputs in different tabs.

If I understand your problem correctly, there is actually a quite simple workaround to prevent the duplicate showing of messages.

Change your growl to the following:

<p:growl id="growl" globalOnly="true" autoUpdate="true" showDetail="true" />

In case you want to add messages from backing bean side you can do that with the following code:

FacesContext.getCurrentInstance()
   .addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "title", "details");

And if you want to be completely safe, you can even specify a for-attribute to the growl, and take that as the first parameter to addMessage.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!