Johan Compagner wrote:
> 
> I don't know the exact details of your model hierachy and where you use
> them
> in your components.
> But am i right that you do sorting in memory?
> So 1 model is loading the rows
> another model is sorting the rows?
> and another is doing X?
> 
yes, that's it, roughly.


Johan Compagner wrote:
> 
> But what do you give to the component then? And why must is wrap?
> 
> johan
> 

I don't know if you'll be able to see it from this description, but here is
a specific scenario.

SortingModel (IChainingModel) -> AppendingListModel
(IComponentAssignmentModel) -> HibernateListModel (database oriented model
that returns a list of items from the db, unsorted).

Let's say that the base List model returns a list of ACTIVE items from the
db, over time it is possible for an item to become inactive.  So, if you
were to view an old record, the DropdownChoice wouldn't have the (now
inactive) item in it's list of choices even though the model object for the
dropdownchoice would have the object.  So, the AppendingListModel ensures
that the object associated with a dropdownchoice is in the list, even if it
didn't come from the database.  In order to do that, the model needs to be
IComponentAssignmentModel so that it can get access to the component (and
therefore the component's modelobject).  Then the SortingModel, takes the
effective list and sorts it with a specified comparator.

I was able to make a Model that implements IChainingModel,
IComponentAssignmentModel, and IWrappedModel that follows the chain until it
either encounters a IComponentAssignmentModel or exhausts the chain.  If it
found a IComponentAssignmentModel, then it calls wrapOnAssignment and calls
setChainedModel on the model containing the IComponentAssignmentModel to get
it back into the hierarchy.

It appears to be working for me now.  If you are interested, I can post the
code.

Chuck

On 11/6/07, ChuckDeal <[EMAIL PROTECTED]> wrote:
>
>
>
> Johan Compagner wrote:
> >
> > But if it traverses and then call wrapOnAssignment on the first one it
> > finds
> > what do all the chained models do then? Why are they there? Because
> > from that moment on those chained are completel gone. They could even be
> > gc'ed
> > So this only works if getObject from them are doing nothing more then
> > calling getObject from chained.
> >
>
> Couldn't you then call setChainedModel on the "parent" of the
> IComponentAssignedModel passing in the model returned from
> wrapOnAssignment?
> Or would that be to intrusive/destructive on the original model?
>
>
> Johan Compagner wrote:
> >
> > What you could do is let all your chained models also implement
> > IComponentAssignedModel
> >
>
> Are you proposing that I implement the interface and delegate to the first
> IComponentAssignedModel in my chain?  What if I don't have an
> IComponentAssignedModel in my chain?
>
> I'll play with that idea and see what happens.  Does this seem like the
> right approach to adding sorting capabilities to a model?
>
> Chuck
>
>
> johan
>
> On 11/6/07, ChuckDeal <[EMAIL PROTECTED]> wrote:
> >
> >
> > I have DropDownChoice objects where I want the choices model to be
> sorted.
> > The choices come from a database (using a HibernateListModel from
> > databinder) but I am unable to perform the sort on the database side, it
> > must be done on the server after the results are returned (due to the
> > nature
> > of the sort function).  Previously, I had extended the
> HibernateListModel
> > to
> > make a SortableHibernateListModel, which worked very well.  However,
> That
> > style of adding features gets cumbersome as you try to add new features
> > in.
> > For instance, next was a FilterableHibernateListModel (that also wanted
> to
> > sort).
> >
> > So, I tried another approach whereby I would chain the operations
> > together.
> > So, I created a SortingModel that implements the IChainingModel
> interface
> > and then stuck the HibernateListModel inside of it.  And that still
> > worked.
> > But, in another place, the model that I put into the SortingModel
> > (IChainingModel) is an impl of IComponentAssignedModel.  The problem is
> > that
> > when assigning choices to a DropDownChoice, it calls Component.wrapwhich
> > specifically looks for IComponentAssignedModel models, and if found,
> calls
> > wrapOnAssignment().  However, in my case, wrap will see the SortingModel
> > not
> > the IComponentAssignedModel and therefore not operate as it did
> > previosuly.
> >
> > I'm looking for some feedback here...
> > Should wrap() be updated to traverse the IChainingModel chain until it
> > finds
> > an IComponentAssignedModel or exhausts the chain?
> >
> > Should I find a different method of adding sort capabilities on top of a
> > Model?
> >
> > What other options do I have?
> >
> > Thanks,
> > Chuck


-- 
View this message in context: 
http://www.nabble.com/Component.wrap-and-IChainingModel-tf4759201.html#a13616079
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to