Re: Loading wicket components from javascript
derTag(true) is needed only if you change the >>>> visibility of Ajax updated component. I don't see visibility related >>>> logic in your code. >>>> >>>> What exactly you want to achieve ? >>>>> >>>>> On Mon, Jul 18, 2011 at 4:59 AM, msj121 wrote: >>>>>> I am not sure if it is still true, but if you have the label added, just >>>>>> the >>>>>> visibility is false from the beginning, then in older versions of wicket >>>>>> it >>>>>> would not actually put the component, even the placeholder. I dealt with >>>>>> this before, but I think in newer versions presumably this was >>>>>> changed >>>>>> In theory a good way to check if this is an issue is to setvisible to >>>>>> true >>>>>> in the beginning and alternate. >>>>>> >>>>>> >>>>>> If your trying to add a new markup that never existed in html to the >>>>>> page, >>>>>> it should throw an error, and then you will need to use ListViews etc... >>>>>> as >>>>>> described above. >>>>>> >>>>>> -- >>>>>> View this message in context: >>>>>> http://apache-wicket.1842946.n4.nabble.com/Loading-wicket-components-from-javascript-tp3673381p3674372.html >>>>>> Sent from the Users forum 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 >>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> Martin Grigorov >>>> jWeekend >>>> Training, Consulting, Development >>>> http://jWeekend.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 >>> >>> >> >> >> >> -- >> Martin Grigorov >> jWeekend >> Training, Consulting, Development >> http://jWeekend.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 > > -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Loading wicket components from javascript
I am using this behaviour because I found an example for this. I don't know if there is anything better. :) Ok, the problem is I have some javascript diagrams (from http://highcharts.com/, don't want to advertise, but since you've asked ;)) that I use in our wicket app. and when I click on a part of the diagramm I want to open a wicket panel that loads data for that specific part of the diagramm. so I got everything working except the panel replacement. I also tried the MyPanel.this.addOrReplacecomponent(myAjaxLoadedPanel) before with no effect, but maybe I've screwed something else up then. Gonna try it again, thanks. On Sun, Jul 24, 2011 at 5:06 PM, Martin Grigorov wrote: > On Sun, Jul 24, 2011 at 5:40 PM, Michael Petritsch > wrote: >> Yes, I removed the visibility related code and anything else for >> simplicity and to focus on the actual problem. >> >> What I actually want to achieve is something like: >> >> public class MyPanel extends Panel { >> Panel myAjaxLoadedPanel; >> public MyPanel() { >> add(new AbstractDefaultAjaxBehavior() { > Still not clear why you use directly this behavior but you know better :-) >> @Override >> protected void respond(AjaxRequestTarget target) { >> String someParameter = >> RequestCycle.get().getRequest().getParameter("someParameter"); >> if(someParameter.equals("1") { > reverse the check here to avoid NPE >> myAjaxLoadedPanel = new Foo1Panel("myAjaxLoadedPanel"); >> } >> ... >> else { >> myAjaxLoadedPanel = new FooXPanel("myAjaxLoadedPanel"); >> } >> target.addComponent(myAjaxLoadedPanel); >> } >> } >> myAjaxLoadedPanel = new MyDefaultPanel("myAjaxLoadedPanel"); >> myAjaxLoadedPanel.setOutputMarkupId(true); >> add(myAjaxLoadedPanel); >> } > The problem that I see is that you just re-assign the panel. Better > see org.apache.wicket.Component.replaceWith(Component) and > org.apache.wicket.MarkupContainer.replace(Component). These methods > preserve the component hierarchy, i.e. the new assignment will > inherits its parent (MyPanel.this) from the old assignment. > > What is the actual problem ? Sorry, but I didn't follow this thread before. > >> >> On Sun, Jul 24, 2011 at 4:16 PM, Martin Grigorov >> wrote: >>> On Sun, Jul 24, 2011 at 5:10 PM, Michael Petritsch >>> wrote: >>>> I am using wicket 1.4.16, the markupplaceholder is there (checked with >>>> firebug). >>>> >>>> I have also tried it with a simple visible label: >>>> >>>> public class MyPanel extends Panel { >>>> Label myUpdatedLabel; >>>> public MyPanel() { >>>> add(new AbstractDefaultAjaxBehavior() { >>> Why do you use this behavior but not a more specific one ? E.g. >>> AjaxEventBehavior. >>>> @Override >>>> protected void respond(AjaxRequestTarget target) { >>>> myUpdatedLabel.setDefaultModel("bar"); >>>> target.addComponent(myUpdatedLabel); >>>> } >>>> } >>>> myUpdatedLabel = new Label("myLabel","foo"); >>>> myUpdatedLabel.setOutputMarkupId(true); >>>> add(myUpdatedLabel); >>>> } >>>> >>>> This works, however what I actually have to do in the response() >>>> method is the following: >>>> myUpdatedLabel = new Label("myLabel","bar"); >>>> myUpdatedLabel.setOuputMarkupId(true); >>>> target.addComponent(myUpdatedLabel); >>> What you really want is: >>> myUpdatedLabel.setDefaultModelObject("bar"); >>> target.addComponent(myUpdatedLabel); >>>> >>>> But when I try this nothing happens. The html of the label remains >>>> untouched: foo >>> setOutputMarkupPlaceholderTag(true) is needed only if you change the >>> visibility of Ajax updated component. I don't see visibility related >>> logic in your code. >>> >>> What exactly you want to achieve ? >>>> >>>> On Mon, Jul 18, 2011 at 4:59 AM, msj121 wrote: >>>>> I am not sure if it is still true, but if you have the label added, just >>>>> the >>>>> visibility is false from the beginning, then in older versions of wicket >>>>> it >>>>> would n
Re: Loading wicket components from javascript
On Sun, Jul 24, 2011 at 5:40 PM, Michael Petritsch wrote: > Yes, I removed the visibility related code and anything else for > simplicity and to focus on the actual problem. > > What I actually want to achieve is something like: > > public class MyPanel extends Panel { > Panel myAjaxLoadedPanel; > public MyPanel() { > add(new AbstractDefaultAjaxBehavior() { Still not clear why you use directly this behavior but you know better :-) > @Override > protected void respond(AjaxRequestTarget target) { > String someParameter = > RequestCycle.get().getRequest().getParameter("someParameter"); > if(someParameter.equals("1") { reverse the check here to avoid NPE > myAjaxLoadedPanel = new Foo1Panel("myAjaxLoadedPanel"); > } > ... > else { > myAjaxLoadedPanel = new FooXPanel("myAjaxLoadedPanel"); > } > target.addComponent(myAjaxLoadedPanel); > } > } > myAjaxLoadedPanel = new MyDefaultPanel("myAjaxLoadedPanel"); > myAjaxLoadedPanel.setOutputMarkupId(true); > add(myAjaxLoadedPanel); > } The problem that I see is that you just re-assign the panel. Better see org.apache.wicket.Component.replaceWith(Component) and org.apache.wicket.MarkupContainer.replace(Component). These methods preserve the component hierarchy, i.e. the new assignment will inherits its parent (MyPanel.this) from the old assignment. What is the actual problem ? Sorry, but I didn't follow this thread before. > > On Sun, Jul 24, 2011 at 4:16 PM, Martin Grigorov wrote: >> On Sun, Jul 24, 2011 at 5:10 PM, Michael Petritsch >> wrote: >>> I am using wicket 1.4.16, the markupplaceholder is there (checked with >>> firebug). >>> >>> I have also tried it with a simple visible label: >>> >>> public class MyPanel extends Panel { >>> Label myUpdatedLabel; >>> public MyPanel() { >>> add(new AbstractDefaultAjaxBehavior() { >> Why do you use this behavior but not a more specific one ? E.g. >> AjaxEventBehavior. >>> @Override >>> protected void respond(AjaxRequestTarget target) { >>> myUpdatedLabel.setDefaultModel("bar"); >>> target.addComponent(myUpdatedLabel); >>> } >>> } >>> myUpdatedLabel = new Label("myLabel","foo"); >>> myUpdatedLabel.setOutputMarkupId(true); >>> add(myUpdatedLabel); >>> } >>> >>> This works, however what I actually have to do in the response() >>> method is the following: >>> myUpdatedLabel = new Label("myLabel","bar"); >>> myUpdatedLabel.setOuputMarkupId(true); >>> target.addComponent(myUpdatedLabel); >> What you really want is: >> myUpdatedLabel.setDefaultModelObject("bar"); >> target.addComponent(myUpdatedLabel); >>> >>> But when I try this nothing happens. The html of the label remains >>> untouched: foo >> setOutputMarkupPlaceholderTag(true) is needed only if you change the >> visibility of Ajax updated component. I don't see visibility related >> logic in your code. >> >> What exactly you want to achieve ? >>> >>> On Mon, Jul 18, 2011 at 4:59 AM, msj121 wrote: >>>> I am not sure if it is still true, but if you have the label added, just >>>> the >>>> visibility is false from the beginning, then in older versions of wicket it >>>> would not actually put the component, even the placeholder. I dealt with >>>> this before, but I think in newer versions presumably this was changed >>>> In theory a good way to check if this is an issue is to setvisible to true >>>> in the beginning and alternate. >>>> >>>> >>>> If your trying to add a new markup that never existed in html to the page, >>>> it should throw an error, and then you will need to use ListViews etc... as >>>> described above. >>>> >>>> -- >>>> View this message in context: >>>> http://apache-wicket.1842946.n4.nabble.com/Loading-wicket-components-from-javascript-tp3673381p3674372.html >>>> Sent from the Users forum mailing list archive at Nabble.com. >>>> >>>> - >>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >>>> For additional commands, e-mail: users-h...@wicket.apache.o
Re: Loading wicket components from javascript
Yes, I removed the visibility related code and anything else for simplicity and to focus on the actual problem. What I actually want to achieve is something like: public class MyPanel extends Panel { Panel myAjaxLoadedPanel; public MyPanel() { add(new AbstractDefaultAjaxBehavior() { @Override protected void respond(AjaxRequestTarget target) { String someParameter = RequestCycle.get().getRequest().getParameter("someParameter"); if(someParameter.equals("1") { myAjaxLoadedPanel = new Foo1Panel("myAjaxLoadedPanel"); } ... else { myAjaxLoadedPanel = new FooXPanel("myAjaxLoadedPanel"); } target.addComponent(myAjaxLoadedPanel); } } myAjaxLoadedPanel = new MyDefaultPanel("myAjaxLoadedPanel"); myAjaxLoadedPanel.setOutputMarkupId(true); add(myAjaxLoadedPanel); } On Sun, Jul 24, 2011 at 4:16 PM, Martin Grigorov wrote: > On Sun, Jul 24, 2011 at 5:10 PM, Michael Petritsch > wrote: >> I am using wicket 1.4.16, the markupplaceholder is there (checked with >> firebug). >> >> I have also tried it with a simple visible label: >> >> public class MyPanel extends Panel { >> Label myUpdatedLabel; >> public MyPanel() { >> add(new AbstractDefaultAjaxBehavior() { > Why do you use this behavior but not a more specific one ? E.g. > AjaxEventBehavior. >> @Override >> protected void respond(AjaxRequestTarget target) { >> myUpdatedLabel.setDefaultModel("bar"); >> target.addComponent(myUpdatedLabel); >> } >> } >> myUpdatedLabel = new Label("myLabel","foo"); >> myUpdatedLabel.setOutputMarkupId(true); >> add(myUpdatedLabel); >> } >> >> This works, however what I actually have to do in the response() >> method is the following: >> myUpdatedLabel = new Label("myLabel","bar"); >> myUpdatedLabel.setOuputMarkupId(true); >> target.addComponent(myUpdatedLabel); > What you really want is: > myUpdatedLabel.setDefaultModelObject("bar"); > target.addComponent(myUpdatedLabel); >> >> But when I try this nothing happens. The html of the label remains >> untouched: foo > setOutputMarkupPlaceholderTag(true) is needed only if you change the > visibility of Ajax updated component. I don't see visibility related > logic in your code. > > What exactly you want to achieve ? >> >> On Mon, Jul 18, 2011 at 4:59 AM, msj121 wrote: >>> I am not sure if it is still true, but if you have the label added, just the >>> visibility is false from the beginning, then in older versions of wicket it >>> would not actually put the component, even the placeholder. I dealt with >>> this before, but I think in newer versions presumably this was changed >>> In theory a good way to check if this is an issue is to setvisible to true >>> in the beginning and alternate. >>> >>> >>> If your trying to add a new markup that never existed in html to the page, >>> it should throw an error, and then you will need to use ListViews etc... as >>> described above. >>> >>> -- >>> View this message in context: >>> http://apache-wicket.1842946.n4.nabble.com/Loading-wicket-components-from-javascript-tp3673381p3674372.html >>> Sent from the Users forum 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 >> >> > > > > -- > Martin Grigorov > jWeekend > Training, Consulting, Development > http://jWeekend.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
Re: Loading wicket components from javascript
On Sun, Jul 24, 2011 at 5:10 PM, Michael Petritsch wrote: > I am using wicket 1.4.16, the markupplaceholder is there (checked with > firebug). > > I have also tried it with a simple visible label: > > public class MyPanel extends Panel { > Label myUpdatedLabel; > public MyPanel() { > add(new AbstractDefaultAjaxBehavior() { Why do you use this behavior but not a more specific one ? E.g. AjaxEventBehavior. > @Override > protected void respond(AjaxRequestTarget target) { > myUpdatedLabel.setDefaultModel("bar"); > target.addComponent(myUpdatedLabel); > } > } > myUpdatedLabel = new Label("myLabel","foo"); > myUpdatedLabel.setOutputMarkupId(true); > add(myUpdatedLabel); > } > > This works, however what I actually have to do in the response() > method is the following: > myUpdatedLabel = new Label("myLabel","bar"); > myUpdatedLabel.setOuputMarkupId(true); > target.addComponent(myUpdatedLabel); What you really want is: myUpdatedLabel.setDefaultModelObject("bar"); target.addComponent(myUpdatedLabel); > > But when I try this nothing happens. The html of the label remains > untouched: foo setOutputMarkupPlaceholderTag(true) is needed only if you change the visibility of Ajax updated component. I don't see visibility related logic in your code. What exactly you want to achieve ? > > On Mon, Jul 18, 2011 at 4:59 AM, msj121 wrote: >> I am not sure if it is still true, but if you have the label added, just the >> visibility is false from the beginning, then in older versions of wicket it >> would not actually put the component, even the placeholder. I dealt with >> this before, but I think in newer versions presumably this was changed >> In theory a good way to check if this is an issue is to setvisible to true >> in the beginning and alternate. >> >> >> If your trying to add a new markup that never existed in html to the page, >> it should throw an error, and then you will need to use ListViews etc... as >> described above. >> >> -- >> View this message in context: >> http://apache-wicket.1842946.n4.nabble.com/Loading-wicket-components-from-javascript-tp3673381p3674372.html >> Sent from the Users forum 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 > > -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Loading wicket components from javascript
I am using wicket 1.4.16, the markupplaceholder is there (checked with firebug). I have also tried it with a simple visible label: public class MyPanel extends Panel { Label myUpdatedLabel; public MyPanel() { add(new AbstractDefaultAjaxBehavior() { @Override protected void respond(AjaxRequestTarget target) { myUpdatedLabel.setDefaultModel("bar"); target.addComponent(myUpdatedLabel); } } myUpdatedLabel = new Label("myLabel","foo"); myUpdatedLabel.setOutputMarkupId(true); add(myUpdatedLabel); } This works, however what I actually have to do in the response() method is the following: myUpdatedLabel = new Label("myLabel","bar"); myUpdatedLabel.setOuputMarkupId(true); target.addComponent(myUpdatedLabel); But when I try this nothing happens. The html of the label remains untouched: foo On Mon, Jul 18, 2011 at 4:59 AM, msj121 wrote: > I am not sure if it is still true, but if you have the label added, just the > visibility is false from the beginning, then in older versions of wicket it > would not actually put the component, even the placeholder. I dealt with > this before, but I think in newer versions presumably this was changed > In theory a good way to check if this is an issue is to setvisible to true > in the beginning and alternate. > > > If your trying to add a new markup that never existed in html to the page, > it should throw an error, and then you will need to use ListViews etc... as > described above. > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/Loading-wicket-components-from-javascript-tp3673381p3674372.html > Sent from the Users forum 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
Re: Loading wicket components from javascript
I am not sure if it is still true, but if you have the label added, just the visibility is false from the beginning, then in older versions of wicket it would not actually put the component, even the placeholder. I dealt with this before, but I think in newer versions presumably this was changed In theory a good way to check if this is an issue is to setvisible to true in the beginning and alternate. If your trying to add a new markup that never existed in html to the page, it should throw an error, and then you will need to use ListViews etc... as described above. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Loading-wicket-components-from-javascript-tp3673381p3674372.html Sent from the Users forum 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: Loading wicket components from javascript
Thanks, gonna try this. I hope this also works for adding Components with subcomponents (e.g. Tables, Panels etc.) and I don't have to manually Wicket...appendChild() all the subcomponents in js. On Sun, Jul 17, 2011 at 5:38 PM, Bertrand Guay-Paquet wrote: > Hi, > > Have you seen > http://wicketinaction.com/2008/10/repainting-only-newly-created-repeater-items-via-ajax/ > ? I used this method to add form inputs via ajax. If I understand correctly > what you want to do, you should be able to use this for adding labels. > > Bertrand > > On 17/07/2011 9:23 AM, Michael Petritsch wrote: >> >> Hi, >> >> is there a way to load wicket components from javascript? I tried the >> https://cwiki.apache.org/WICKET/calling-wicket-from-javascript.html >> approach. I tried to add a Label but it wasn't visible on the page. I >> tried to add a Panel but it never replaced the markupPlaceHolder I >> added for it. All I can do is send some js back via >> target.appendJavascript. Am I using it wrong or is there another way >> to do this? >> >> regards, >> Michael >> >> - >> 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 > > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Loading wicket components from javascript
Hi, Have you seen http://wicketinaction.com/2008/10/repainting-only-newly-created-repeater-items-via-ajax/ ? I used this method to add form inputs via ajax. If I understand correctly what you want to do, you should be able to use this for adding labels. Bertrand On 17/07/2011 9:23 AM, Michael Petritsch wrote: Hi, is there a way to load wicket components from javascript? I tried the https://cwiki.apache.org/WICKET/calling-wicket-from-javascript.html approach. I tried to add a Label but it wasn't visible on the page. I tried to add a Panel but it never replaced the markupPlaceHolder I added for it. All I can do is send some js back via target.appendJavascript. Am I using it wrong or is there another way to do this? regards, Michael - 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
Loading wicket components from javascript
Hi, is there a way to load wicket components from javascript? I tried the https://cwiki.apache.org/WICKET/calling-wicket-from-javascript.html approach. I tried to add a Label but it wasn't visible on the page. I tried to add a Panel but it never replaced the markupPlaceHolder I added for it. All I can do is send some js back via target.appendJavascript. Am I using it wrong or is there another way to do this? regards, Michael - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org