You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-dev@incubator.apache.org by Adam Winer <aw...@gmail.com> on 2007/04/04 22:36:40 UTC

Re: JBoss Seam & Trinidad integration

On 3/29/07, Peter Muir <pm...@bleepbleep.org.uk> wrote:
> Hi
>
> I've started doing some work on this.
>
> On 02/02/07, Adam Winer <aw...@gmail.com> wrote:
> >  (1) Page in data as necessary, automatically
>
> I'm not entirely sure how this is supposed to be done with the
> CollectionModel.  As we're using JPA what we want is a something like:
>
> // build the query
> query.setFirstResult(10);
> query.setMaxResults(10);
> List list = query.getResultList();
>
> // wrap the result list in a datamodel.
>
> but the CollectionModel isn't updated with paging information - it
> seems to be stored on the component.
>
> Any hints ;)

Well, in theory, you'd do this semi-lazily:  have a fetch
size stored in the model (which, depending on what
sort of caching you have available, might be a
multiple of the row count on the component), and then
on the first request for a particular row, fire the query
off with a heuristic for setFirstResults() and the fetch
size for setMaxResults().

The pain comes if you want to do this aggressively
(e.g., before Render Response).

> >  (2) Report good permanent row keys, so
> >    that adding/removing rows gets picked up
> >    without any off-by-one errors.
>
> It should be possible to use the business key of the entity for this,
> just some problems arise as the EntityManager isn't always available.
>
> >  (3) Perform sorting directly on the model
>
> This works nicely - translating the sort criterion into an order by
> and an order by into a List<SortCriterion>.  Trinidad doesn't seem to
> support a List<SortCriterion> with more than one element however (it
> just displays the little arrow for the first criterion)?

Well, it's certainly great progress to support a single sort criterion.
I do think we should have some UI support for at least displaying
secondary sort criteria, even if there's nothing built in on tr:column
for activating multiple sort criteria straight from the UI.

-- Adam

Re: JBoss Seam & Trinidad integration

Posted by Pete Muir <pm...@bleepbleep.org.uk>.
Hi

I posted the Seam/Trinidad demo announcement on adffaces-user
yesterday which includes what we've discussed here (well, this stuff
is available as jar, the example just uses it).  Thanks for the help
:) A bit of feedback/questions inline.  I can open JIRA issues for
them if you want - let me know.

On 04/04/07, Adam Winer <aw...@gmail.com> wrote:

> Well, in theory, you'd do this semi-lazily:  have a fetch
> size stored in the model (which, depending on what
> sort of caching you have available, might be a
> multiple of the row count on the component), and then
> on the first request for a particular row, fire the query
> off with a heuristic for setFirstResults() and the fetch
> size for setMaxResults().
>
> The pain comes if you want to do this aggressively
> (e.g., before Render Response).

I did this by assuming that maxResults==rows.  This works well (have
to load the query twice, once for render, once for decode, but I can
work around this in Seam given some time).  Of course, if the user
selects to display all rows, then we get lots of little queries
(again, we can work around this and use at most two queries - the
small one, and if it doesn't return enough results, everything).

At the moment this relies on the developer doing something like
rows="#{query.maxResults}" - would you guys consider adding in a
maxResults (or rows or something) property to CollectionModel.
Ideally, setting <tr:table rows="5" would be reflected in the
CollecitonModel, and setting collectionMode.rows=5 would be reflected
in the table rows property, but unidirectional would be ok as well.
If you think this is ok, I'll add a JIRA issue :)

> > >  (2) Report good permanent row keys, so
> > >    that adding/removing rows gets picked up
> > >    without any off-by-one errors.

This works, but I had one oddity - if I returned an object from
getRowKey, the equals method on it wasn't called (breaking stuff like
row disclosure), wheras returning a primitive was fine.  I tried a
very simple wrapper around a primitive (e.g.

public class Foo {

  public String foo;

  // equals method

}
) with no joy.  I can submit a testcase for this if it would help.  I
solved it by returning an index into a collection of objects (the
identifier for the entity).

> I do think we should have some UI support for at least displaying
> secondary sort criteria, even if there's nothing built in on tr:column
> for activating multiple sort criteria straight from the UI.

Ok, well IIRC, when adding a second element to the List of
SortCriterion, there was no visual indicator on the table that I could
notice.

Best

Pete