Re: controlling components from sub classes
I am actually asking for generic solution through which I will be able to modify components behavior from sub class without touching base class is there any pattern or any of the page method where I can retrieve the component by its path and make changes ? Alexandru Objelean wrote: What about this: BasePage: --- add(newFindingNumber(findingNumber)); protected Component newFindingNumber(String id) { return new TextFieldString(id); } --- in ChildPage: --- protected Component newFindingNumber(String id) { Component component = super. newFindingNumber(id); component.setEnabled(false);// or whatever return component; } --- Alex fachhoch wrote: I looking for some best practices or better way to control my page components , like set enable add attribute modifiers etc. for example I have add and edit page , where one textField should be enabled in add and disabled in edit so for this I did add(new TextFieldString(findingNumber).setEnabled(enableFindingNumber())); protected boolean enableFindingNumber(){ return false; } the subclass Add page will override this method to true .but this will not be generic tomarrow If I need some attribute modifiersfor addpage and not for edit again I will do the same add a protected method call that in textfield and override in addpage , this approach will make me change the base class for everytime for any new features the sub class needs .I am looking for some way through whcih I can retrieve the component in the sub class and add decoratos without changing the base class ? -- View this message in context: http://www.nabble.com/controlling-components-from-sub-classes-tp23853627p23874505.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: controlling components from sub classes
get(path) will get you the component by path. -igor On Thu, Jun 4, 2009 at 10:33 AM, fachhoch fachh...@gmail.com wrote: I am actually asking for generic solution through which I will be able to modify components behavior from sub class without touching base class is there any pattern or any of the page method where I can retrieve the component by its path and make changes ? Alexandru Objelean wrote: What about this: BasePage: --- add(newFindingNumber(findingNumber)); protected Component newFindingNumber(String id) { return new TextFieldString(id); } --- in ChildPage: --- protected Component newFindingNumber(String id) { Component component = super. newFindingNumber(id); component.setEnabled(false);// or whatever return component; } --- Alex fachhoch wrote: I looking for some best practices or better way to control my page components , like set enable add attribute modifiers etc. for example I have add and edit page , where one textField should be enabled in add and disabled in edit so for this I did add(new TextFieldString(findingNumber).setEnabled(enableFindingNumber())); protected boolean enableFindingNumber(){ return false; } the subclass Add page will override this method to true .but this will not be generic tomarrow If I need some attribute modifiers for addpage and not for edit again I will do the same add a protected method call that in textfield and override in addpage , this approach will make me change the base class for everytime for any new features the sub class needs .I am looking for some way through whcih I can retrieve the component in the sub class and add decoratos without changing the base class ? -- View this message in context: http://www.nabble.com/controlling-components-from-sub-classes-tp23853627p23874505.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
controlling components from sub classes
I looking for some best practices or better way to control my page components , like set enable add attribute modifiers etc. for example I have add and edit page , where one textField should be enabled in add and disabled in edit so for this I did add(new TextFieldString(findingNumber).setEnabled(enableFindingNumber())); protected boolean enableFindingNumber(){ return false; } the subclass Add page will override this method to true .but this will not be generic tomarrow If I need some attribute modifiersfor addpage and not for edit again I will do the same add a protected method call that in textfield and override in addpage , this approach will make me change the base class for everytime for any new features the sub class needs .I am looking for some way through whcih I can retrieve the component in the sub class and add decoratos without changing the base class ?
Re: controlling components from sub classes
How about returning the TextField itself from the subclass ? And the baseclass just returns a default TextField ? On Wed, Jun 3, 2009 at 10:22 AM, tubin gen fachh...@gmail.com wrote: I looking for some best practices or better way to control my page components , like set enable add attribute modifiers etc. for example I have add and edit page , where one textField should be enabled in add and disabled in edit so for this I did add(new TextFieldString(findingNumber).setEnabled(enableFindingNumber())); protected boolean enableFindingNumber(){ return false; } the subclass Add page will override this method to true .but this will not be generic tomarrow If I need some attribute modifiersfor addpage and not for edit again I will do the same add a protected method call that in textfield and override in addpage , this approach will make me change the base class for everytime for any new features the sub class needs .I am looking for some way through whcih I can retrieve the component in the sub class and add decoratos without changing the base class ? -- Regards, Vasu Srinivasan
Re: controlling components from sub classes
What about this: BasePage: --- add(newFindingNumber(findingNumber)); protected Component newFindingNumber(String id) { return new TextFieldString(id); } --- in ChildPage: --- protected Component newFindingNumber(String id) { Component component = super. newFindingNumber(id); component.setEnabled(false);// or whatever return component; } --- Alex fachhoch wrote: I looking for some best practices or better way to control my page components , like set enable add attribute modifiers etc. for example I have add and edit page , where one textField should be enabled in add and disabled in edit so for this I did add(new TextFieldString(findingNumber).setEnabled(enableFindingNumber())); protected boolean enableFindingNumber(){ return false; } the subclass Add page will override this method to true .but this will not be generic tomarrow If I need some attribute modifiersfor addpage and not for edit again I will do the same add a protected method call that in textfield and override in addpage , this approach will make me change the base class for everytime for any new features the sub class needs .I am looking for some way through whcih I can retrieve the component in the sub class and add decoratos without changing the base class ? -- View this message in context: http://www.nabble.com/controlling-components-from-sub-classes-tp23853627p23856345.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org