Search Expression Framework
In JSF API, UIComponent#findComponent only accepts id expressions.
In the render/execute attribute of f:ajax, you can also reference components by some special keywords:
In PrimeFaces 3.x, we already improved the findComponent logic by adding some new features like @namingcontainer and PrimeFaces Selectors. PrimeFaces Selectors aka provides the ability to reference components by JQuery selectors e.g. (@(:input:disabled), @(.ui-datatable .ui-panel)).
For PrimeFaces 4.x, we have taken this to the next level. Thomas Andraschko completely over-worked our search expression logic and created a modular framework with new features and enhancements to resolve some problems.
- @composite resolves the closest CompositeComponent parent
- @widgetVar(name) resolves a component by its widgetVar
- @child(index) resolves the nth child
Combinable keywords are also supported;
Sample expressions demo is available at PrimeFaces Showcase.
This expressions can be used for all component in PrimeFaces, not only in the process and update attributes! Ajax, CommandButton, Watermark, Printer and many more!
Some components requires to resolve the UIComponent instance on the server side, so PFS and @widgetVar are not available for all attributes. These are considered as client side expressions only.
- Client side expressions are also NOT safe as server side expressions.
- If a server side expression can’t be resolved, we throw an exception.
- If your selector is wrong, the component will just not be found.