我有這個組件:驗證沒有發射
<ice:form style="width: 45%;" partialSubmit="true" >
<ice:inputText id="cc" required="true" partialSubmit="true" immediate="true"
value="#{userAction.username}">
<f:validator validatorId="passwordValidator" />
<ice:message style="color: red;" id="ageError" for="cc" />
</ice:inputText>
</ice:form>
我已經宣佈在臉上配置驗證:
<validator>
<validator-id>passwordValidator</validator-id>
<validator-class>com.mydomain.seam_icefaces_test.action.PasswordValidator</validator-class>
</validator>
和驗證Java類:
package com.mydomain.seam_icefaces_test.action;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
import org.jboss.seam.faces.FacesMessages;
public class PasswordValidator implements Validator {
@Override
public void validate(FacesContext arg0, UIComponent arg1, Object value)
throws ValidatorException {
String val = (String) value;
if (val.length() == 0)
((UIInput) arg1).setValid(false);
FacesMessages.instance().addToControlFromResourceBundle(arg1.getId(),
"invalid.password");
}
}
我不理解爲什麼當它失去焦點時不會發射......
你有任何ideea?
謝謝。
所以你推送一個提交按鈕,驗證不會觸發? – 2011-02-08 11:42:16
我不推送任何東西... inputText組件的partialSubmit和immediate屬性知道自動執行POST ... – 2011-02-08 11:43:41