Re: [Wicket-user] How can we change a component dynamically in Wicket ?
* rc.china: > > It seems that Lable use < s p a n > tag while TextField use < i n p u t > tag > and that they conflict. I have changed the code like this and it still does > not work properly. Does anyone have any workaround ? Thank you! > > public class Login extends WebPage { > private int count = 0; > > Label label = null; > TextField textField = null; > > public Login() { > super(); > > label = new Label("label", new PropertyModel(this, "count")); > label.setOutputMarkupId(true); > > textField = new TextField("label", new PropertyModel(this, > "count")); > textField.setOutputMarkupId(true); Add both components to the page and override isVisible() on your components. -- Jean-Baptiste Quenot aka John Banana Qwerty http://caraldi.com/jbq/ - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] How can we change a component dynamically in Wicket ?
On 6/21/07, Igor Vaynberg <[EMAIL PROTECTED]> wrote: > if you dont want to see the div and using wicket 1.3 you can use > wicket:container instead of div, eg, wicket:id="placeholder"> Or setRenderBodyOnly(true); Martijn -- Join the wicket community at irc.freenode.net: ##wicket Wicket 1.2.6 contains a very important fix. Download Wicket now! http://wicketframework.org - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] How can we change a component dynamically in Wicket ?
if you want to switch between a label and a textfield, or any two things that require unique markup but not big enough to factor out into panels then you should use fragments then simply insert the correct fragment into the placeholder div if you dont want to see the div and using wicket 1.3 you can use wicket:container instead of div, eg, -igor On 6/20/07, rc.china <[EMAIL PROTECTED]> wrote: swaroop wrote: > > I can see a few things gond wrong here... > > 1> First in the onclick method , this does not refer to the original > parent > to which label was added initially as label is the component u want to > replace > > 2> When u want to add a new component to replace the original component > in the parent heirarchy , u need to call replace method or replaceWith > method > > 3> Dont create the textfield right at the beginning. Do it in the onClick > method. > Here it just hangs out there until user clicks the link > > -swaroop > you are right, I have make some mistake. Timo wrote: > > This is suspicious. I don't think you should add components > to the hierarchy during ajax request processing, and > definitely not if-else what you add when you have static > markup (i.e. no repeaters). > > Always add both components, and set their visibility as > needed. Wicket visibility controls whether the comoponent > produces any markup at all, so it's "stronger" than HTML > visibility. > > With ajax updates of visibility you need a placeholder to > update around the component (as invisible components don't > provide any markup which ajax could update). > > Best wishes, > Timo > > P.S. Congratulations to Apache Wicket for graduating! > > > -- > Timo Rantalaiho > I just show what i want using this simple example. In practice, I have a menu/tree link and i want to dynamically show different content in one area for each menu item or tree item. If we use placeholders for each of them, it would be terrible. Thank you guys. I have found another mistake in this example. In the html template: Click here The is ok for wicket.markup.html.basic.Label, however, wicket.markup.html.form.TextField asks for , so it is disappointing. -- View this message in context: http://www.nabble.com/How-can-we-change-a-component-dynamically-in-Wicket---tf3956267.html#a11227255 Sent from the Wicket - User mailing list archive at Nabble.com. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] How can we change a component dynamically in Wicket ?
It seems that Lable use < s p a n > tag while TextField use < i n p u t > tag and that they conflict. I have changed the code like this and it still does not work properly. Does anyone have any workaround ? Thank you! public class Login extends WebPage { private int count = 0; Label label = null; TextField textField = null; public Login() { super(); label = new Label("label", new PropertyModel(this, "count")); label.setOutputMarkupId(true); textField = new TextField("label", new PropertyModel(this, "count")); textField.setOutputMarkupId(true); AjaxLink ajaxLink = new AjaxLink("ajaxLink") { public void onClick(AjaxRequestTarget request) { count++; if (count % 2 == 0) { this.findPage().replace(label); request.addComponent(label); } else { this.findPage().replace(textField); request.addComponent(textField); } } }; this.add(label); this.add(ajaxLink); } public int getCount() { return count; } public void setCount(int count) { this.count = count; } } -- View this message in context: http://www.nabble.com/How-can-we-change-a-component-dynamically-in-Wicket---tf3956267.html#a11227330 Sent from the Wicket - User mailing list archive at Nabble.com. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] How can we change a component dynamically in Wicket ?
swaroop wrote: > > I can see a few things gond wrong here... > > 1> First in the onclick method , this does not refer to the original > parent > to which label was added initially as label is the component u want to > replace > > 2> When u want to add a new component to replace the original component > in the parent heirarchy , u need to call replace method or replaceWith > method > > 3> Dont create the textfield right at the beginning. Do it in the onClick > method. > Here it just hangs out there until user clicks the link > > -swaroop > you are right, I have make some mistake. Timo wrote: > > This is suspicious. I don't think you should add components > to the hierarchy during ajax request processing, and > definitely not if-else what you add when you have static > markup (i.e. no repeaters). > > Always add both components, and set their visibility as > needed. Wicket visibility controls whether the comoponent > produces any markup at all, so it's "stronger" than HTML > visibility. > > With ajax updates of visibility you need a placeholder to > update around the component (as invisible components don't > provide any markup which ajax could update). > > Best wishes, > Timo > > P.S. Congratulations to Apache Wicket for graduating! > > > -- > Timo Rantalaiho > I just show what i want using this simple example. In practice, I have a menu/tree link and i want to dynamically show different content in one area for each menu item or tree item. If we use placeholders for each of them, it would be terrible. Thank you guys. I have found another mistake in this example. In the html template: Click here The is ok for wicket.markup.html.basic.Label, however, wicket.markup.html.form.TextField asks for , so it is disappointing. -- View this message in context: http://www.nabble.com/How-can-we-change-a-component-dynamically-in-Wicket---tf3956267.html#a11227255 Sent from the Wicket - User mailing list archive at Nabble.com. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] How can we change a component dynamically in Wicket ? (ccc rrr)
you can get to outer class scoping easily for example if that label was inside a panel class MyPanel extends Panel { public MyPanel(String id) { super(id); add(new AjaxLink("link") { public void onclick(ajaxrequesttarget target) { // to get a reference to the panel that the link is in just do Panel panel=MyPanel.this; // or MyPanel.this.add } -igor On 6/20/07, rc.china <[EMAIL PROTECTED]> wrote: Sorry, one error in the code: this.add(...) ==> this.findPage().add(...) And we change like above, the output is what we want:) -- View this message in context: http://www.nabble.com/Re%3A-How-can-we-change-a-component-dynamically-in-Wicket---%28ccc-rrr%29-tf3956306.html#a11226195 Sent from the Wicket - User mailing list archive at Nabble.com. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] How can we change a component dynamically in Wicket ? (ccc rrr)
Sorry, one error in the code: this.add(...) ==> this.findPage().add(...) And we change like above, the output is what we want:) -- View this message in context: http://www.nabble.com/Re%3A-How-can-we-change-a-component-dynamically-in-Wicket---%28ccc-rrr%29-tf3956306.html#a11226195 Sent from the Wicket - User mailing list archive at Nabble.com. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] How can we change a component dynamically in Wicket ?
Sorry, one error in the code: this.add(...) ==> this.findPage().add(...) But the output is the same:( -- View this message in context: http://www.nabble.com/How-can-we-change-a-component-dynamically-in-Wicket---tf3956267.html#a11226186 Sent from the Wicket - User mailing list archive at Nabble.com. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] How can we change a component dynamically in Wicket ?
On Thu, 21 Jun 2007, ccc rrr wrote: >if (count % 2 == 0) >{ > this.add(label); > request.addComponent(label); >} >else >{ >this.add(textField); >request.addComponent(textField); >} This is suspicious. I don't think you should add components to the hierarchy during ajax request processing, and definitely not if-else what you add when you have static markup (i.e. no repeaters). Always add both components, and set their visibility as needed. Wicket visibility controls whether the comoponent produces any markup at all, so it's "stronger" than HTML visibility. With ajax updates of visibility you need a placeholder to update around the component (as invisible components don't provide any markup which ajax could update). Best wishes, Timo P.S. Congratulations to Apache Wicket for graduating! -- Timo Rantalaiho Reaktor Innovations Oyhttp://www.ri.fi/ > - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] How can we change a component dynamically in Wicket ?
Hi I can see a few things gond wrong here... 1> First in the onclick method , this does not refer to the original parent to which label was added initially as label is the component u want to replace 2> When u want to add a new component to replace the original component in the parent heirarchy , u need to call replace method or replaceWith method 3> Dont create the textfield right at the beginning. Do it in the onClick method. Here it just hangs out there until user clicks the link -swaroop On 6/21/07, ccc rrr <[EMAIL PROTECTED]> wrote: Hi, I want to change a component in html, for example: *1)Test.html* Click here *2)Test.java* public class Test extends WebPage { private int count = 0; Label label = null; TextField textField = null; public Login() { super(); label = new Label("label", new PropertyModel(this, "count")); label.setOutputMarkupId(true); textField = new TextField("label", new PropertyModel(this, "count")); textField.setOutputMarkupId(true); AjaxLink ajaxLink = new AjaxLink("ajaxLink") { public void onClick(AjaxRequestTarget request) { count++; if (count % 2 == 0) { this.add(label); request.addComponent (label); } else { this.add(textField); request.addComponent(textField); } } }; this.add(label); this.add(ajaxLink); } public int getCount() { return count; } public void setCount(int count) { this.count = count; } } However, when I client the link, the Ajax message shows as: INFO: INFO: Initiating Ajax GET request on /wicket/mytest/?wicket:interface=:0:ajaxLink::IBehaviorListener&wicket:behaviorId=0&random= 0.17448336090136768 INFO: Invoking pre-call handler(s)... INFO: Received ajax response (53 characters) INFO: ERROR: Error while parsing response: Could not find root element INFO: Invoking post-call handler(s)... INFO: Invoking failure handler(s)... - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] How can we change a component dynamically in Wicket ? (ccc rrr)
Another test. If we change the code like this: //... AjaxLink ajaxLink = new AjaxLink("ajaxLink") { public void onClick(AjaxRequestTarget request) { count++; this.add(label); request.addComponent(label); } }; //... we still can not get what we want. This is the Ajax message: *INFO: * *INFO: * Initiating Ajax GET request on /wicket/mytest/?wicket:interface=:0:ajaxLink::IBehaviorListener&wicket:behaviorId=0&random= 0.17603507974667476 *INFO: *Invoking pre-call handler(s)... *INFO: *Received ajax response (177 characters) *INFO: * *INFO: *Response parsed. Now invoking steps... *ERROR: * Component with id [[ajaxLink_label]] a was not found while trying to perform markup update. Make sure you called component.setOutputMarkupId (true) on the component whose markup you are trying to update. *INFO: *Response processed successfully. *INFO: *Invoking post-call handler(s)... - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user