2
votes

The following code is a simple form used with ajax component:

<h:form id="loginform">
    <h:inputText id="username">
        <f:ajax event="blur" execute="loginform:username loginform:loginbutton" ... />
    </h:inputText>
    <h:inputText id="password">
        <f:ajax event="blur" execute="loginform:password loginform:loginbutton" ... />
    </h:inputText>
    <h:commandButton id="loginbutton" value="login" action="#{indexBean.authentication()}" />
</h:form>  

I understand that execute attribute is a space-separated List of IDs for components that should be included in the Ajax request.

I can access the source component at backing bean with AjaxBehaviorEvent.getComponent() method, but how to access the rest of components?

1

1 Answers

2
votes

It's available by PartialViewContext#getExecuteIds().

FacesContext context = FacesContext.getCurrentInstance();
Collection<String> executeIds = context.getPartialViewContext().getExecuteIds();
// ...

You can then use UIViewRoot#findComponent() to find component by client ID.

for (String executeId : executeIds) {
    UIComponent component = context.getViewRoot().findComponent(executeId);
    // ...
}