This content has been marked as final.
Show 3 replies
-
1. Re: what is the preferred way to load smth before the jsf page starts loading
atamur Nov 3, 2008 4:49 PM (in response to atamur)so essentially my qn is: is it possible to write a backing bean for a page which will be invoked right after requestm before jsf kicks in. I don't like the
Factory
approach cuz it requires creation of new unique names for each page :( -
2. Re: what is the preferred way to load smth before the jsf page starts loading
pramod_bs May 26, 2009 5:05 PM (in response to atamur)Do you have a solution for this?
-
3. Re: what is the preferred way to load smth before the jsf page starts loading
brandonsimpson May 26, 2009 8:53 PM (in response to atamur)I don't think that what you think is happening is really happening. I use page actions and to my knowledge they do execute prior to the page being rendered. What is the default scope for blog?
It looks to me like the page param would be creating a blog object directly then setting the id from the blogId parameter. So depending on the scope of that blog instance, maybe that is causing the wierd results. In other words, could it be that your <param> creates a blog object first and then goes out of scope before your <action> executes? My guess is if you set the blogId directly on your BlogAction, you will get the correct result. For example, do
<param name="blogId" value="#{blogAction.blogId}" required="true" />
<action execute="#{blogAction.loadBlog()}" />
then your blogAction could have something like:
private Long blogId;
@Out
private Blog blog;
public void setBlogId(Long blogId)
{
this.blogId = blogId;
}
public void loadBlog() {
blog = entityManager.find(Blog.class, blogId);
}
@SuppressWarnings({"unchecked"})
public List<BlogEntry> getEntries() {
return entityManager
.createQuery("select be from BlogEntry be " +
"where be.blog.id = " + blogId +
"order by be.postDate desc")
.setMaxResults(ONE_PAGE_LIMIT)
.getResultList();
}