I\'m using a ViewHandler to block all input elements on any accessed page, if certain criteria is met.
This works great for the input elements in the \'primary\' xhtml f
A ViewHandler is the wrong tool for the job. It's intented to create, build and restore views and to generate URLs for usage in JSF forms and links. It's not intented to manipulate components in a view.
For your particular functional requirement, a SystemEventListener on PostAddToViewEvent is likely the best suit. I just did a quick test, it works for me on inputs in composites as well.
public class MyPostAddtoViewEventListener implements SystemEventListener {
@Override
public boolean isListenerForSource(Object source) {
return (source instanceof UIInput);
}
@Override
public void processEvent(SystemEvent event) throws AbortProcessingException {
UIInput input = (UIInput) event.getSource();
if (true) { // Do your check here.
input.getAttributes().put("disabled", true);
}
}
}
To get it to run, register it as follows inside <application>
of faces-config.xml
:
<system-event-listener>
<system-event-listener-class>com.example.MyPostAddtoViewEventListener</system-event-listener-class>
<system-event-class>javax.faces.event.PostAddToViewEvent</system-event-class>
</system-event-listener>