1

EDITED

I would like to use

 <h:body onload="#{myBean.initialize}"> 

but the function initialize() is not called in my JSF page and I don't undertsand why. Thanks in advance

The structure of the page is

 <html>
   <h:body onload="#{myBean.initialize}"> 
   <p:layout>
   <ui:composition>
       <ui:define>
           <p:layoutUnit>
                <h:form>
                      <p:panel> 
                            <h:panelGrid>
                              .....
                            </h:panelGrid>
                       </p:panel> 
                  </h:form>
           </p:layoutUnit>
     </ui:define>
   </ui:composition>
   </p:layout>
   </h:body>
</html>               

EDITED

I am using

  <p:remoteCommand name="onload" action="#{editUDBean.init}" autoRun="true"/>

just after the

 <h:form>

and this calls the init function

Makoto
  • 825
  • 2
  • 15
  • 40

2 Answers2

1

It should go right after the html tag (or after head of course). Almost every tutorial on templating do it this way, see Mkyong's one for instance.

Petr Mensik
  • 24,455
  • 13
  • 84
  • 111
  • Thanks for your reply. I found it alos but now, my question has slightly changed because now the function is not called when I want to load the page – Makoto Feb 12 '14 at 14:19
0

with

<h:body onload=""> 

you can trigger a javascript function not a java bean method! You can use onload like this:

<h:body onload="alert('onload is called...');"> 
Gio
  • 611
  • 6
  • 10