Do I understand you right, you have something like

    Class MyPanel {
       public MyPanel(...) {
          Component c = new Component(...);
          c.add(new Draggable());
          // some more components with draggable
       }
    }



    MyPage extends WebPage {
      Public MyPage() {
         add(new MyPanel(...));
         // dragging works

         add(new AjaxLink(...){
            onClick(AjaxRequestTarget) {
               MyPanel newPanel;
               getPage.addOrReplace(newPanel = new MyPanel(...));
               target.addComponent(newPanel);
               // Dragging stops working
            }
         });
      }
    }
Right?



-----Ursprüngliche Nachricht-----
Von: Stefan Jozsa [mailto:[email protected]] 
Gesendet: Donnerstag, 18. Juni 2009 16:28
An: [email protected]
Betreff: RE: WicketJQuery: Drag & drop behavior lost for components of AJAX 
updated panels


Hi Stefan,

Sorry, but I missed to specify that DraggableBehavior is added to
(undefined/variable number of) components of 'MyPanel', that is
not to the panel itself.
So, using the same 'MyPanel' constructor in both cases 
DraggableBehavior is added (by Java code) to those components of 'MyPanel'.

Having: 
   Panel myPanel = new MyPanel("panelId");
depending how is "rendered" by addOrReplace(myPanel) or by
target.addComponent(myPanel) the result is different, 
the markup (and who knows what...) is different.

I tried WicketJQuery-0.3.5, got same (draggable behavior lost) result.

I tried even (naive) workarounds like:
  myDraggableComponent.add(new AttributeModifier("class", true, new 
Model<String>("ui-draggable")));
  myDraggableComponent.add(new AttributeModifier("dragclass", true, new 
Model<String>("a")));
but got the same (draggable behavior lost) result.

This is extremly disturbing issue since cannot reload page
(it has an embedded Flash player) and GUI interaction is based on
AJAX backed panel/component refresh.

Any idea, help, workaround, fix is welcomed,
thanks,
Stefan


--- On Thu, 6/18/09, Stefan Lindner <[email protected]> wrote:

> From: Stefan Lindner <[email protected]>
> Subject: RE: WicketJQuery: Drag & drop behavior lost for components of AJAX 
> updated panels
> To: [email protected]
> Date: Thursday, June 18, 2009, 3:30 PM
> I can't see a solution for what you
> are doing.
> 
>     ...
>     @Override
>     public void onClick(AjaxRequestTarget target)
> {
>         Panel panel = new
> MyPanel("panelId");
>         addOrReplace(panel);
>         target.addComponent(panel);
>     }
> 
> creates a NEW Panel and the NEW panel is a totally new
> object that does not know anything about the ORIGINAL Panel.
> The AJAX response renders the NEW Panel (with it's new class
> attribute but without the AJAX behaviors you've added to the
> ORIGINAL Panel).
> 
> This also happens with Wickts builtin Behaviors. Try this
> 
>         panel.add(new
> AjaxEventBehavior("onclick") {
>            
> @Override
>            
> protected void onEvent(AjaxRequestTarget target) {
>            
>     System.out.println("clicked!");
>             }
>         });
> 
> This also disappears after you replace the panel within an
> AJAX call.
> 
> 
> You can do two things:
> 1.  ...
>     @Override
>     public void onClick(AjaxRequestTarget target)
> {
>         Panel panel = new
> MyPanel("panelId");
> !       panel.add(new
> DraggableBehavior());
>         addOrReplace(panel);
>         target.addComponent(panel);
>     }
> 
> !   AND USE VERSION 0.3.5!
> 
> 2.  ...
>     @Override
>     public void onClick(AjaxRequestTarget target)
> {
> !   
>    originalPanel.setDefaultModelObject(some
> new value);
> !   
>    target.addComponent(originalPanel);
>     }
> 
> Good luck and let me know if it works for you!
> 
> Stefan
> 
> -----Ursprüngliche Nachricht-----
> Von: Stefan Jozsa [mailto:[email protected]]
> 
> Gesendet: Donnerstag, 18. Juni 2009 13:24
> An: [email protected]
> Betreff: Re: WicketJQuery: Drag & drop behavior lost
> for components of AJAX updated panels
> 
> 
> Found that when panel is constructed like:
>     public MyPage() {
>         ...
>         add(new MyPanel("panelId"));
>         ...
>     }
> markup of a draggable element is:
> <span id="id123456" class="myClass ui-draggable" ...
> >[]</span>
> 
> However when:
>     ...
>     @Override
>     public void onClick(AjaxRequestTarget target)
> {
>         Panel panel = new
> MyPanel("panelId");
>         addOrReplace(panel);
>         target.addComponent(panel);
>     }
> markup of a draggable element is:
> <span id="id123456" class="myClass" ...
> >[]</span>
> 
> that is 'ui-draggable' is not found (stripped ? not added?)
> 
> in 'class' attribute of draggable element.
> 
> Any help is welcommed,
> Stefan
> 
> 
> --- On Thu, 6/18/09, Stefan Jozsa <[email protected]>
> wrote:
> 
> > From: Stefan Jozsa <[email protected]>
> > Subject: WicketJQuery: Drag & drop behavior lost
> for components of AJAX updated panels
> > To: [email protected]
> > Date: Thursday, June 18, 2009, 1:44 PM
> > 
> > Doing:
> >     public MyPage() {
> >         ...
> >         add(new MyPanel("panelId"));
> >         ...
> >     }
> > dragging elements (having DraggableBehavior) of
> 'MyPanel'
> > works.
> > 
> > However doing:
> >     ...
> >     @Override
> >     public void onClick(AjaxRequestTarget target)
> > {
> >         Panel panel = new
> > MyPanel("panelId");
> >         addOrReplace(panel);
> >         target.addComponent(panel);
> >     }
> >     
> > dragging elements of 'MyPanel' DO NOT works
> > (DraggableBehavior is lost).
> > 
> > 
> > What's going on ?
> > Any help is (very) appreciated,
> > thanks Stefan
> > 
> > Using:
> > Wicket-1.4.rc4,
> > WicketJQuery-0.3.4
> > 
> > 
> > 
> > 
> >       
> > 
> >
> ---------------------------------------------------------------------
> > 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]
> 
> 
> ---------------------------------------------------------------------
> 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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to