Discussions
Categories
- 385.5K All Categories
- 5.1K Data
- 2.5K Big Data Appliance
- 2.5K Data Science
- 453.4K Databases
- 223.2K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 47 Multilingual Engine
- 606 MySQL Community Space
- 486 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.2K ORDS, SODA & JSON in the Database
- 585 SQLcl
- 4K SQL Developer Data Modeler
- 188K SQL & PL/SQL
- 21.5K SQL Developer
- 46 Data Integration
- 46 GoldenGate
- 298.4K Development
- 4 Application Development
- 20 Developer Projects
- 166 Programming Languages
- 295K Development Tools
- 150 DevOps
- 3.1K QA/Testing
- 646.7K Java
- 37 Java Learning Subscription
- 37.1K Database Connectivity
- 201 Java Community Process
- 108 Java 25
- 22.2K Java APIs
- 138.3K Java Development Tools
- 165.4K Java EE (Java Enterprise Edition)
- 22 Java Essentials
- 176 Java 8 Questions
- 86K Java Programming
- 82 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 208 Java User Groups
- 25 JavaScript - Nashorn
- Programs
- 667 LiveLabs
- 41 Workshops
- 10.3K Software
- 6.7K Berkeley DB Family
- 3.6K JHeadstart
- 6K Other Languages
- 2.3K Chinese
- 207 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 474 Portuguese
How to call partial trigger on JSFF component from separate managed bean?

eevictim
Member Posts: 319
Guys and Gals,
Using JDev 11.1.1.2.0. Looked on the forums and google. Initial results aren't so great.
Is it possible to call a PPR on a JSFF component from a separate managed bean? It seems calling the FacesContext in this instance calls the root JSPX, which only contains one child: the RichDocument.

Ideas for a workaround?
Edited by: LovettWB on Nov 17, 2010 3:39 AM
Edited by: LovettWB on Nov 17, 2010 4:11 AM
Edited by: LovettWB on Nov 17, 2010 4:12 AM
Using JDev 11.1.1.2.0. Looked on the forums and google. Initial results aren't so great.
Is it possible to call a PPR on a JSFF component from a separate managed bean? It seems calling the FacesContext in this instance calls the root JSPX, which only contains one child: the RichDocument.
UIComponent component = FacesContext.getCurrentInstance().getViewRoot().findComponent("pc1:table1"); if (component != null) { AdfFacesContext context = AdfFacesContext.getCurrentInstance(); context.addPartialTarget(component); }
System.out.println(FacesContext.getCurrentInstance().getViewRoot().getChildCount());Returns 1

Ideas for a workaround?
Edited by: LovettWB on Nov 17, 2010 3:39 AM
Edited by: LovettWB on Nov 17, 2010 4:11 AM
Edited by: LovettWB on Nov 17, 2010 4:12 AM
Best Answer
-
Then maybe this post will help (assuming your fragment is added to the page as a region): http://biemond.blogspot.com/2009/11/find-uicomponent-in-adf-task-flow.html
Answers
-
If not possible, refreshing the entire JSFF would work. This refresh request is being sent from a managed bean connected to a dialog from within the JSFF. i.e. I'm not refreshing a region on a page, but the JSFF itself.
-
Hi,
Bind the component to the managed bean first (in component inspector Advanced > Binding), JDeveloper will create the getter/setter methods for you automatically. After that you can call AdfFacesContext.getCurrentInstance().addPartialTarget(propertyName) to refresh the component.
Regards,
Joonas -
My component is in another, separate, managed bean.
partTable is in bean TableCollectionListeners
My PPR is being called from DialogCollectionListeners
In this instance, how would I grab the handle for the component (partTable) so my DialogCollectionListener bean could "see" it for the AdfFacesContext.getCurrentInstance().addPartialTarget(propertyName)? I thought the ....findComponent("pc1:table1"); command would work, but it doesn't seem to find it.
I apologize. Should have cleared that up in my previous post. -
Then maybe this post will help (assuming your fragment is added to the page as a region): http://biemond.blogspot.com/2009/11/find-uicomponent-in-adf-task-flow.html
-
Looks promising! Thank you for your reply. I'll check it out in the morning, and let you know how it goes. I'm pooped!
-
Thanks! Joonas, you've been a great help.
The code on the page you referenced was close, but the code on a page referenced in the user comments was even better:
http://www.jroller.com/mert/entry/how_to_find_a_uicomponent
My region is located in a facet, which the page you posted doesn't quite cover, but the page above fixed that. Here's the fix below:
In Managed Bean// search for the region ID (or task flow) in the base page UIComponent base = jsfUtils.findComponentInRoot("dynamicRegion"); // now find component ID from within that region UIComponent partTable = jsfUtils.findComponent(base, "partTable"); // call PPR on your found component AdfFacesContext.getCurrentInstance().addPartialTarget(partTable);
In JSFUtils utility class// used to locate region. Could also find any component // located in the base ViewRoot() public static UIComponent findComponentInRoot(String id) { UIComponent component = null; FacesContext facesContext = FacesContext.getCurrentInstance(); if (facesContext != null) { UIComponent root = facesContext.getViewRoot(); component = findComponent(root, id); } return component; } // Recursive method which finds your component within JSFF // regardless of facet or other UIComponents which may have children public static UIComponent findComponent(UIComponent base, String id) { if (id.equals(base.getId())) return base; UIComponent kid = null; UIComponent result = null; Iterator kids = base.getFacetsAndChildren(); while (kids.hasNext() && (result == null)) { kid = (UIComponent) kids.next(); if (id.equals(kid.getId())) { result = kid; break; } result = findComponent(kid, id); if (result != null) { break; } } return result; }
Good stuff to know! -
One more thing.
To do an effective search on a component ID, I believe you have to manually change the component's ID. If you let ADF assign the ID, there's no telling what the ID will become at runtime, which makes for an uncertain search outcome. -
Glad to hear you got it working!
You're safe with JDeveloper generated component IDs (pc1, t1 etc.), but may run into problems if you don't have IDs assigned at design time at all (in which case they get generated at runtime).
This discussion has been closed.