Re: Accessing Page components
Just declare them final, should work just fine, but with consequences (you wont be able to re-reference them in a future). On Thu, Dec 17, 2009 at 8:45 AM, marioosh.net marioosh@gmail.comwrote: Is simple possibility to access page components in anonymous onClick method like in code below ? public class NewLinkPanel extends Panel { public NewLinkPanel(String id) { super(id); TextField name = new TextField(name); TextField address = new TextField(address); add(name); add(address); add(new AjaxLink(ok){ public void onClick(AjaxRequestTarget target) { // how to get name and address values ? System.out.println(ok); } }); } } Thanks in advance. -- Greetings, marioosh - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Best regards, Paul Szulc http://paulszulc.wordpress.com
Re: Accessing Page components
2009/12/17, Pieter Degraeuwe pieter.degrae...@systemworks.be: However, I never do it like this. I always use PropertyModels() to 'map' my TextFields to properties of my object. This way your code in the onClick() method uses that just the object properties. (Note that the AjaxSubmitLink has no onClick(), but a onSubmit()...) Pieter Thanks Pieter. I got working this like below: public class NewLinkPanel extends Panel { public NewLinkPanel(String id) { super(id); add(new LinkForm(linkform)); } } class LinkForm extends Form { public LinkForm(String id) { super(id); Link link = new Link(); this.setModel(new Model(link)); add(new TextField(name, new PropertyModel(link, name))); add(new TextField(address,new PropertyModel(link, address))); add(new AjaxSubmitLink(ok){ @Override protected void onSubmit(AjaxRequestTarget target, Form form) {} }); } @Override protected void onSubmit() { Link l = (Link)this.getModelObject(); new LinkDAO().save(l); } } Now i want to update (refresh) my another panel with list of links on my page :D That will be a problem for me now. I'm beginner -- Greetings, marioosh - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Accessing Page components
There are several ways how you can do this... To encourage losely coupled components folowing is in my opinion the best solution.. Work with a callback mechanism. let's say you define a callback interface SaveCallback with a method onSaved(AjaxRequestTarget target). The component that uses you panel/form, can pass such a callback to define de 'code' that needs to be executedn once the Link is saved. class MyPage { public MyPage() { //construct panels final Panel otherPanel = new . otherPanel.setOutputMarkupId(true); //make it possible to refresh this panel via ajax add(otherPanel); add(new NewLinkPanel(newLinkPanel,new SaveCallback() { onSaved(AjaxRequestTarget target) { target.addComponent(otherPanel);//refresh other panel } }); } } On Thu, Dec 17, 2009 at 11:31 AM, marioosh.net marioosh@gmail.comwrote: 2009/12/17, Pieter Degraeuwe pieter.degrae...@systemworks.be: However, I never do it like this. I always use PropertyModels() to 'map' my TextFields to properties of my object. This way your code in the onClick() method uses that just the object properties. (Note that the AjaxSubmitLink has no onClick(), but a onSubmit()...) Pieter Thanks Pieter. I got working this like below: public class NewLinkPanel extends Panel { public NewLinkPanel(String id) { super(id); add(new LinkForm(linkform)); } } class LinkForm extends Form { public LinkForm(String id) { super(id); Link link = new Link(); this.setModel(new Model(link)); add(new TextField(name, new PropertyModel(link, name))); add(new TextField(address,new PropertyModel(link, address))); add(new AjaxSubmitLink(ok){ @Override protected void onSubmit(AjaxRequestTarget target, Form form) {} }); } @Override protected void onSubmit() { Link l = (Link)this.getModelObject(); new LinkDAO().save(l); } } Now i want to update (refresh) my another panel with list of links on my page :D That will be a problem for me now. I'm beginner -- Greetings, marioosh - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be
Re: Accessing Page components
Pieter Degraeuwe wrote: There are several ways how you can do this... To encourage losely coupled components folowing is in my opinion the best solution.. Work with a callback mechanism. let's say you define a callback interface SaveCallback with a method onSaved(AjaxRequestTarget target). The component that uses you panel/form, can pass such a callback to define de 'code' that needs to be executedn once the Link is saved. class MyPage { public MyPage() { //construct panels final Panel otherPanel = new . otherPanel.setOutputMarkupId(true); //make it possible to refresh this panel via ajax add(otherPanel); add(new NewLinkPanel(newLinkPanel,new SaveCallback() { onSaved(AjaxRequestTarget target) { target.addComponent(otherPanel);//refresh other panel } }); } } I did code like below, but i don't know how in onSubmit() method get AjaxRequestTarget object. // callback interface public interface AddLinkCallback { public void onAdd(AjaxRequestTarget target); } // main page with panels public class Base extends WebPage { public Base() { final ContentPanel contentPanel = new ContentPanel(content); contentPanel.setOutputMarkupId(true); // can be updated by ajax NewLinkPanel linkPanel = new NewLinkPanel(newlink, new AddLinkCallback() { @Override public void onAdd(AjaxRequestTarget target) { // TODO Auto-generated method stub target.addComponent(contentPanel);//refresh other panel } }); } } // control panel (add button) public class NewLinkPanel extends Panel { public NewLinkPanel(String id, AddLinkCallback callback) { super(id); add(new LinkForm(linkform, callback)); } } class LinkForm extends Form { private AddLinkCallback callback; public LinkForm(String id, AddLinkCallback callback) { super(id); this.callback = callback; Link link = new Link(); this.setModel(new Model(link)); add(new TextField(name, new PropertyModel(link, name))); add(new TextField(address,new PropertyModel(link, address))); add(new AjaxSubmitLink(ok){ @Override protected void onSubmit(AjaxRequestTarget target, Form form) {} }); } @Override protected void onSubmit() { System.out.println(ok); Link l = (Link)this.getModelObject(); new LinkDAO().save(l); callback.onAdd(target ); // ??? } } -- View this message in context: http://old.nabble.com/Accessing-Page-components-tp26824375p26827804.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: Accessing Page components
Use the onSubmit(AjaxRequestTarget target) of your AjaxSubmitLink instead of your form. (Note that if you make use of FeedbackPanel, youd should also override the onError() method of that ajaxlink to 'refresh' your feedback panel) On Thu, Dec 17, 2009 at 2:14 PM, marioosh.net marioosh@gmail.comwrote: Pieter Degraeuwe wrote: There are several ways how you can do this... To encourage losely coupled components folowing is in my opinion the best solution.. Work with a callback mechanism. let's say you define a callback interface SaveCallback with a method onSaved(AjaxRequestTarget target). The component that uses you panel/form, can pass such a callback to define de 'code' that needs to be executedn once the Link is saved. class MyPage { public MyPage() { //construct panels final Panel otherPanel = new . otherPanel.setOutputMarkupId(true); //make it possible to refresh this panel via ajax add(otherPanel); add(new NewLinkPanel(newLinkPanel,new SaveCallback() { onSaved(AjaxRequestTarget target) { target.addComponent(otherPanel);//refresh other panel } }); } } I did code like below, but i don't know how in onSubmit() method get AjaxRequestTarget object. // callback interface public interface AddLinkCallback { public void onAdd(AjaxRequestTarget target); } // main page with panels public class Base extends WebPage { public Base() { final ContentPanel contentPanel = new ContentPanel(content); contentPanel.setOutputMarkupId(true); // can be updated by ajax NewLinkPanel linkPanel = new NewLinkPanel(newlink, new AddLinkCallback() { @Override public void onAdd(AjaxRequestTarget target) { // TODO Auto-generated method stub target.addComponent(contentPanel);//refresh other panel } }); } } // control panel (add button) public class NewLinkPanel extends Panel { public NewLinkPanel(String id, AddLinkCallback callback) { super(id); add(new LinkForm(linkform, callback)); } } class LinkForm extends Form { private AddLinkCallback callback; public LinkForm(String id, AddLinkCallback callback) { super(id); this.callback = callback; Link link = new Link(); this.setModel(new Model(link)); add(new TextField(name, new PropertyModel(link, name))); add(new TextField(address,new PropertyModel(link, address))); add(new AjaxSubmitLink(ok){ @Override protected void onSubmit(AjaxRequestTarget target, Form form) {} }); } @Override protected void onSubmit() { System.out.println(ok); Link l = (Link)this.getModelObject(); new LinkDAO().save(l); callback.onAdd(target ); // ??? } } -- View this message in context: http://old.nabble.com/Accessing-Page-components-tp26824375p26827804.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 -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be
Re: Accessing Page components
I don't have the habit to exend from Form, since I don't need to put logic there (I put it in my submitLinks/buttons) On Thu, Dec 17, 2009 at 2:45 PM, Pieter Degraeuwe pieter.degrae...@systemworks.be wrote: Use the onSubmit(AjaxRequestTarget target) of your AjaxSubmitLink instead of your form. (Note that if you make use of FeedbackPanel, youd should also override the onError() method of that ajaxlink to 'refresh' your feedback panel) On Thu, Dec 17, 2009 at 2:14 PM, marioosh.net marioosh@gmail.comwrote: Pieter Degraeuwe wrote: There are several ways how you can do this... To encourage losely coupled components folowing is in my opinion the best solution.. Work with a callback mechanism. let's say you define a callback interface SaveCallback with a method onSaved(AjaxRequestTarget target). The component that uses you panel/form, can pass such a callback to define de 'code' that needs to be executedn once the Link is saved. class MyPage { public MyPage() { //construct panels final Panel otherPanel = new . otherPanel.setOutputMarkupId(true); //make it possible to refresh this panel via ajax add(otherPanel); add(new NewLinkPanel(newLinkPanel,new SaveCallback() { onSaved(AjaxRequestTarget target) { target.addComponent(otherPanel);//refresh other panel } }); } } I did code like below, but i don't know how in onSubmit() method get AjaxRequestTarget object. // callback interface public interface AddLinkCallback { public void onAdd(AjaxRequestTarget target); } // main page with panels public class Base extends WebPage { public Base() { final ContentPanel contentPanel = new ContentPanel(content); contentPanel.setOutputMarkupId(true); // can be updated by ajax NewLinkPanel linkPanel = new NewLinkPanel(newlink, new AddLinkCallback() { @Override public void onAdd(AjaxRequestTarget target) { // TODO Auto-generated method stub target.addComponent(contentPanel);//refresh other panel } }); } } // control panel (add button) public class NewLinkPanel extends Panel { public NewLinkPanel(String id, AddLinkCallback callback) { super(id); add(new LinkForm(linkform, callback)); } } class LinkForm extends Form { private AddLinkCallback callback; public LinkForm(String id, AddLinkCallback callback) { super(id); this.callback = callback; Link link = new Link(); this.setModel(new Model(link)); add(new TextField(name, new PropertyModel(link, name))); add(new TextField(address,new PropertyModel(link, address))); add(new AjaxSubmitLink(ok){ @Override protected void onSubmit(AjaxRequestTarget target, Form form) {} }); } @Override protected void onSubmit() { System.out.println(ok); Link l = (Link)this.getModelObject(); new LinkDAO().save(l); callback.onAdd(target ); // ??? } } -- View this message in context: http://old.nabble.com/Accessing-Page-components-tp26824375p26827804.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 -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be
Re: Accessing Page components
Pieter Degraeuwe wrote: I don't have the habit to exend from Form, since I don't need to put logic there (I put it in my submitLinks/buttons) On Thu, Dec 17, 2009 at 2:45 PM, Pieter Degraeuwe pieter.degrae...@systemworks.be wrote: Use the onSubmit(AjaxRequestTarget target) of your AjaxSubmitLink instead of your form. (Note that if you make use of FeedbackPanel, youd should also override the onError() method of that ajaxlink to 'refresh' your feedback panel) At first I wanted to do this in onSubmit of AjaxSubmitLink, but i've problem to get name and address components inside this method :( -- View this message in context: http://old.nabble.com/Accessing-Page-components-tp26824375p26828432.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: Accessing Page components
class LinkForm extends Form { private AddLinkCallback callback; public LinkForm(String id, *final *AddLinkCallback callback) { super(id); this.callback = callback; *final *Link link = new Link(); this.setModel(new Model(link)); add(new TextField(name, new PropertyModel(link, name))); add(new TextField(address,new PropertyModel(link, address))); add(new AjaxSubmitLink(ok){ @Override protected void onSubmit(AjaxRequestTarget target, Form form) { *new LinkDAO().save(l)*; callback.onAdd(target); } }); } @Override protected void onSubmit() { System.out.println(ok); Link l = (Link)this.getModelObject(); new LinkDAO().save(l); callback.onAdd(target ); // ??? } } On Thu, Dec 17, 2009 at 3:02 PM, marioosh.net marioosh@gmail.comwrote: Pieter Degraeuwe wrote: I don't have the habit to exend from Form, since I don't need to put logic there (I put it in my submitLinks/buttons) On Thu, Dec 17, 2009 at 2:45 PM, Pieter Degraeuwe pieter.degrae...@systemworks.be wrote: Use the onSubmit(AjaxRequestTarget target) of your AjaxSubmitLink instead of your form. (Note that if you make use of FeedbackPanel, youd should also override the onError() method of that ajaxlink to 'refresh' your feedback panel) At first I wanted to do this in onSubmit of AjaxSubmitLink, but i've problem to get name and address components inside this method :( -- View this message in context: http://old.nabble.com/Accessing-Page-components-tp26824375p26828432.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 -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be
Re: Accessing Page components
Pieter, passing the [*final *Link link = new Link();] object to the anonymous AjaxSubmitLink will Serialize the the link object itself. why not using the form.getModelObject() from the form parameter in ajaxsubmitl...@onsubmit()? *new LinkDAO().save(form.getModelObject())*; Pieter Degraeuwe wrote: class LinkForm extends Form { private AddLinkCallback callback; public LinkForm(String id, *final *AddLinkCallback callback) { super(id); this.callback = callback; *final *Link link = new Link(); this.setModel(new Model(link)); add(new TextField(name, new PropertyModel(link, name))); add(new TextField(address,new PropertyModel(link, address))); add(new AjaxSubmitLink(ok){ @Override protected void onSubmit(AjaxRequestTarget target, Form form) { *new LinkDAO().save(l)*; callback.onAdd(target); } }); } @Override protected void onSubmit() { System.out.println(ok); Link l = (Link)this.getModelObject(); new LinkDAO().save(l); callback.onAdd(target ); // ??? } } On Thu, Dec 17, 2009 at 3:02 PM, marioosh.net marioosh@gmail.comwrote: Pieter Degraeuwe wrote: I don't have the habit to exend from Form, since I don't need to put logic there (I put it in my submitLinks/buttons) On Thu, Dec 17, 2009 at 2:45 PM, Pieter Degraeuwe pieter.degrae...@systemworks.be wrote: Use the onSubmit(AjaxRequestTarget target) of your AjaxSubmitLink instead of your form. (Note that if you make use of FeedbackPanel, youd should also override the onError() method of that ajaxlink to 'refresh' your feedback panel) At first I wanted to do this in onSubmit of AjaxSubmitLink, but i've problem to get name and address components inside this method :( -- View this message in context: http://old.nabble.com/Accessing-Page-components-tp26824375p26828432.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 -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be -- View this message in context: http://old.nabble.com/Accessing-Page-components-tp26824375p26831586.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: Accessing Page components
It is indeed a better (more proper) way to do it your way, but the Link object will be serialized as well, since it is not a DetachableLoadableModel if I'm not mistaking... On Thu, Dec 17, 2009 at 6:15 PM, Juan Carlos Garcia M. jcgarc...@gmail.comwrote: Pieter, passing the [*final *Link link = new Link();] object to the anonymous AjaxSubmitLink will Serialize the the link object itself. why not using the form.getModelObject() from the form parameter in ajaxsubmitl...@onsubmit()? *new LinkDAO().save(form.getModelObject())*; Pieter Degraeuwe wrote: class LinkForm extends Form { private AddLinkCallback callback; public LinkForm(String id, *final *AddLinkCallback callback) { super(id); this.callback = callback; *final *Link link = new Link(); this.setModel(new Model(link)); add(new TextField(name, new PropertyModel(link, name))); add(new TextField(address,new PropertyModel(link, address))); add(new AjaxSubmitLink(ok){ @Override protected void onSubmit(AjaxRequestTarget target, Form form) { *new LinkDAO().save(l)*; callback.onAdd(target); } }); } @Override protected void onSubmit() { System.out.println(ok); Link l = (Link)this.getModelObject(); new LinkDAO().save(l); callback.onAdd(target ); // ??? } } On Thu, Dec 17, 2009 at 3:02 PM, marioosh.net marioosh@gmail.comwrote: Pieter Degraeuwe wrote: I don't have the habit to exend from Form, since I don't need to put logic there (I put it in my submitLinks/buttons) On Thu, Dec 17, 2009 at 2:45 PM, Pieter Degraeuwe pieter.degrae...@systemworks.be wrote: Use the onSubmit(AjaxRequestTarget target) of your AjaxSubmitLink instead of your form. (Note that if you make use of FeedbackPanel, youd should also override the onError() method of that ajaxlink to 'refresh' your feedback panel) At first I wanted to do this in onSubmit of AjaxSubmitLink, but i've problem to get name and address components inside this method :( -- View this message in context: http://old.nabble.com/Accessing-Page-components-tp26824375p26828432.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 -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be -- View this message in context: http://old.nabble.com/Accessing-Page-components-tp26824375p26831586.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 -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be
Re: Accessing Page components
Totally right! :) Pieter Degraeuwe wrote: It is indeed a better (more proper) way to do it your way, but the Link object will be serialized as well, since it is not a DetachableLoadableModel if I'm not mistaking... On Thu, Dec 17, 2009 at 6:15 PM, Juan Carlos Garcia M. jcgarc...@gmail.comwrote: Pieter, passing the [*final *Link link = new Link();] object to the anonymous AjaxSubmitLink will Serialize the the link object itself. why not using the form.getModelObject() from the form parameter in ajaxsubmitl...@onsubmit()? *new LinkDAO().save(form.getModelObject())*; Pieter Degraeuwe wrote: class LinkForm extends Form { private AddLinkCallback callback; public LinkForm(String id, *final *AddLinkCallback callback) { super(id); this.callback = callback; *final *Link link = new Link(); this.setModel(new Model(link)); add(new TextField(name, new PropertyModel(link, name))); add(new TextField(address,new PropertyModel(link, address))); add(new AjaxSubmitLink(ok){ @Override protected void onSubmit(AjaxRequestTarget target, Form form) { *new LinkDAO().save(l)*; callback.onAdd(target); } }); } @Override protected void onSubmit() { System.out.println(ok); Link l = (Link)this.getModelObject(); new LinkDAO().save(l); callback.onAdd(target ); // ??? } } On Thu, Dec 17, 2009 at 3:02 PM, marioosh.net marioosh@gmail.comwrote: Pieter Degraeuwe wrote: I don't have the habit to exend from Form, since I don't need to put logic there (I put it in my submitLinks/buttons) On Thu, Dec 17, 2009 at 2:45 PM, Pieter Degraeuwe pieter.degrae...@systemworks.be wrote: Use the onSubmit(AjaxRequestTarget target) of your AjaxSubmitLink instead of your form. (Note that if you make use of FeedbackPanel, youd should also override the onError() method of that ajaxlink to 'refresh' your feedback panel) At first I wanted to do this in onSubmit of AjaxSubmitLink, but i've problem to get name and address components inside this method :( -- View this message in context: http://old.nabble.com/Accessing-Page-components-tp26824375p26828432.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 -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be -- View this message in context: http://old.nabble.com/Accessing-Page-components-tp26824375p26831586.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 -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be -- View this message in context: http://old.nabble.com/Accessing-Page-components-tp26824375p26835876.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
Accessing Page components
Is simple possibility to access page components in anonymous onClick method like in code below ? public class NewLinkPanel extends Panel { public NewLinkPanel(String id) { super(id); TextField name = new TextField(name); TextField address = new TextField(address); add(name); add(address); add(new AjaxLink(ok){ public void onClick(AjaxRequestTarget target) { // how to get name and address values ? System.out.println(ok); } }); } } Thanks in advance. -- Greetings, marioosh - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Accessing Page components
Place your textfields in a Form. Replace your AjaxLink() by a AjaxSubmitLink (and place that link also in the form) then, you should be able to get the values by name.getDefaultModelObject() I think... However, I never do it like this. I always use PropertyModels() to 'map' my TextFields to properties of my object. This way your code in the onClick() method uses that just the object properties. (Note that the AjaxSubmitLink has no onClick(), but a onSubmit()...) Pieter On Thu, Dec 17, 2009 at 8:45 AM, marioosh.net marioosh@gmail.comwrote: Is simple possibility to access page components in anonymous onClick method like in code below ? public class NewLinkPanel extends Panel { public NewLinkPanel(String id) { super(id); TextField name = new TextField(name); TextField address = new TextField(address); add(name); add(address); add(new AjaxLink(ok){ public void onClick(AjaxRequestTarget target) { // how to get name and address values ? System.out.println(ok); } }); } } Thanks in advance. -- Greetings, marioosh - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be
Re: Accessing Page components
If you want to access them from a call you need to declare them final final TextField name = new TextField(name); But i' m missing a Model that should receive the values from the form components? Normally, with wicket you do not access the FormComponets to get the values but let Wicket handle the conversion and validation. Or do you use a CompoundPropertyModel (not shown in the code) ? Bert On Thu, Dec 17, 2009 at 08:45, marioosh.net marioosh@gmail.com wrote: Is simple possibility to access page components in anonymous onClick method like in code below ? public class NewLinkPanel extends Panel { public NewLinkPanel(String id) { super(id); TextField name = new TextField(name); TextField address = new TextField(address); add(name); add(address); add(new AjaxLink(ok){ public void onClick(AjaxRequestTarget target) { // how to get name and address values ? System.out.println(ok); } }); } } Thanks in advance. -- Greetings, marioosh - 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