as i said in other threads.
When you dynamically adding things on the client side
Then you have to do this loading of that data completely by yourself in youre Form.onSubmit() method.

The wicket way (without ajax at them moment) you just have to go to the server there add a new record (new Person)
so that the ListView makes an extra empty row and renders this to the client.


On 10/3/05, Trieu, Danny <[EMAIL PROTECTED]> wrote:

Hi all,

 

It's 3am in the morning and I still trying to do something that seems simple… and yet impossible?

 

Ok, I have a list of Person(s) that needs to be display in a Form for update and create.

 

For update, I was able to update the existing data just fine.

 

For create, my Form has a button, when click on it, it needs to create an additional row with inputs for

All of the Person attributes.                                                                                                            

 

I first tried to use _javascript_ to create the new row with all the input fields empty. I used the Wicket's path

Patterns to generate these new input's name( with new index for this new entry). And on the serverside, I

Do as follow:

·        Created a new ListView that has populateItem(…) implemented.

·        Overrided newItem(…) and getListItemModel(…) so that newItem(…) returns a new ListItem that associated

To a new ListItemModel(I extended), return by the getListItemModel(…) that I override.

·        The new ListItemModel I extended has onAttach(…) overrided with logic that would add new and empty

Person object to the existing List of Person, that get from my ListView. getModelObject(…).

Well this doesn't work. The page did create additional row of inputs for the new person. But when I submit the Form,

Nothing get update to the existing list and the page come back with just the previous data in the table and my new

Person input is gone and no where to be found.

 

My guess is, Wicket use the existing components in the page to get posted data. And since my new entry inputs

Created on the client never exist on the server. Therefore, wicket does not know to go get it.

 

If this is right, then how do I overcome this default behavior? And if it is impossible to add new inputs on the client

Browser then How do I do it on the server? Meaning, how do I create the new inputs entries on the server so that wicket

Can generate new inputs entry, and client can enter data and submit it.

 

Thanks for any helps,

 

--danny

 

"The essence of knowledge is, having it, to apply it; not having it, to confess your ignorance." -Confucius

 


Reply via email to