On Sun, Jul 24, 2011 at 6:18 PM, Michael Petritsch <[email protected]> wrote: > 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. see https://github.com/hielkehoeve/wiquery-highcharts . could be in help ... > > and when I click on a part of the diagramm I want to open a wicket for events like click you better use AjaxEventBehavior > 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 <[email protected]> wrote: >> On Sun, Jul 24, 2011 at 5:40 PM, Michael Petritsch >> <[email protected]> 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 <[email protected]> >>> wrote: >>>> On Sun, Jul 24, 2011 at 5:10 PM, Michael Petritsch >>>> <[email protected]> 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: <div id="myLabeld" wicket:id="myLabel">foo</div> >>>> 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 <[email protected]> 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: [email protected] >>>>>> For additional commands, e-mail: [email protected] >>>>>> >>>>>> >>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: [email protected] >>>>> For additional commands, e-mail: [email protected] >>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> Martin Grigorov >>>> jWeekend >>>> Training, Consulting, Development >>>> http://jWeekend.com >>>> >>>> --------------------------------------------------------------------- >>>> 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] >>> >>> >> >> >> >> -- >> Martin Grigorov >> jWeekend >> Training, Consulting, Development >> http://jWeekend.com >> >> --------------------------------------------------------------------- >> 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] > >
-- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
