You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Craig Tataryn <ct...@mysticcoders.com> on 2009/04/10 19:18:32 UTC

Component Model question

I have a component I'm designing where it displays a list of items to  
the user, so the setup for the component on the page might look like  
this:

         add(new MultiTextInput<Collection<String>>("tags", new  
ArrayList<String>() {
         	{
         		add("apple");
         		add("banana");
         	}
         }));

The widget will render two sets of hidden inputs, one for the original/ 
additional items (name="tags") which were entered and one for deleted  
items (name="removed_tags").

For instance:

<input type="hidden" name="tags" value="apple"/>
<input type="hidden" name="tags" value="peach"/>
<input type="hidden" name="tags" value="grape"/>
<input type="hidden" name="removed_tags" value="banana"/>

The above would result from me keeping apple and adding peach, grape,  
and removing banana.

I'm a bit stuck on how I should get my component to put these values  
back into it's model?  Obviously in behind the scenes I'm going to  
have to do some stuff in the MultiTextInput ctor to have the incoming  
Collection added to a composite model that contains both the original/ 
added items and the removed items.

I'm just not sure where I broker the form submittal so that I have a  
chance to move the "tags" and "removed_tags" into the proper place in  
the model for my component.  When the user calls getModelObject() on  
my component they'll get an object back where they can query  
model.getItems() and model.getRemovedItems().

As always, any help greatly appreciated!

Craig.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org