Calling session facade methods from my code
513155Aug 23 2006 — edited Aug 23 2006My application consists of two projects: Interface and Model. Model, of course, is used for access to a database using TopLink with POJOs and session facade bean...Pretty much like thing done int tutorial. While, naturally, Interface project are the web pages etc. Standard web application.
Now, there is no problem with using data controls from session facade bean (drag and drop to the form for making tables, lists, forms etc.), that works fine.
What I need is to use methods from my session facade bean in my code. For example, I have made a TopLink query findAllLabels. It is exposed in session facade bean UtilBean so in the bean the code is
List<Labels> findAllLabels(){
...
}
So In some part of my code (for instance, in some backing bean) I would like to call this query. I have done this:
UtilBean util=new UtilBean();
List<Labels> labels=util.findAllLabels();
And this works fine, for now. But, I'm wondering, is this the correct solution, and is there some more ellegant and correct way to do this? Is it correct to instantiate a session facade bean in this way?