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 Peter Muir <pm...@bleepbleep.org.uk> on 2007/03/29 14:24:53 UTC

Re: JBoss Seam & Trinidad integration

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 ;)

>  (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)?


>
> -- Adam
>
>
> On 2/1/07, Peter Muir <pm...@bleepbleep.org.uk> wrote:
> >
> > Hello there,
> >
> > I'm hoping to do some work to improve the integration of Seam and
> > Trinidad.  I've tried to explain the various Seam specific bits but
> > I'm very happy to clarify :)
> >
> > Firstly, issues that I know of (and have been reported by Seam users):
> >
> > * Seam has a tag validateAll, which traverses down the JSF component
> > tree looking for UIInput components and adding a validator to them
> > (just saves you having to add the validator to each UIInput).  This
> > can be fixed in Seam (http://jira.jboss.org/jira/browse/JBSEAM-501)
> >
> > * There is a problem outjecting (this is Seam's way of making an
> > object available in JSF) a Trinidad TreeModel (none of the children
> > appear). It works quite happily (for example) if you outject an
> > object, and then convert it to a (ChildProperty)TreeModel in a
> > facelets function.  Anyone got any ideas? Or do I need to dig into
> > this ;)
> >
> > * Seam uses some EL enhancements (by Stan Silvert) to allow passing of
> > method parameters.  These don't work when you use Trinidad BUT I don't
> > think this is worth fixing as there is supposed to be an enhancement
> > to EL (by Jacob Hookom) becoming available that will allow method
> > parameters to work anyway
> > (http://jira.jboss.org/jira/browse/JBSEAM-697)
> >
> > Secondly, a few ideas for making the two frameworks work better
> > together - my suggestion is to distribute these with Seam as
> > jboss-seam-trinidad.jar - an optional jar you could include in your
> > project to get this extra functionality.
> >
> > 1) @TreeModel & @TreeModelSelection
> >
> > The idea here is that in your Java code you could do something like
> >
> > @TreeModel(childProperty="children")
> > private List<Foo> foo;
> >
> > and then, in your view, it would be magically converted to a tree
> > model.  Further, when an action is called from the view, if one of the
> > nodes of the tree was selected, a property annotated with
> > @TreeModelSelection would contain the object representing the node.
> > This already works with datamodels so should be straightforward.
> >
> > 2) Data paging: Seam includes the ability to page through a query,
> > only retrieving that pages worth of records from the persistence layer
> > BUT it requires quite a lot of controls on the front end.  Trinidad
> > has good paging controls BUT will load all the data and then page in
> > JSF.  It would be good to get the best of both and make trinidad
> > request only the records it needs.  My initial ideas about achieving
> > this are:
> >
> > add in some sort of PagingController which Seam could override to do its
> > paging
> >
> > or
> >
> > Use the existing-in-Trinidad RangeChangeEvent to alter query parameters
> >
> > 3) Perhaps an @MenuModel annotation (similar to treemodel)
> >
> > Thirdly, once you guys have any sort of release out (that we can say
> > to Seam users - use this version), we'll add an example of using
> > Trinidad and Seam to the set of Seam examples.
> >
> > I'd like to hear of any incompatibilities you know about and any other
> > integration ideas you guys have :)  Also, it would be great to hear
> > how close the areas I've mentioned above are to being in their final
> > form or whether there is a lot of refactoring to do.
> >
> > I'm tracking this via http://jira.jboss.org/jira/browse/JBSEAM-754
> >
> > Thanks
> >
> > Pete
> >
>

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

Re: JBoss Seam & Trinidad integration

Posted by Adam Winer <aw...@gmail.com>.
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