2015-06-01 18 views
0

我使用openFaces的dateChooser並設置了一個模式。 如果我把它放在一個錯誤的值(如:33/33/33),並嘗試提交validationError設置爲true,因爲格式錯誤,但我不知道如何獲取特定的錯誤消息或組件導致驗證錯誤。當openFaces組件中的validationError = true時,具體的驗證錯誤是什麼

這裏是我的代碼的一部分:

<o:dateChooser 
    id="DateColBtnGeneralView" 
    pattern="#{configurationController.defaultDateFormat}" 
    value="#{homeController.firstDate}"> 
    <f:convertDateTime pattern="#{configurationController.defaultDateFormat}"/> 
</o:dateChooser> 

<o:commandButton 
    action="#{homeController.submitDates}" 
    onsuccess="contractClientDialogValidation(event) 
    value="Submit" /> 

function contractClientDialogValidation (event) { 
    if (event.validationError) { 
     alert("I want to show you the right error message according to the wrong value and component"); 
    } 
} 

的validationError設置爲true的情況下,所需的組件爲空或不正確的日期格式的情況下或者在情況下輸入號碼太長等等。

回答

0

驗證錯誤主要與JSF生命週期內的UpdateModelValues和InvokeApplication階段有關。

在你的< h:form />元素中,你可以選擇有一個< h:messages id =「errorMessages」/>標籤。

當ajax請求/響應生命週期完成時,將h:messages />標記渲染到<。

See point 3 of this link

+0

我試圖添加