]
Brian Leathem resolved SEAMFACES-109.
-------------------------------------
Resolution: Won't Fix
The ViewConfig API as it stands today provides support for retrieving arbitrary
@annotations stored in the ViewConfig datastore. This seems to be sufficient for now.
Provide a query API to retrieve components from view metadata
-------------------------------------------------------------
Key: SEAMFACES-109
URL:
https://issues.jboss.org/browse/SEAMFACES-109
Project: Seam Faces
Issue Type: Feature Request
Components: UI Components
Affects Versions: 3.0.0.CR1
Reporter: Dan Allen
Priority: Minor
The ViewMetadata API only provides a method for retrieving the collection of
UIViewParameter components. However, this facet can be used for many other components,
such as view actions, view restrictions and so forth. Seam Faces should provide a
convenient query API for retrieving any type of component.
Here is a proposal:
{code:java}
public class ViewMetadataQuery {
public <C extends UIComponent> Collection<C>
findMetadataComponents(UIViewRoot viewRoot,
UIComponentFilter<C> componentFilter) {
UIComponent metadataFacet = viewRoot.getFacet(UIViewRoot.METADATA_FACET_NAME);
if (metadataFacet == null) {
return Collections.<C>emptyList();
}
Collection<C> matches = new ArrayList<C>();
for (UIComponent candidate : metadataFacet.getChildren()) {
if (componentFilter.accepts(candidate)) {
matches.add((C) candidate);
}
}
return matches;
}
}
public class UIComponentFilter<C extends UIComponent> {
public abstract boolean accepts(UIComponent candidate);
}
{code}
It would be used as follows:
{code:java}
@Inject
private ViewMetadataQuery query;
...
Collection<UIViewAction> viewActions = query.findMetadataComponents(viewRoot, new
UIComponentFilter<UIViewAction>() {
public boolean accepts(UIComponent candidate) {
return candidate instanceof UIViewAction;
}
});
{code}
You can simplify this further by providing a version of the method that accepts a type:
{code:java}
Collection<UIViewAction> viewActions = query.findMetadataComponents(viewRoot,
UIViewAction.class);
{code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: