0

When a JSF/XPages application starts it reads the faces-config.xml for managed beans, validators etc. Can I manipulate the loaded configuration at runtime? e.g. dynamically add a validator to ensure my custom code will run.

I'm not trying to change the xml file at runtime, but the memory representation after it gets loaded.

XPages uses a JSF 1.x runtime,so JSF 2.0 constructs might not work

stwissel
  • 20,110
  • 6
  • 54
  • 101

1 Answers1

2

Yes, you can add a lot of JSF artifacts which are normally configured in faces-config.xml by among others the Application class as well.

Application application = FacesContext.getCurrentInstance().getApplication();
application.addValidator("fooValidator", "com.example.FooValidator");
// ...

You could do the job in an eagerly initialized application scoped managed bean.

@ManagedBean(eager=true)
@ApplicationScoped
public class Config {

    @PostConstruct
    public void init() {
        // ...
    }

}
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555