Editable datatable field validation when using datascroller pagination
843844Jul 12 2009 — edited Jul 13 2009Hi,
Im using tomahawk-1.1.8 and myfaces-api-1.2.6 I have an editable datatable with each rows having the following set of fields
selectBooleanCheckBox , three selectOneMenus , three outputTexts, three inputTexts
There will be close to 200 rows in the table so im using t:dataScroller to paginate the datatable.
The following are my requirements
1 All elements of the form except the selectBooleanCheckbox must be disabled on load of the page.
2 On clicking on the boolean check box the corresponding rows must be enabled.
3 I should be able to extract only the selected row in the bean side to perform some action and finally save it in the database.
4 On submit of the page I should validate the following.
a. at least one check box is selected
b. Whether all the three intputTexts in the row have values and must also verify if they have valid values.
c. Rows which are not selected (using check box) need not be considered for validation
d. if any invalid data is found appropriate error message must be thrown and that particular element should be given the focus
On seeing the requirement I felt its better to use Javascript to enable/disable controls and to validate data. Everything works fine if I have all the controls in a single page. But since I have server side pagenation enabled (using datascroller) Im able to access only the current page form elements from javascript. In shot Im able to access only the elements which are in the page from where I click on submit.But the user may change data in several pages and finally submit.
This leads me to a situation where validation can be done using JSF only. Im ok to do validations in JSF using a custom validator .But certain things like enabling or disabling controls on the form and the onLoad behavior can be coded using javascript only. This is because if I set the values such as disabled=true on the jsf inputText tag itself it is taking effect every time I move out and come back to the same page.
Im new to JSF . Can someone assist me in this. Its pretty URGENT
.
Thanks,
Swami