my dog learned polymorphism
The moose likes JSF and the fly likes Dynamic components and best practice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Dynamic components and best practice" Watch "Dynamic components and best practice" New topic

Dynamic components and best practice

Stefan Ramirez

Joined: Jul 10, 2011
Posts: 11
Hey Ranchers!

Once again I need your help...

I've bound several UIForms in my backing bean and am searching for a possibility to call them by name. Something like getComponent("bindingname");
Any hints on that?
Also for sequential access, I'd like to store those UIForms in a list? At my previous attempts I got NullPointerExceptions whenever I tried to call a form of the list.

If one wants to go for "best practice" would it be better to have very few xhtml pages? Hypothetical, one could implement a whole page in one xhtml file and progressive render the components right?

Thanks in advance,
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

Best practice it to keep it simple. There will be occasion enough for complex solutions when a specific need arises, and if you're starting simple, there will be less likelihood of conflicts with existing constructs.

Simplest of all would be one View definition per webpage, but most of us are looking for a standard page layout for the bulk of the the website, so frequently these days we'll use Facelets templates to define the standard page and reference that layout for the specific page View definition.

Rule #1 in JSF is that any time you find yourself writing code that references anything in the javax.faces packages that isn't either a SelectItem or a DataTable model, you should stop and think. Because there's a good chance you're doing it wrong. JSF is designed to be POJO-based and a lot of effort went into ensuring that you WOULDN'T have a lot of platform-specific code and constructs littering up the place.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Dynamic components and best practice
It's not a secret anymore!