驗(yàn)證錯(cuò)誤發(fā)生后,如何使用PrimeFacesAjax填充文本字段?我在視圖中有一個(gè)表單,它為自動完成和GMAP本地化執(zhí)行Ajax部分處理。我的后臺bean實(shí)例化了一個(gè)實(shí)體對象“Address”,并將表單的輸入引用到這個(gè)對象:@ManagedBean(name="mybean")@SessionScopedpublic class Mybean implements Serializable {
private Address address;
private String fullAddress;
private String center = "0,0";
....
public mybean() {
address = new Address();
}
...
public void handleAddressChange() {
String c = "";
c = (address.getAddressLine1() != null) { c += address.getAddressLine1(); }
c = (address.getAddressLine2() != null) { c += ", " + address.getAddressLine2(); }
c = (address.getCity() != null) { c += ", " + address.getCity(); }
c = (address.getState() != null) { c += ", " + address.getState(); }
fullAddress = c;
addMessage(new FacesMessage(FacesMessage.SEVERITY_INFO, "Full Address", fullAddress));
try {
geocodeAddress(fullAddress);
} catch (MalformedURLException ex) {
Logger.getLogger(Mybean.class.getName()).log(Level.SEVERE, null, ex);
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(Mybean.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(Mybean.class.getName()).log(Level.SEVERE, null, ex);
} catch (ParserConfigurationException ex) {
Logger.getLogger(Mybean.class.getName()).log(Level.SEVERE, null, ex);
} catch (SAXException ex) {
Logger.getLogger(Mybean.class.getName()).log(Level.SEVERE, null, ex);
} catch (XPathExpressionException ex) {
Logger.getLogger(Mybean.class.getName()).log(Level.SEVERE, null, ex);
}
}在我在提交時(shí)處理整個(gè)表單之前,自動完成和映射Ajax請求可以很好地工作。如果驗(yàn)證失敗,Ajax仍然工作正常,除非字段Full Address無法在視圖中更新,即使在Ajax請求之后在后臺bean上正確設(shè)置了它的值。如果刷新頁面,驗(yàn)證錯(cuò)誤消息就會消失,Ajax將按預(yù)期完成FullAddress字段。在驗(yàn)證過程中還會發(fā)生另一個(gè)奇怪的行為:我已經(jīng)禁用了表單字段的bean驗(yàn)證,如代碼中所示。這個(gè)工作正常,直到找到其他驗(yàn)證錯(cuò)誤,那么,如果我重新提交表單,JSF將對此字段進(jìn)行bean驗(yàn)證!我想我在驗(yàn)證狀態(tài)中遺漏了一些東西,但是我不知道它有什么問題。有人知道如何調(diào)試JSF生命周期嗎?有什么想法嗎?
驗(yàn)證錯(cuò)誤發(fā)生后,如何使用PrimeFacesAjax填充文本字段?
手掌心
2019-07-13 10:13:15