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
RE: Adding a label when I add a FormComponent.
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]
Re: Adding a label when I add a FormComponent.
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]
Re: Adding a label when I add a FormComponent.
If you are going to have to add extra containers anyway, you could try it the way we do it on my project. In the html, we add both a label and input element with wicket ids. to keep it simple, the label's id is the same as the related component's id with label appended to it. Then, we have a createLabel method that takes the Component and it automatically adds the label with the proper id. TextField message = new TextField(message); message.setLabel(new Model(Message)); add(message); createFieldLabel(this, message); protected FormComponentLabel createFieldLabel(final MarkupContainer container, final FormComponent formComponent) { FormComponentLabel label = new FieldLabel(formComponent.getId() + Label, formComponent); container.add(label); return label; } Chuck igor.vaynberg wrote: 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] -- View this message in context: http://www.nabble.com/Adding-a-label-when-I-add-a-FormComponent.-tf4569428.html#a13047069 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Adding a label when I add a FormComponent.
Is there a way to tell if a request is coming via AJAX instead of a normal request? If there is a way to do this, I could disable my ComponentBorder on secondary AJAX requests, and only use it on the original request... Thanks, -Clay -Original Message- From: Igor Vaynberg [mailto:[EMAIL PROTECTED] Sent: Thursday, October 04, 2007 2:09 PM To: users@wicket.apache.org Subject: Re: Adding a label when I add a FormComponent. 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Adding a label when I add a FormComponent.
WebRequest.isAjax() Eelco On 10/4/07, Clay Lehman [EMAIL PROTECTED] wrote: Is there a way to tell if a request is coming via AJAX instead of a normal request? If there is a way to do this, I could disable my ComponentBorder on secondary AJAX requests, and only use it on the original request... Thanks, -Clay -Original Message- From: Igor Vaynberg [mailto:[EMAIL PROTECTED] Sent: Thursday, October 04, 2007 2:09 PM To: users@wicket.apache.org Subject: Re: Adding a label when I add a FormComponent. 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] - 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]