I am not sure if this is the best way, but one idea that could work is
to create a PhaseListener that acts after the view is restored.  In
this phase listener, you could check if the view being restored is the
view for which you want to call your backing bean method.  Then, you
could obtain a MessageBinding object for your backing bean expression
and use that to call your method.

Create YourPhaseListener and register it in faces-config.xml:
<faces-config>
    ...
    <lifecycle>
        <phase-listener>com.yourcompany.YourPhaseListener</phase-listener>
    </lifecycle>
</faces-config>

public class YourPhaseListener implements PhaseListener {

    public void beforePhase(PhaseEvent event) {
        // Nothing to do
    }

    public void afterPhase(PhaseEvent event) {
        FacesContext facesContext = event.getFacesContext();
        UIViewRoot viewRoot = facesContext.getViewRoot();
        String idOfYourPage = ...
        if (viewRoot.getId().equals(idOfYourPage)) {
            Application application = facesContext.getApplication();
            String methodExpression = ...
            Class[] params = ...
            MethodBinding methodBinding =
application.getMessageBinding(methodExpression, params);
            methodBinding.invoke(facesContext, ...);
    }

    public PhaseId getPhaseId() {
        return PhaseId.RESTORE_VIEW;
    }

}

Disclaimer: I haven't tried this code so I don't know if it would work
or even compile.

-Ken

On 8/24/05, Saul Qunming Yuan <[EMAIL PROTECTED]> wrote:
> Thanks for your response. I guess I didn't make me clear here. My question
> is how to call a method in the backing bean from a JSF page without
> rendering out anything to the screen.

Reply via email to