You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Po Po <se...@yahoo.com> on 2006/12/11 04:09:25 UTC

how to avoid query datatable

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 www.Answers.yahoo.com.  Try it now.

Re: how to avoid query datatable

Posted by Magnus Sandberg <ma...@devdep.com>.
Hi,

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:

<x:linkForm>
    <t:dataTable transient="true">
	...

	<x:commandLink action="#{XX}" value="here" />
	...
    </t:dataTable>
</x:linkForm>

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.

/Magnus


> 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 www.Answers.yahoo.com.  Try it now.


Re: how to avoid query datatable

Posted by Andrew Robinson <an...@gmail.com>.
1) If your command link is hard-coded, and you don't want to update or
validate the model, use immediate
2) Use output link as you really aren't executing an action so therefore
don't need to use a command link
3) use <t:saveState value="#{yourBean.datalist}" />

-Andrew

On 12/10/06, Po Po <se...@yahoo.com> wrote:
>
> 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 www.Answers.yahoo.com.  Try it
> now.
>