General question about Action Listener
I just read http://www.laliluna.de/first-java-server-faces-tutorial.html and don't understand one thing: All action listener methods access the session. Why? Take a look at the "deleteBook" method, for instance. Instead of passing the book-ID direktly, its parameter is an event. Why? I mean, could the listBooks.jsp not simply pass the Book-ID as parameter to the method so that the parameter of deleteBook would be ID instead of event? Why is it necessary to access the session in every action listener and pass them events instead of IDs? Thanks Matt
Re: General question about Action Listener
Because this is general code, and the rest of the world doesn't know about your book-ID. But in essence, you're right. This is a major (performance and stability related) issue with JSF: too much stuff going on that is often not needed. And the problem is far more severe than you state now: just keep on studying :-). At this time, you have to choose: live with it, and enjoy the benefits of JSF that do exist; or go for more optimal, less complex code, and do it proprietary. Maybe Struts is an option for you: it has similar issues, but is a lot less intrusive than JSF. One last point: you could use outputLink instead of commandLink/Button to trigger an action on another URL than the page-of-origin, but this actually defies JSF. On 30 Sep 2005, at 11:16, Matthias Klein wrote: I just read http://www.laliluna.de/first-java-server-faces-tutorial.html and don't understand one thing: All action listener methods access the session. Why? Take a look at the "deleteBook" method, for instance. Instead of passing the book-ID direktly, its parameter is an event. Why? I mean, could the listBooks.jsp not simply pass the Book-ID as parameter to the method so that the parameter of deleteBook would be ID instead of event? Why is it necessary to access the session in every action listener and pass them events instead of IDs? Thanks Matt Met vriendelijke groeten, Jan Dockx PeopleWare NV - Head Office Cdt.Weynsstraat 85 B-2660 Hoboken Tel: +32 3 448.33.38 Fax: +32 3 448.32.66 PeopleWare NV - Branch Office Geel Kleinhoefstraat 5 B-2440 Geel Tel: +32 14 57.00.90 Fax: +32 14 58.13.25 http://www.peopleware.be/ http://www.mobileware.be/
RE: General question about Action Listener
Thanks for your quick reply. I still don't understand, though. Why does "general code" have to use the session? Do I have to do the same if I want to write a JSF application with commandLinks that call BackingBean methods? Thanks Matt From: ir. ing. Jan Dockx [mailto:[EMAIL PROTECTED] Sent: Freitag, 30. September 2005 11:28To: MyFaces DiscussionSubject: Re: General question about Action Listener Because this is general code, and the rest of the world doesn't know about your book-ID.But in essence, you're right. This is a major (performance and stability related) issue with JSF: too much stuff going on that is often not needed.And the problem is far more severe than you state now: just keep on studying :-).At this time, you have to choose: live with it, and enjoy the benefits of JSF that do exist; or go for more optimal, less complex code, and do it proprietary. Maybe Struts is an option for you: it has similar issues, but is a lot less intrusive than JSF.One last point: you could use outputLink instead of commandLink/Button to trigger an action on another URL than the page-of-origin, but this actually defies JSF.On 30 Sep 2005, at 11:16, Matthias Klein wrote:I just read http://www.laliluna.de/first-java-server-faces-tutorial.html and don't understand one thing:All action listener methods access the session. Why?Take a look at the "deleteBook" method, for instance. Instead of passing thebook-ID direktly, its parameter is an event. Why?I mean, could the listBooks.jsp not simply pass the Book-ID as parameter tothe method so that the parameter of deleteBook would be ID instead of event?Why is it necessary to access the session in every action listener and passthem events instead of IDs?ThanksMattMet vriendelijke groeten,Jan DockxPeopleWare NV - Head OfficeCdt.Weynsstraat 85 B-2660 Hoboken Tel: +32 3 448.33.38 Fax: +32 3 448.32.66 PeopleWare NV - Branch Office GeelKleinhoefstraat 5B-2440 GeelTel: +32 14 57.00.90Fax: +32 14 58.13.25http://www.peopleware.be/http://www.mobileware.be/
Re: General question about Action Listener
JSF is based on the concept that the component is responsible for decoding itself. Now, the component does not know anything about primary keys or ids" - it just knows that it has bindings to its backing bean. There are several workarounds using Apache MyFaces for this - check out the documentation and examples for saveState, preserveDataModel and forceIdIndexFormula. regards, Martin On 9/30/05, Matthias Klein <[EMAIL PROTECTED]> wrote: > > Thanks for your quick reply. I still don't understand, though. > Why does "general code" have to use the session? > Do I have to do the same if I want to write a JSF application with > commandLinks that call BackingBean methods? > Thanks > Matt > > > > From: ir. ing. Jan Dockx [mailto:[EMAIL PROTECTED] > Sent: Freitag, 30. September 2005 11:28 > To: MyFaces Discussion > Subject: Re: General question about Action Listener > > > Because this is general code, and the rest of the world doesn't know about > your book-ID. > > But in essence, you're right. This is a major (performance and stability > related) issue with JSF: too much stuff going on that is often not needed. > > And the problem is far more severe than you state now: just keep on studying > :-). > > At this time, you have to choose: live with it, and enjoy the benefits of > JSF that do exist; or go for more optimal, less complex code, and do it > proprietary. Maybe Struts is an option for you: it has similar issues, but > is a lot less intrusive than JSF. > > One last point: you could use outputLink instead of commandLink/Button to > trigger an action on another URL than the page-of-origin, but this actually > defies JSF. > > > On 30 Sep 2005, at 11:16, Matthias Klein wrote: > > I just read > http://www.laliluna.de/first-java-server-faces-tutorial.html > > > and don't understand one thing: > > All action listener methods access the session. Why? > > Take a look at the "deleteBook" method, for instance. Instead of passing the > book-ID direktly, its parameter is an event. Why? > > I mean, could the listBooks.jsp not simply pass the Book-ID as parameter to > the method so that the parameter of deleteBook would be ID instead of event? > > Why is it necessary to access the session in every action listener and pass > them events instead of IDs? > > Thanks > > Matt > > > Met vriendelijke groeten, > > Jan Dockx > > PeopleWare NV - Head Office > Cdt.Weynsstraat 85 > B-2660 Hoboken > Tel: +32 3 448.33.38 > Fax: +32 3 448.32.66 > > PeopleWare NV - Branch Office Geel > Kleinhoefstraat 5 > B-2440 Geel > Tel: +32 14 57.00.90 > Fax: +32 14 58.13.25 > > http://www.peopleware.be/ > http://www.mobileware.be/ > -- http://www.irian.at Your JSF powerhouse - JSF Trainings in English and German