Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Search form backing code  RSS feed

 
Vasilis Souvatzis
Ranch Hand
Posts: 81
1
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good morning. Not entirely sure if this is a JSF-related question or Java-related. Please act accordingly if you feel it needs to be moved.

Long story short, I have a search form that searches the DB for users. There are three radio buttons (three f:selctItem inside one p:selectOneRadio) with itemValues "username", "name" and "email". And there's the text box for the search term along with a command button that calls this method. I have done the following and works correctly:

This means I have four methods in the backing bean, each calling one of the four search methods in the EJB. As I said, this works just fine. I'm wondering whether there's a better way of doing this.
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's fine with me. If you want to cut down on the number of the internal private methods you code in the backing bean, your switch could invoke the EJB's "find" methods directly, but that's a matter of taste and whether or not the EJB contains all the code or if there's additional complexity that would bloat the switch method.
 
Vasilis Souvatzis
Ranch Hand
Posts: 81
1
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Silly me, I totally forgot about removing the private methods and directly invoking the EJB :P Now that you mentioned it, I could always move the switch to the EJB and let it return the appropriate query and thus, leaving the backing controller just pass the value through.

The latter seems more business-like to me to be honest. But anyway, since you find it alright I'm set. I may mention the alternative when I present my project.

Cheers :)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!