Everyone must have used ADF Faces popup component , this is one of most used container to show information on top of page
In this post i am talking about popup fetch event suppose we have to perform some operation before opening popup like filtering data inside popup . We can do this by capturing popup fetch event, if you have checked af:popUp documentation then you must have seen concept of popupFetchListener
From Docs-
The
So here we will see -
How to use popupFetchListener to filter data inside popup ?
How to execute some operation before opening popup ?
How to call AMImpl method before launching popup?
Let's see implementation part-
Cheere :) Happy Learning
In this post i am talking about popup fetch event suppose we have to perform some operation before opening popup like filtering data inside popup . We can do this by capturing popup fetch event, if you have checked af:popUp documentation then you must have seen concept of popupFetchListener
From Docs-
The
PopupFetchEvent
is one of two server-side popup events
but doesn't have a corresponding client event. The popup fetch event is
invoked during content delivery. This means that the event will only
queue for popups that have a contentDelivery
type of lazy
or lazyUncached
.
Another caveat is that the event will only work when the launch id is
set. This is automatically handled by the af:showPopupBehavior but must
be provided as a popup hint if programmatically shown.
So here we will see -
How to use popupFetchListener to filter data inside popup ?
How to execute some operation before opening popup ?
How to call AMImpl method before launching popup?
Let's see implementation part-
- Create a Fusion Web Application and prepare model using Departments table of HR Schema
- Create a ViewCriteria in Departments ViewObject (For filtering viewObject using DepartmentId) and apply this viewCritria at Application Module level
- Create a page, drop a button and a popup with dialog in it, Drop Departments ViewObject in dialog as ADF Form
- Set content delivery of popup to lazyUncached and create a popupFetchListener in managed bean
- I have added an inputText on page to allow user input for DepartmentId
Create a method in ApplicationModule Impl class that sets value of DepartmentId bind variable and filters Departments ViewObject - Run and check application, put any DepartmentId in inputText and hit open popup button, see popupFetchListener will be called and data will be filtered in popup
To Apply ViewCriteria at AM level- Open ApplicationModule--> Select ViewObject Instance--> Click on edit button at top right side
In new window, Select viewCriteria and shuttle it to selected side. All done :)
Code in AMImpl-
/**Method to set bind variable value in Department ViewObject * @param deparmentId */ public void filterDepartment(Integer departmentId){ ViewObject deptVo=this.getDepartments1(); deptVo.setNamedWhereClauseParam("BindDeptId", departmentId); deptVo.executeQuery(); }
Code in Managed Bean to call AM method-
/** * Generic Method to call operation binding * */ public BindingContainer getBindingsCont() { return BindingContext.getCurrent().getCurrentBindingsEntry(); } /** * Generic Method to execute operation Binding * */ public OperationBinding executeOperation(String operation) { OperationBinding ob = getBindingsCont().getOperationBinding(operation); return ob; } /**PopUp Fetch Listener , will be called on fetch event of PopUp * @param popupFetchEvent */ public void deptPopUpFetchListener(PopupFetchEvent popupFetchEvent) { OperationBinding ob = executeOperation("filterDepartment"); //inputTextDeptIdBind is component binding of inputText that is used to get value ob.getParamsMap().put("departmentId", inputTextDeptIdBind.getValue()); ob.execute(); }
Cheere :) Happy Learning
No comments :
Post a Comment