views:

628

answers:

1

Hi, Is there a way to execute an action when a page is loaded? (Using JSF 1.2 with ICEFACES)

Cheers.

A: 

Yes, just put the desired logic in the constructor of the bean associated with the JSF page.

public Bean() {
    // Do your stuff here.
}

Alternatively you can also make use of a bean method which is annotated with the @PostConstruct annotation. Such a method will be executed after construction and initialization/setting of all managed properties as definied in faces-config.xml.

@PostConstruct
public void init() {
    // Do your stuff here.
}
BalusC