myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Magnus Sandberg <>
Subject Re: how to avoid query datatable
Date Mon, 11 Dec 2006 14:56:15 GMT


yes I've had the same kind of problem.

The general problem is that the data used when creating the commandLink
must be availible in the next restore-view phase. If the data is not
stored somewhere between requests (in a session-bean or by using
preserveState in t:dataTable) it has to be re-fetched from the database.

When re-fetching or preserving state is not an option some other method
than a commandLink must be used.

One such option would be to use outputLink and handle the request
parameters in the traditional way. While this will work in a lot of
cases I did something different.

What I did was to create a set of components that stores the required
state outside the dataTable, somewhat in the same fashion as the
tomahawk dummyForm does.

It looks like this:

    <t:dataTable transient="true">

	<x:commandLink action="#{XX}" value="here" />

Note that this will work even if the x:commandLink is transient since
x:linkForm is the component responsible for handling events.

This works very nice for me and if this is something that could be
useful for you (or anyone else) just let me know.


> Hello, 
> I've a case using datatable and commandlink.
> my jsp contain a datatable and commandlink. datatable
> and commandlink doesn't have relation.
> <t:datatable>
> ...
> </t:datatable>
> <t:commandlink action="test" value="test"/>
> datatable will bound to property datalist in the
> backbean. the datalist is getting the content from
> query.
> ...
> private List datalist;
> public List getDatalist() {
>   List list = ... //do query to database
>   return list;
> }
> ...
> And the commandlink has static link "test" declare in
> faces-config.xml
> all of this is working properly.
> But my concern is when i click the commandlink, JSF
> also call method getDatalist(). how to prevent this?
> Because this is take a resource.
> Thanks,
> Popo
> ____________________________________________________________________________________
> Any questions? Get answers on any topic at  Try it now.

View raw message