Re: Component.wrap and IChainingModel

2007-11-12 Thread ChuckDeal


Dmitry   Kandalov wrote:
 
 On Thursday 08 November 2007 23:28:40 ChuckDeal wrote:
  Perhaps I didn't get the explanation but why can't you wrap models in
  this order?
 
  AppendingListModel(
      SortingModel(
          HibernateListModel()
      )
  )

 In that order the list would be sorting PRIOR to appending the item,
 which
 could result in an unsorted list.  In the order I specified, the item
 would
 get appeneded and then the sort would take place.
 
 You're right. But if you were not using List you could return SortedSet
 from 
 SortingModel and it would work :)
 

But then I'd be using a Set instead of a List.  DropDownChoice (via
AbstractChoice) expects the choices model to represent a List.

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


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



Re: Component.wrap and IChainingModel

2007-11-12 Thread Dmitry Kandalov
On Monday 12 November 2007 22:13:33 ChuckDeal wrote:
  You're right. But if you were not using List you could return SortedSet
  from
  SortingModel and it would work :)

 But then I'd be using a Set instead of a List.  DropDownChoice (via
 AbstractChoice) expects the choices model to represent a List.

Well, you could have yet another model that lazily wraps a Set in a List. And 
you could enhance DDC with this model to support Sets (I've always wanted DDC 
and ListView to support sets). But I admit it's quite hackish to solve your 
initial problem like that.

Dima

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



Re: Component.wrap and IChainingModel

2007-11-09 Thread Dmitry Kandalov
On Thursday 08 November 2007 23:28:40 ChuckDeal wrote:
  Perhaps I didn't get the explanation but why can't you wrap models in
  this order?
 
  AppendingListModel(
      SortingModel(
          HibernateListModel()
      )
  )

 In that order the list would be sorting PRIOR to appending the item, which
 could result in an unsorted list.  In the order I specified, the item would
 get appeneded and then the sort would take place.

You're right. But if you were not using List you could return SortedSet from 
SortingModel and it would work :)


Dima

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



Re: Component.wrap and IChainingModel

2007-11-08 Thread ChuckDeal


Dmitry   Kandalov wrote:
 
 On Wednesday 07 November 2007 01:18:32 ChuckDeal wrote:
 
 SortingModel (IChainingModel) - AppendingListModel
 (IComponentAssignmentModel) - HibernateListModel (database oriented
 model
 that returns a list of items from the db, unsorted).
 
 Perhaps I didn't get the explanation but why can't you wrap models in this 
 order?
 
 AppendingListModel(
 SortingModel(
 HibernateListModel()
 )
 )
 
In that order the list would be sorting PRIOR to appending the item, which
could result in an unsorted list.  In the order I specified, the item would
get appeneded and then the sort would take place.


Dmitry   Kandalov wrote:
 
 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.
 
 I'd like to.
 
 
 Dima
 

I don't have time right now to make a sample app, but this should be enough
source for you to see the impl.

http://www.nabble.com/file/p13654020/chained_model_source.zip
chained_model_source.zip 

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


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



Re: Component.wrap and IChainingModel

2007-11-08 Thread Dmitry Kandalov
On Wednesday 07 November 2007 01:18:32 ChuckDeal wrote:

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

Perhaps I didn't get the explanation but why can't you wrap models in this 
order?

AppendingListModel(
SortingModel(
HibernateListModel()
)
)

 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.

I'd like to.


Dima

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



Re: Component.wrap and IChainingModel

2007-11-08 Thread ChuckDeal


Johan Compagner wrote:
 


 SortingModel (IChainingModel) - AppendingListModel
 (IComponentAssignmentModel) - HibernateListModel (database oriented
 model
 that returns a list of items from the db, unsorted).
 
 
 
 So the sorting model is the outside one that you give to the component
 
 But if we then go through that chained model and see the
 AppendingListModel
 and we say ok wrap. Aren't we then by by passing the sort?? Because
 if the component then ask its model the data. It doesn't go through the
 sorting model.
 
 johan
 
 

Not with my impl.  In the case of a chained model, the wrapped model is
inserted into the chain in the place of the model it is wrapping.  So that
sort will still occur, but it will get it's list from the wrapped model.

I posted some of the files on another message in this thread.

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


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



Re: Component.wrap and IChainingModel

2007-11-06 Thread Johan Compagner
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.

What you could do is let all your chained models also implement
IComponentAssignedModel

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.wrap which
 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#a13610128
 Sent from the Wicket - User mailing list archive at Nabble.com.


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




Re: Component.wrap and IChainingModel

2007-11-06 Thread ChuckDeal


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.wrap which
 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#a13610846
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: Component.wrap and IChainingModel

2007-11-06 Thread Johan Compagner
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?

But what do you give to the component then? And why must is wrap?

johan



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#a13610846
 Sent from the Wicket - User mailing list archive at Nabble.com.


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




Re: Component.wrap and IChainingModel

2007-11-06 Thread ChuckDeal


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