Thank you for our opinion Maurice,

problem is that what you're telling me is not exactly my problem
(although it will be further on, so thank you anyway)

as I see I have to submit the whole form in order to retain (not yet
save do DB!) those values from this particular dynamic list component,
I update (by setting the ajax target) only this one component but yet
the whole form must be submitted and it's a big form, what if it
contains fileuploads and stuff that is not needed for this ajax
component, that would be an overkill

or am I missing something?

regards
Wojtek

2008/3/5, Maurice Marrink <[EMAIL PROTECTED]>:
> We usually follow this approach
>  -load initial list
>  -clone initial list for working copy
>  -if the list is likely to be altered often or by multiple persons
>  store a flag for each item indicating if it was removed or added
>  -have wicket modify the working copy (and or the flags)
>  -in the onsubmit load a fresh list from the db, if you have flags use
>  that to delete / add items. if you do not have flags your working copy
>  is how the list should end up, so clear list and insert all items from
>  working copy.
>
>  Maurice
>
>
>  On Wed, Mar 5, 2008 at 3:13 PM, Wojciech Biela <[EMAIL PROTECTED]> wrote:
>  > I don't know if the code will help, if it doesn't please just
>  >  disregard it and answer my question
>  >
>  >  regards
>  >  Wojtek
>  >
>  >  2008/3/5, Wojciech Biela <[EMAIL PROTECTED]>:
>  >
>  >
>  > > Hello
>  >  >
>  >  >  This time my question is not so general.
>  >  >
>  >  >  We have a big form, part of this form there is a component which
>  >  >  should be a dynamic list of fields like this:
>  >  >
>  >  >  |TextField| - remove
>  >  >  |TextField| - remove
>  >  >  |TextField| - remove
>  >  >  |TextField| - add
>  >  >
>  >  >  if you click "add" another row "|TextField| - remove" should appear at
>  >  >  the bottom, it you should click "remove" then this row should be
>  >  >  removed
>  >  >
>  >  >  problem we have is that the "add" and "remove" link does not send the
>  >  >  form, it only sends and ajax request to add an element to the list of
>  >  >  components and it operates (target) on a DIV that wraps the whole
>  >  >  list, so afterwards it renders the list again loosing values that were
>  >  >  already put in
>  >  >
>  >  >  what is the preferred method to do such a thing? should the add and
>  >  >  remove link be a submit link with defaultFormProcessing set to false?
>  >  >  or maybe should we try to save values to model objects onchange in the
>  >  >  respective fields themselves
>  >  >
>  >  >  isn't there a way to do it in a neat fashion?
>  >  >
>  >  >  code responsible for the list component is
>  >  >
>  >  >     wrapper = new WebMarkupContainer("attributes-wrapper");
>  >  >     listView = new ListView("attributes", attributeValuesList) {
>  >  >       public void populateItem(final ListItem listItem) {
>  >  >         final AttributeValue attributeValue = (AttributeValue)
>  >  >  listItem.getModelObject();
>  >  >         Renderer inputRenderer =
>  >  >  attributeValue.getAttribute().getInputRenderer();
>  >  >         Component component = 
> inputRenderer.getComponent(attributeValue);
>  >  >         listItem.add(component);
>  >  >         AjaxLink addLink = new AddLink("add-link");
>  >  >         AjaxLink removeLink = new RemoveLink("remove-link", listItem);
>  >  >         if (listItem.getIndex() < (listView.getViewSize() - 1)) {
>  >  >           addLink.setVisible(false);
>  >  >         } else {
>  >  >           removeLink.setVisible(false);
>  >  >         }
>  >  >         listItem.add(addLink);
>  >  >         listItem.add(removeLink);
>  >  >       }
>  >  >     };
>  >  >     wrapper.setOutputMarkupId(true);
>  >  >
>  >  >  HTML is
>  >  >
>  >  >         <div wicket:id="attributes-wrapper" class="composit-wrapper">
>  >  >                 <div wicket:id="attributes" class="composit">
>  >  >                         <div wicket:id="attributeAndValue" 
> class="composit-item"></div>
>  >  >                         <div class="composit-links">
>  >  >                         <a wicket:id="add-link">+ add</a>
>  >  >                         <a wicket:id="remove-link">- remove</a>
>  >  >                         </div>
>  >  >                 </div>
>  >  >         </div>
>  >  >
>  >  >
>  >  >  --
>  >  >  Wojtek Biela
>  >  >
>  >
>  >
>  >  --
>  >  Wojtek Biela
>  >
>
> >  ---------------------------------------------------------------------
>  >  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  >  For additional commands, e-mail: [EMAIL PROTECTED]
>  >
>  >
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Wojtek Biela

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

Reply via email to