Actually AjaxFormComponentUpdatingBehavior accomplishes the desired behavior without submitting the entire form. I can see the tricky part in loosing changes to the text in the textfields if you replace the div surrounding them but i thought nested forms in wicket 1.3.? solved this by only submitting the child formcomponents, or am i mistaken?
Maurice On Wed, Mar 5, 2008 at 4:50 PM, Erik van Oosten <[EMAIL PROTECTED]> wrote: > Hi Wojciech, > > You should use Buttons instead of links. Button (or AjaxFallbackButton) > does submit the form. The only thing you need to do is disable > validation on the button (call button.setDefaultFormProcessing(false)), > otherwise the onSubmit of the button is not called when some field in > the form does not validate. You can optionally call form.validate() in > the onSubmit of the button so that validation messages do not disappear. > > OT: personally, in forms I prefer RefreshingView instead of ListView. > > Regards, > Erik. > > -- > Erik van Oosten > http://www.day-to-day-stuff.blogspot.com/ > > > > > Wojciech Biela wrote: > > 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> > > > > > > > > > --------------------------------------------------------------------- > 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]
