JavaServerFaces in Action mentions on page 437 that you can register a
phase listerner with a bean. The example shows a bean that refreshes a
list before phase RENDER_RESPONSE. Maybe this helps:
public class MyBean() {
public MyBean() {
LifecycleFactory lifecycleFactory = (LifecycleFactory)
FactoryFinder.getFactory(FactoryFinder.LIFECYLE_FACTORY);
Lifecycle lifecycle =
lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
lifecycle.addPhaseListener(
new PhaseListener() {
public void beforePhase() {
refreshList();
}
public void afterPhase() {
}
publid PhaseId getPhaseId() {
return PhaseId.RENDER_RESPONSE;
}
});
protected void refreshList() {
...
}
...
}
Tom Innes wrote:
> I have a question on how best to handle focus when an error occurs.
>
> I am currently using the Sandbox focus component and have implemented a
> PhaseListener on my backing beans to set focus to the first input component
> that has a message associated with it. On each of my backing beans I have a
> setFocusId and a getFocusId Method.
>
> Consider the following Example
>
> Backing Bean
> CountryQBE
> - getCode
> - setCode
> - getName
> - setName
> - setFocusId
> - getFocusId
>
> CountryForm
> - getCode
> - setCode
> - getName
> - setName
> - setFocusId
> - getFocusId
>
>
> StateForm
> - getCode
> - setCode
> - getName
> - setName
> - setFocusId
> - getFocusId
>
> Say as a Result of Pressing a command button on the CountryForm an Error
> occurs on the nameField. When this happens the PhaseListener Fires on all
> three backing beans and sets the FocusId to the nameFieldId.
>
> Thus the CountryQBE, CountryForm and StateForm backing beans all have their
> focusId property set to nameFieldId.
>
> Is there any way to limit the phase listener to only fire for the current
> form that it is processing?
>
> Tom
>
>
>
>