ADF How To Clear or Reset Search Form in Jdev10g
Google Blogger does not allow me to upload attachment so wait for 4 images loaded.
Credits :
Olaf Heimburger
Frank Nimphius
OTN Forum
The problem :
Let say my application based on HR schema. I've search form for employees and departments.
For employee we can search by first name, last name, email and so on.
For departments we can search by department name and manager.
So i enter employee search form and search employee first name Steven. I got 2 records, thats fine.
I leave to another form and now the riddiculous thing are when you come back to employee search form again,
you'll see your previous first name parameter Steven and your previous result which is 2 records.
Thats mean to me Oracle does not clear / reset input value in the form.
I have no idea why Oracle leave the mess like this. Is this a bug or not i don't know.
The solution :
Thanks to Olaf Heimburger article to give me inspiration.
In his blog, Olaf said he got hint from Frank Nimphius. So i gave credit to him too.
Here is original Olaf piece of code :
Its works perfect. But hey i have a lot of search form am i suppose to put that code on my every page ?
Of course not.
Step 1 :
Here is the modified code. I put this into JSFUtils.java :
Step 2 :
And now how can all the search form calling those method ? The key is an interceptor class before and after loading the page
Thanks to OTN forum. So i create class to intercept like this :
Step 3 :
Now the implementation is simple, just add this simple code in each PageDefinition header like this :
Above is the general, if you want to customize you can override onPageLoad and onPageRender method in backing bean.
Just extend the class like this
public class EmployeeSearchForm extends CustomPagePhaseListener.
Remember your PageDefinition is now no longer point to CustomPagePhaseListnener, but point to your backing bean class
which mean EmployeeSearchForm.
My environment :
*. XP SP2
*. JDev 10.1.3.3
*. Oracle Database 11g
|