If we upgrade to JSF 1.2, we may be able to use @PostConstruct: http://weblogs.java.net/blog/jhook/archive/2007/05/jsf_12_ri_backi.html
Matt On 7/30/07, Safurudin <[EMAIL PROTECTED]> wrote: > With pure JSF, no, with Facelets, it is possible. > > http://www.alyssar.nl/faceletsactionhandler.html > > But as I said, JSF is strange in many ways. The designers of > JSF probably had very outdated browsers with no support for bookmarks, > and never used Google at the time the spec landed, back in the dark ages > of internet :) > > The good news is that this functionality is suppose to come with 2.0. > As someone on a different mailing list pointed out, the designers at Sun > are only human, and unfortunately not exactly masters of getting > everything right the first time. > Look at EJB for example. > > Safurudin > > Matt Raible skrev: > > > How do you execute the action when the page loads? This is not > > possible with JSF 1.1. > > > > Matt > > > > On 7/30/07, Safurudin <[EMAIL PROTECTED]> wrote: > > > >> There seems to be a consensus in the JSF community that the best way to > >> do this is to invoke > >> an action which takes care of actually fetching the data, making the > >> getter merely a POJO-style > >> getter. > >> > >> Eg. > >> > >> public class UserList extends BasePage implements Serializable { > >> private static final long serialVersionUID = 972359310602744018L; > >> > >> private List users; > >> > >> public UserList() { > >> setSortColumn("username"); > >> } > >> > >> // ensure this action is invoked prior to fetching > >> public String openUserList() { > >> users = sort(userManager.getUsers(null)); > >> return "success"; > >> } > >> > >> public List getUsers() { > >> return users; > >> } > >> } > >> > >> I won't argue this is the best solution, but as JSF is strange in many > >> ways far beyond the realm of this issue, > >> I've come to accept it to be a better solution than actually fetching > >> the data from the database multiple times. > >> > >> Safurudin > >> > >> Matt Raible skrev: > >> > >>> I'm OK with changing UserList to be a better example. What do you > >>> suggest we change it to? > >>> > >>> Matt > >>> > >>> > >>> On 7/30/07, Safurudin <[EMAIL PROTECTED]> wrote: > >>> > >>> > >>>> According to Veniamin Goldins and Ed Burns on the following thread: > >>>> > >>>> http://forum.java.sun.com/thread.jspa?threadID=550485&messageID=3919330 > >>>> > >>>> one shoudn't expect getters of managed-beans only to be invoked once > >>>> per request/lifecycle > >>>> > >>>> In Appfuses eg. UserList.java following happens; > >>>> > >>>> public List getUsers() { > >>>> return sort(userManager.getUsers(null)); > >>>> } > >>>> > >>>> As the JSF spec doesn't guarantee that the getters will be called only > >>>> once, this could lead to the same query getting > >>>> executing multiple times during the JSF lifecycle, eg. validate and > >>>> render-response. > >>>> > >>>> It is not critical for such a simple example as in the UserList, but if > >>>> you have a lot of getters on a page, then equally many > >>>> queries can be executed unnecessarily due to this issue (first-hand > >>>> experience) > >>>> > >>>> I believe this should be revised in Appfuse, because this could become a > >>>> potential performance leak if enough objects/beans > >>>> are involved in a single page rendering. Users don't expect appfuses > >>>> examples to do unnecessary query executions. > >>>> > >>>> Any comments are appreciated. > >>>> > >>>> Regards, > >>>> Safurudin Mahic > >>>> > >>>> > >>>> --------------------------------------------------------------------- > >>>> To unsubscribe, e-mail: [EMAIL PROTECTED] > >>>> For additional commands, e-mail: [EMAIL PROTECTED] > >>>> > >>>> > >>>> > >>>> > >>> > >>> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [EMAIL PROTECTED] > >> For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > >> > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- http://raibledesigns.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]