Component Model question

2009-04-13 Thread Craig Tataryn
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 MultiTextInputCollectionString(tags, new  
ArrayListString() {

{
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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Component Model question

2009-04-10 Thread Martin Makundi
Are you trying to handle state on client side? While that is possible,
it is not the purpose of Wicket. Would you consider managing he state
on server side?

**
Martin

2009/4/10 Craig Tataryn crai...@tataryn.net:
 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 MultiTextInputCollectionString(tags, new
 ArrayListString() {
{
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.

 --
 Craig Tataryn
 site: http://www.basementcoders.com/
 podcast:http://feeds.feedburner.com/TheBasementCoders
 irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
 twitter: craiger

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



Re: Component Model question

2009-04-10 Thread Craig Tataryn

On 10-Apr-09, at 12:58 PM, Martin Makundi wrote:


Are you trying to handle state on client side? While that is possible,
it is not the purpose of Wicket. Would you consider managing he state
on server side?



It's an existing javascript widget I wrote so I was looking for a  
quick port to Wicket. However there is no reason there couldn't be two  
versions, the Ajax version could redraw everything serverside upon  
addition/deletion of items.


So if it's possible for me to (easily) map those two sets of hidden  
inputs to my model upon form submit I'd really like to know how.


Thanks,

Craig.


**
Martin

2009/4/10 Craig Tataryn crai...@tataryn.net:
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 MultiTextInputCollectionString(tags, new
ArrayListString() {
  {
  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.

--
Craig Tataryn
site: http://www.basementcoders.com/
podcast:http://feeds.feedburner.com/TheBasementCoders
irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
twitter: craiger


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





Re: Component Model question

2009-04-10 Thread Martin Makundi
 So if it's possible for me to (easily) map those two sets of hidden inputs
 to my model upon form submit I'd really like to know how.

What specifically is the difficult part?

**
Martin



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



Re: Component Model question

2009-04-10 Thread Igor Vaynberg
look at textfield.

all you have to do is to write out the input tags with a name you
obtain from formcomponent.getname() - to guarantee uniqueness, then
override convertinput() and pull those values out of the request into
a collection and call setconvertedinput(collection). formcomponent
will take care of everything else such as validation and updating the
model. thats all there is to it.

-igor

On Fri, Apr 10, 2009 at 10:49 AM, Craig Tataryn crai...@tataryn.net wrote:
 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 MultiTextInputCollectionString(tags, new
 ArrayListString() {
        {
                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.

 --
 Craig Tataryn
 site: http://www.basementcoders.com/
 podcast:http://feeds.feedburner.com/TheBasementCoders
 irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
 twitter: craiger

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



Re: Component Model question

2009-04-10 Thread Craig Tataryn

On 10-Apr-09, at 3:10 PM, Igor Vaynberg wrote:


look at textfield.

all you have to do is to write out the input tags with a name you
obtain from formcomponent.getname() - to guarantee uniqueness, then
override convertinput() and pull those values out of the request into
a collection and call setconvertedinput(collection). formcomponent
will take care of everything else such as validation and updating the
model. thats all there is to it.



Thanks Igor, in my version I had overridden updateModel like so to get  
it working:


public void updateModel() {
String[] added = this.getInputAsArray();
		String[] removed = getRequest().getParameters(removed_ +  
getInputName());

MultiTextInputModel model = (MultiTextInputModel) 
this.getModel();
		model.setItems(added == null ? EMPTY_STRING_COL :  
Arrays.asList(added));
		model.setRemovedItems(removed == null ? EMPTY_STRING_COL :  
Arrays.asList(removed));


}
I'm assuming that convertInput fires before update model, so I should  
override that method as you suggest to handle different types but  
maintain my updateModel as well to shovel things into the right places  
in the model?


Craig.


-igor

On Fri, Apr 10, 2009 at 10:49 AM, Craig Tataryn  
crai...@tataryn.net wrote:
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 MultiTextInputCollectionString(tags, new
ArrayListString() {
   {
   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.

--
Craig Tataryn
site: http://www.basementcoders.com/
podcast:http://feeds.feedburner.com/TheBasementCoders
irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
twitter: craiger


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




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



Re: Component Model question

2009-04-10 Thread Igor Vaynberg
no, all you have to do is override convertinput and inside call
setconvertedinput(yourcollection);

the default implementation of updatemodel() already does
getmodel().setobject(getconvertedinput());

-igor

On Fri, Apr 10, 2009 at 3:29 PM, Craig Tataryn crai...@tataryn.net wrote:
 On 10-Apr-09, at 3:10 PM, Igor Vaynberg wrote:

 look at textfield.

 all you have to do is to write out the input tags with a name you
 obtain from formcomponent.getname() - to guarantee uniqueness, then
 override convertinput() and pull those values out of the request into
 a collection and call setconvertedinput(collection). formcomponent
 will take care of everything else such as validation and updating the
 model. thats all there is to it.


 Thanks Igor, in my version I had overridden updateModel like so to get it
 working:

        public void updateModel() {
                String[] added = this.getInputAsArray();
                String[] removed = getRequest().getParameters(removed_ +
 getInputName());
                MultiTextInputModel model = (MultiTextInputModel)
 this.getModel();
                model.setItems(added == null ? EMPTY_STRING_COL :
 Arrays.asList(added));
                model.setRemovedItems(removed == null ? EMPTY_STRING_COL :
 Arrays.asList(removed));

        }
 I'm assuming that convertInput fires before update model, so I should
 override that method as you suggest to handle different types but maintain
 my updateModel as well to shovel things into the right places in the model?

 Craig.

 -igor

 On Fri, Apr 10, 2009 at 10:49 AM, Craig Tataryn crai...@tataryn.net
 wrote:

 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 MultiTextInputCollectionString(tags, new
 ArrayListString() {
       {
               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.

 --
 Craig Tataryn
 site: http://www.basementcoders.com/
 podcast:http://feeds.feedburner.com/TheBasementCoders
 irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
 twitter: craiger

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



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



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