You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Joseph Pachod <jo...@thomas-daily.de> on 2010/08/03 23:42:22 UTC

FormComponentPanel and list edit

hi
IF
we're heavily reusing the edit components we do, and as such we wanted them to behave as "good form citizen". On our way, we spotted the FormComponentPanel, which seems to achieve our goal.

Yet, a question has popped up: how to deal with List edit ? Indeed, none of the class extending AbstractRepeater is a form component. As such, there's no getConvertedInput that could be used to compose the result when using a repeater.

Currently, the approach we have taken is to wrap the list edit used (listview/listEditor for example) in a FormComponentPanel and, on convertInput, we first visit all children and call IFormModelUpdateListener.updateModel where possible. And then we use the backing model of the list editor to compose our result.

This doesn't seem 100% right and we already had some issue where some component updateModel was called before convertInput was, resulting in a null convertedInput being used.

In the distant future we plan to implement a list editor being a FormComponent and requesting a FormComponent to populate each row. As such we could iterate over each row formComponent and call getConvertedInput there.

is it appropriate ? Would you recommend some other approach ?

thanks in advance
++
joseph

Re: FormComponentPanel and list edit

Posted by Igor Vaynberg <ig...@gmail.com>.
On Wed, Aug 4, 2010 at 1:00 AM, Joseph Pachod <jp...@thomas-daily.de> wrote:
> Igor Vaynberg wrote:
>>
>> why not? convertinput() will cascade down to all components that need
>> them.
>>
>> -igor
>>
>
> I feel like the issue is not with the components in the list item, but with
> the wrapper around the list item.
>
> For example (pseudo code):
> public class ContactListEdit extends FormComponentPanel<List<Contact>>{
>
> (...)
> private ListEditor<Contact> contactListEdit ;
>
> onBeforeRender(){
>  if(!hasBeenRendered()){
>   contactListEdit = new ListEditor<Contact>("id",listModel){
>     void onPopulateItem(item){
>        item.add(new TextField("firstname", new
> PropertyModel(item.getModel(), "firstname");
>        item.add(new TextField("lastname", new PropertyModel(item.getModel(),
> "lastname");
>     }
>   }
>   add(contactListEdit);
>  }
> }
>  (..)
>
> List<Contact> convertedInput ;
>
> public void convertInput(){
>  List<Contact> list= new ArrayList<Contact>()
>  // how to compose the list ?
    listeditor.convertinput();
   setConvertedInput(listeditor.getconvertedinput());

-igor
> }
> }
>
> The issue is then in convertInput, how to compose the list of contacts ?
>
> thanks again for your help
> ++
> joseph
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: FormComponentPanel and list edit

Posted by Joseph Pachod <jp...@thomas-daily.de>.
Igor Vaynberg wrote:
> why not? convertinput() will cascade down to all components that need them.
>
> -igor
>   
I feel like the issue is not with the components in the list item, but 
with the wrapper around the list item.

For example (pseudo code):
public class ContactListEdit extends FormComponentPanel<List<Contact>>{

(...)
private ListEditor<Contact> contactListEdit ;

onBeforeRender(){
  if(!hasBeenRendered()){
    contactListEdit = new ListEditor<Contact>("id",listModel){
      void onPopulateItem(item){
         item.add(new TextField("firstname", new 
PropertyModel(item.getModel(), "firstname");
         item.add(new TextField("lastname", new 
PropertyModel(item.getModel(), "lastname");
      }
    }
    add(contactListEdit);
  }
}
   (..)

List<Contact> convertedInput ;

public void convertInput(){
  List<Contact> list= new ArrayList<Contact>()
  // how to compose the list ?
  setConvertedInput(list);
}
}

The issue is then in convertInput, how to compose the list of contacts ?

thanks again for your help
++
joseph

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


Re: FormComponentPanel and list edit

Posted by Igor Vaynberg <ig...@gmail.com>.
why not? convertinput() will cascade down to all components that need them.

-igor

On Wed, Aug 4, 2010 at 12:03 AM, Joseph Pachod <jp...@thomas-daily.de> wrote:
> Igor Vaynberg wrote:
>>
>> visit all the children, check if they are a FormComponent and call
>> convertinput() followed by getconvertedinput()
>>
>> -igor
>>
>
> hi
>
> thanks igor
>
> we thought of that, but the issue is that we need to handle the
> getconvertedinput
>
> For example, if I've a ContactListEdit, with each item having 2 TextFields
> (on firstname and lastname for example), then just calling getConvertedInput
> would'nt be enough. Each item have some getConvertedInput doing something
> like "return new Contact(firstnameEdit.getConvertedInput(),
> lastnameEdit.getConvertedInput())".
>
> or am I missing something ?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: FormComponentPanel and list edit

Posted by Joseph Pachod <jp...@thomas-daily.de>.
Igor Vaynberg wrote:
> visit all the children, check if they are a FormComponent and call
> convertinput() followed by getconvertedinput()
>
> -igor
>   
hi

thanks igor

we thought of that, but the issue is that we need to handle the 
getconvertedinput

For example, if I've a ContactListEdit, with each item having 2 
TextFields (on firstname and lastname for example), then just calling 
getConvertedInput would'nt be enough. Each item have some 
getConvertedInput doing something like "return new 
Contact(firstnameEdit.getConvertedInput(), 
lastnameEdit.getConvertedInput())".

or am I missing something ?

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


Re: FormComponentPanel and list edit

Posted by Igor Vaynberg <ig...@gmail.com>.
visit all the children, check if they are a FormComponent and call
convertinput() followed by getconvertedinput()

-igor

On Tue, Aug 3, 2010 at 2:42 PM, Joseph Pachod
<jo...@thomas-daily.de> wrote:
> hi
> IF
> we're heavily reusing the edit components we do, and as such we wanted them to behave as "good form citizen". On our way, we spotted the FormComponentPanel, which seems to achieve our goal.
>
> Yet, a question has popped up: how to deal with List edit ? Indeed, none of the class extending AbstractRepeater is a form component. As such, there's no getConvertedInput that could be used to compose the result when using a repeater.
>
> Currently, the approach we have taken is to wrap the list edit used (listview/listEditor for example) in a FormComponentPanel and, on convertInput, we first visit all children and call IFormModelUpdateListener.updateModel where possible. And then we use the backing model of the list editor to compose our result.
>
> This doesn't seem 100% right and we already had some issue where some component updateModel was called before convertInput was, resulting in a null convertedInput being used.
>
> In the distant future we plan to implement a list editor being a FormComponent and requesting a FormComponent to populate each row. As such we could iterate over each row formComponent and call getConvertedInput there.
>
> is it appropriate ? Would you recommend some other approach ?
>
> thanks in advance
> ++
> joseph

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