This content has been marked as final.
Show 2 replies
-
1. Re: accessing EntityManager in java action constructor
michael.yuan Apr 6, 2007 2:17 AM (in response to shasho)Use a page action in pages.xml like this:
<page view-id="/foo.xhtml" action="#{boo.loadData}"/>
... ...
The method is called before your page is rendered. -
2. Re: accessing EntityManager in java action constructor
shasho Apr 7, 2007 1:45 AM (in response to shasho)Many thanks its working but there is a problem with ICEFACE integration
I have a java action bean with the following@Stateful @Scope(SESSION) @Name("productsGrid") public class ProductsGridAction implements ProductsGrid{ @PersistenceContext private EntityManager em; . . . public void LoadData() { if (animalList==null) { // only first time read it from the db animalList = em.createQuery("select a from Animal a order by id") .getResultList(); }
LoadData is called as you suggested
This action bean is connected to the following code in the facelets (XHTML)<ice:selectOneMenu id="animals" value="#{productsGrid.animalID}" > <f:selectItems value="#{productsGrid.animalList}"/> </ice:selectOneMenu>
And it does show the correct list from the database
However, the following code is NOT working from the same faclets page<ice:commandLink actionListener="#{productsGrid.toggleSubGroupAction}"> <ice:outputText value="#{productsGrid.expandText}" /> </ice:commandLink>
Now, if I remove the LoadData from the java action bean the list (ice:selectOneMenu) as expected doest show anything but the (ice:commandLink)works !
What is my problem? Why the LoadData "destroy" the " ice:commandLink"?
If I am calling LoadData from another faclets page everything is working well. Again, my problem is when the faclets is the first page of the site or I cant call him from another faclets (for example when calling it from a flash code)