put a container around your component and update that via ajax instead -igor
On 10/4/07, Clay Lehman <[EMAIL PROTECTED]> wrote: > I implemented a simple IComponentBorder, and anything I put in the > beforeRender gets added again every time I try to update the component > with AJAX. > > My IcomponentBorder has: > public void renderBefore(Component component) > { > Response resp = component.getResponse(); > resp.write("Label"); > } > > To update the input box using AJAX I have a behavior: > > Input1.add(new AjaxFormComponentUpdatingBehavior("onchange") > { > protected void onUpdate(AjaxRequestTarget target) > { > theItem.name="new value"; > target.addComponent(input2) > } > }); > > When I do target.addComponent(input2), the renderBefore adds "Label" > again, so the HTML looks like: > > Label Label <input wicket:id="input2"/> > > Am I using IComponentBorder wrong? > > Thanks for any help! > -Clay > > > -----Original Message----- > From: Igor Vaynberg [mailto:[EMAIL PROTECTED] > Sent: Thursday, October 04, 2007 11:13 AM > To: users@wicket.apache.org > Subject: Re: Adding a label when I add a FormComponent. > > see icomponentborder > > -igor > > > On 10/4/07, Clay Lehman <[EMAIL PROTECTED]> wrote: > > > > Hey Everyone, > > > > > > > > I want to create a subclass of a Form Component (Let's use TextField > for > > this example) which takes a String in the constructor, and > automatically > > adds the HTML for a Label before the field. I want to provide all the > > default functionality of a TextField (like adding behaviors, and > > validators), so I don't think a Panel will work for me. > > > > > > > > > > > > I found a post where it mentioned (as a hack)to override onRender to > add > > HTML for the label directly, but this runs into problems when you > > include the Component in an AJAX page (whenever you re-add the > > component, it calls onRender, and you add the HTML for the label > > multiple times. > > > > > > > > Is there a way to do this using SimpleFormComponentLabel, or some > other > > construct? > > > > > > > > Could I use FormComponentPanel? Or is there some configuration and > > functionality in AbstractTextCompnent and TextField which I would lose > > by using a FormComponentPanel? > > > > > > > > Thanks for any advice!! > > > > -Clay Lehman > > > > > > --------------------------------------------------------------------- > 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]