santosh chouhan wrote:
Hello Justinas,
Which one is called first , is there any case possible where Ui component can directly connect to model bean . please any one give the exactly scenario of beans when they come in action.
First called is backingbean. Then bb does some logic, and calls model.
To call model method directly from UI component is bad, because, during page rendering very often bindings are called more than once. You could see that in effect when you put system.out.println("sometext") in BB setter or getter method! Backing beans are helpers, temp value storage for UI component or group of them. They take data from Model beans.

Usually I put BB in request scope, and in constructor I initialize it using calls to Model classes according to request parameters. In that way, model beans are called once per request and backing bean hold values as long as it takes to render page.
From which beans i get my form attribute , please make me clear all step
h:dataTable value="#{myBB.dataModel}"

BB:
private DataModel dataModel;
constructor:
this.dataModel = new ListDataModel(MyModel.getItemList(Contexts.getRequestParam('parent_id'));

where Contexts.getRequestParam is helper function to extract post/get parameter from HttpRequest. MyModel.getItemList() - static method, returning List of items. It encapsulates required SQL and so on.)

hope that clears things up!

Justinas

Reply via email to