Anastasios Vlasopoulos
Anastasios Vlasopoulos

Reputation: 1802

How to call a bean method when page loads?

I am wondering how should I call a bean method after page loading. I tried something like this but it did not actually work:

            <p:remoteCommand name="autoRun"
                             action="#{enbBean.getFakeEndListForTesting()}"
                             autoRun="true" update="enbTable"/>

Upvotes: 0

Views: 2323

Answers (3)

&#214;mer Faruk Kurt
&#214;mer Faruk Kurt

Reputation: 570

below link visit. as far as i know xhtml page loading event run !!!

When to use f:viewAction / preRenderView versus PostConstruct?

Upvotes: 0

Predrag Maric
Predrag Maric

Reputation: 24433

Strange, that should work. Any exceptions? This post contains some alternative ways of achieving what you need. The most standard way should be the first suggestion, to use

<h:body>
    <f:ajax event="load" listener="#{bean.onload}" />
</h:body>

with this

public void onload(AjaxBehaviourEvent event) {
    // ...
}

Upvotes: 1

user3655551
user3655551

Reputation: 111

You can use @PostConstruct annotation for this method.

Upvotes: 0

Related Questions