English 中文(简体)
仅在验证成功时才能执行 a4j: commandLink 的完整操作?
原标题:How to execute a4j:commandLink oncomplete only when validation has succeed?

I am using JSF2, Richfaces4 and Spring. I have a command link. On execute I save records and on complete I execute search to display records like following code. Problem is that fireSearch() in oncomplete executes even if there is a validation error in form. I need to execute fireSearch() only when the record get saved successfully.

只有在验证成功之后 我才能完全完成呢?

<a4j:commandLink styleClass="button" action="#{myBean.save}" render="detail_form" execute="@form" oncomplete="fireSearch()">
<span> Save </span>
</a4j:commandLink>
最佳回答

Richfaces 支持在 oncompreful 属性中基于请求的 EL 评估。 因此您应该能够打印 < a href=" http://docs.oracle.com/javaee/6/api/javax/faces/context/facesContext.html#isValidationFailed% 28%29"\\\ code> facesContext#isvalidationFailed () , 仿佛它是 JS的条件一样。

例如,

oncomplete="if (#{!facesContext.validationFailed}) fireSearch()"

如果审定失败,最终将导致

oncomplete="if (false) fireSearch()"

因此,该函数不会被援引。

问题回答

暂无回答




相关问题
Bind Button.IsEnabled to custom validation with XAML?

I am sorry I didn t know how to title my question any better, you name it if you got a good 1. I have an entity Contact. this person has navigation properties: Address, Phones (A collection of Phone)....

WPF - MVVM - NHibernate Validation

Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...

Wpf Combobox Limit to List

We are using Wpf Combobox to allow the user to do the following things: 1) select items by typing in the first few characters 2) auto complete the entry by filtering the list 3) suggesting the first ...

Rails 101 | validates_currency?

I ve searched high and low, but I could not find a solution, to what I think seems like a very common task. In a form I want to have a text input that accepts currency strings (i.e. $1,000,000 or ...

CodeIgniter form verification and class

I m using the form validation library and have something like this in the view <p> <label for="NAME">Name <span class="required">*</span></label> <?...

热门标签