Seam's injection with factory support would work for you I would believe.

<tr:dataTable value="#{mymodel}" ...>

@Name("doesntMatter")
public class Whatever {

  @In(required=false) @Out(required=false)
  private DataModel mymodel;

  @Factory("mymodel")
  public DataModel createModel() {
     ... load the model here
  }
  // for programmatic access:
  public DataModel getDataModel() {
    if (mymodel == null) {
      mymodel = createModel();
    }
    return mymodel;
  }
}

This would force #{mymodel} to be lazy loaded as needed and backing
beans could use "getDataModel"

You could then also have a on-load function to load this data too if you want.

-Andrew


On 10/20/07, Martin Ahrer <[EMAIL PROTECTED]> wrote:
>
> I'm already using request scope to keep the managed bean qbeController (this
> is the one providing the DataModel) so that data is refreshed every time the
> page is refreshed.
>
> With using the JSF 1.2 <f:view> beforePhase and afterPhase method bindings
> I already try to load data at a very specific phase. I know about jsf-comp,
> shale (does not work with JSF 1.2) and seam, this is almost the same
> solution just different tags or annotations to control the phase and when to
> invoke a specific method. I don't think they would do the trick here!
> Correct me if I should be wrong!
>
> May be I did not state it clearly enough, the problems that I'm fighting are
> a result from restricting data loading to a specific phase. Especially
> delaying data loading to before RENDER_RESPONSE causes the Trinidad table
> not to allow me to click a row and perform a selection method. It simply
> would not create a request! I don't know if this is a Trinidad problem or if
> this is a general issue that results from the JSF life-cycle. As I move data
> loading to the earlier APPLY_REQUEST_VALUES phase the Trinidad table works
> BUT data loading can't be performed properly because the backing bean has
> not yet been refreshed with the query criteria form input :(
>
>
>
> Andrew Robinson-5 wrote:
> >
> > Typically, what I have seen is to store the data in a request scoped
> > member variable. This is used with "if not loaded, load, otherwise use
> > current instance" paradigm.
> >
> > There are 3 libraries that I am aware of that also provide on-load
> > functionality, so that you can load the data before rendering (thus
> > making error handling easier):
> >
> > * jsf-comp on-load
> > * Seam
> > * Shale
> >
> > The simplest way is to store you model directly on the request context
> > from the external request.
> >
> > -Andrew
> >
> >
> >
>
> --
> View this message in context: 
> http://www.nabble.com/-trinidad--what-is-the-proper-lifecycle-phase-for-populating-a-%3Ctr%3Atable%3E-tf4654950.html#a13308254
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Reply via email to