wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastien <seb...@gmail.com>
Subject Re: JQuery - best practice
Date Wed, 30 Jan 2013 20:19:06 GMT
Hi,

@Pieter,
Yes, a Panel was definitely not the best idea, it would have been better to
have - for the moment at least - a WebMarkupContainer as I planned as the
beginning.
I did a try on Martin's and Ernesto's suggestion(s) (handling callbacks in
behaviors, in addition to a Listener/Adapter). I need to think a little bit
more on this...
Anyway, I am also glad that you solved your problem. If, for any reason,
you encounter unexptected issue with your solution, I can revert the Panel
to a WebMarkupContainer at no cost, so it will be easy to use it in your
use case.

@Ernesto,
About your concerns related to the age and to earn some money at the end of
the month, I know exactly what your are talking about! :)

@Martin,
As said above, I did a try with your suggestion with a solution that works
nicely. But I was not able to apply it as you wrote it (for reasons I can
explain). So, I will continue to think a little bit to this to be sure I do
not "miss" something, and, if you don't mind (I don't want to bother you
with wicket-jquery-ui dev), I would like to commit a "new designed
behavior" in github, telling you what was the original approach and what is
the new one, and if you could tell me if the new one is
good/relevant/wicket-way, I will really appreciate!

Best regards to you all,
Sebastien.

On Wed, Jan 30, 2013 at 4:08 PM, Ernesto Reinaldo Barreiro <
reiern70@gmail.com> wrote:

> Good that you where able to solve your problem!
>
> On Wed, Jan 30, 2013 at 3:53 PM, Pieter Claassen <pieter@musmato.com>
> wrote:
>
> > Ok, I just implemented my own. Seems to work.
> >
> > In my code
> >         MyResizableBehavior resizableBehavior = new
> MyResizableBehavior();
> >         resizableBehavior.setStopEvent(new
> > MyResizableBehavior.AjaxResizeStopCallback() {
> >             @Override
> >             protected void resize(AjaxRequestTarget target, Component
> > source, int resizeHeight, int resizeWidth) {
> > ....
> >             }
> >
> >         });
> >
> >
> > public class MyResizableBehavior extends ResizableBehavior {
> >     public abstract static class AjaxResizeStopCallback extends
> > AbstractAjaxEventCallback
> >     {
> >         private static final long serialVersionUID = 1L;
> >
> >         public AjaxResizeStopCallback()
> >         {
> >             super("stop");
> >         }
> >
> >         @Override
> >         protected List<CallbackParameter> getExtraParameters()
> >         {
> >             List<CallbackParameter> ret = super.getExtraParameters();
> >             ret.add(CallbackParameter.resolved("resizeHeight",
> > ResizableBehavior.UI_SIZE
> >                     + ".height"));
> >             ret.add(CallbackParameter.resolved("resizeWidth",
> > ResizableBehavior.UI_SIZE + ".width"));
> >             return ret;
> >         }
> >
> >         @Override
> >         public final void call(AjaxRequestTarget target, Component
> source)
> >         {
> >             IRequestParameters req =
> > RequestCycle.get().getRequest().getRequestParameters();
> >
> >             int resizeHeight =
> > req.getParameterValue("resizeHeight").toInt(-1);
> >             int resizeWidth =
> > req.getParameterValue("resizeWidth").toInt(-1);
> >             resize(target, source, resizeHeight, resizeWidth);
> >         }
> >
> >         protected abstract void resize(AjaxRequestTarget target,
> Component
> > source,
> >                                        int resizeHeight, int
> resizeWidth);
> >     }
> >
> >
> >     public MyResizableBehavior
> > setStopEvent(MyResizableBehavior.AjaxResizeStopCallback callback){
> >
> >         setEventListener(callback);
> >         return this;
> >     }
> > }
> >
> >
> > On Wed, Jan 30, 2013 at 3:15 PM, Pieter Claassen <pieter@musmato.com>
> > wrote:
> >
> > > Ernesto,
> > >
> > > I cannot find any code in wiquery-6.2.0. that hooks into the stopEvent.
> > > The example you provided seems to still force a round trip on any
> change,
> > > not just on stopEvent.
> > >
> > > Maybe I am daft, but I don't see any code that does this? I assume one
> > can
> > > extend ResizableBehaviour and add the stopEvent code to hook into a
> > > callback, but I don't want to do this if this functionality already
> > exists
> > > and I just can't find it.
> > >
> > > Thanks for the help.
> > > Pieter
> > >
> > >
> > > On Wed, Jan 30, 2013 at 3:00 PM, Ernesto Reinaldo Barreiro <
> > > reiern70@gmail.com> wrote:
> > >
> > >> Pieter,
> > >>
> > >> Look at this example.
> > >>
> > >>
> > >>
> >
> http://antiliasoft.com/wiquery-plugins/?wicket:bookmarkablePage=:com.wiquery.plugins.demo.ResizablePage
> > >>
> > >> and click on the ? at the left corner/. It is exactly what you want...
> > >> Wiquery  already have a ResizableAjaxBehavior that hooks into
> stopEvent.
> > >> Fell free to copy or adapt it to your needs;-). Let me know if I can
> > >> further help you somehow.
> > >>
> > >> On Wed, Jan 30, 2013 at 2:46 PM, Pieter Claassen <pieter@musmato.com>
> > >> wrote:
> > >>
> > >> > Ernesto/Sebastien,
> > >> >
> > >> > I am stuck :-(
> > >> >
> > >> > Firstly, thanks for the resizablePanel in wicket-jquery-ui, but I
> have
> > >> to
> > >> > hold off until this code is implemented in a behavior since my
> > >> inheritance
> > >> > doesn't match your project (I cannot inherit from resizablePanel).
> > >> >
> > >> > I looked at what was available in wiquery and found the
> functionality
> > >> > there, except.....
> > >> >
> > >> > When I implement the code below, I force an ajax round-trip to the
> > >> service
> > >> > whenever the re-size event is triggered which is a lot during a
> > >> > panel re-size  This is not practical with the the model updates.
> > Ideally
> > >> > one would like to only update the position on stopEvents but the API
> > >> > provides only for the setting of a JavaScript callback on
> stopEvents.
> > >> >
> > >> > Does anybody have a suggestion on how to make this behavior
> > practically
> > >> > usable?
> > >> >
> > >> > Thanks,
> > >> > Pieter
> > >> >
> > >> >
> > >> >  ResizableBehavior resizableBehavior = new ResizableBehavior();
> > >> >     resizableBehavior.setResizeEvent(new
> > >> > ResizableBehavior.AjaxResizeCallback() {
> > >> >             @Override
> > >> >             protected void resize(AjaxRequestTarget target,
> Component
> > >> > source, int resizeHeight, int resizeWidth) {
> > >> >                 AdvancedFormatter advancedFormatter =
> > >> > questionBaseWebModel.getEntity().getStatement().getFormatter();
> > >> >                 advancedFormatter.setWidth((float)resizeWidth / 800
> *
> > >> 100);
> > >> >                 advancedFormatter.setHeight((float)resizeHeight);
> > >> >                 advancedFormatterFactory.save(advancedFormatter);
> > >> >             }
> > >> >
> > >> >         });
> > >> >
> > >> > This is available but only for JavaScript callbacks
> > >> >
> > >> >
> >  resizableBehavior.setStopEvent(JsScopeUiEvent.quickScope("alert();"));
> > >> >
> > >> >
> > >> >
> > >> >
> > >> >
> > >> > On Mon, Jan 28, 2013 at 8:28 AM, Ernesto Reinaldo Barreiro <
> > >> > reiern70@gmail.com> wrote:
> > >> >
> > >> > > Hi,
> > >> > >
> > >> > > On Mon, Jan 28, 2013 at 7:45 AM, Pieter Claassen <
> > pieter@musmato.com>
> > >> > > wrote:
> > >> > >
> > >> > > > This is a general best practice question. I am using
> > >> wicket-jquery-ui
> > >> > > > because I don't seem to be able to find a resizable panel
in the
> > >> > > > internal wicket ajax widgets.
> > >> > > >
> > >> > > > 1. Is there no problem loading new jquery libraries over
the
> > wicket
> > >> > > > implementation? What is best practice?
> > >> > > >
> > >> > >
> > >> > > Look at the existing jquery integrations and see what people
do?
> > >> > >
> > >> > >
> > >> > >
> > >> > > > 2. I am looking for a way to get the resized panels' x and
y
> size
> > >> > > > parameters into my wicket code? Any suggestions how to do
this?
> > >> > > >
> > >> > > > You have to:
> > >> > >
> > >> > > 1-Hook onto the client side events triggered by resize and use
> > >> > > Wicket.AJA.get/post to stream back the parameters.
> > >> > > 2-Attach and AJAX behavior at server side component and on respond
> > get
> > >> > and
> > >> > > parse those parameter.
> > >> > >
> > >> > > Examples?
> > >> > >
> > >> > >
> > >> > >
> > >> >
> > >>
> >
> https://github.com/WiQuery/wiquery/blob/master/wiquery-jquery-ui/src/main/java/org/odlabs/wiquery/ui/slider/AjaxSlider.java
> > >> > >
> > >> > >
> > >> >
> > >>
> >
> https://github.com/WiQuery/wiquery/blob/master/wiquery-jquery-ui/src/main/java/org/odlabs/wiquery/ui/tabs/Tabs.java
> > >> > >
> > >> > > or event better
> > >> > >
> > >> > >
> > >> > >
> > >> >
> > >>
> >
> https://github.com/WiQuery/wiquery/blob/master/wiquery-jquery-ui/src/main/java/org/odlabs/wiquery/ui/resizable/ResizableBehavior.java
> > >> > >
> > >> > > wihc already have that functionality (see AjaxResizeCallback)
> > >> > >
> > >> > >
> > >> > >
> > >> > > > Thanks,
> > >> > > > Pieter
> > >> > > >
> > >> > > >
> > >> ---------------------------------------------------------------------
> > >> > > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > >> > > > For additional commands, e-mail: users-help@wicket.apache.org
> > >> > > >
> > >> > > >
> > >> > >
> > >> > >
> > >> > > --
> > >> > > Regards - Ernesto Reinaldo Barreiro
> > >> > > Antilia Soft
> > >> > > http://antiliasoft.com/ <http://antiliasoft.com/antilia>
> > >> > >
> > >> >
> > >> >
> > >> >
> > >> > --
> > >> > - - - - - - - - - - - - - - - - - - - -
> > >> >   Pieter Claassen
> > >> >   Musmato B.V.
> > >> >   e: pieter.claassen@musmato.com
> > >> >   t: +31 877 848259
> > >> >   w: http://musmato.com
> > >> > - - - - - - - - - - - - - - - - - - - -
> > >> >
> > >>
> > >>
> > >>
> > >> --
> > >> Regards - Ernesto Reinaldo Barreiro
> > >> Antilia Soft
> > >> http://antiliasoft.com/ <http://antiliasoft.com/antilia>
> > >>
> > >
> > >
> > >
> > > --
> > > - - - - - - - - - - - - - - - - - - - -
> > >   Pieter Claassen
> > >   Musmato B.V.
> > >   e: pieter.claassen@musmato.com
> > >   t: +31 877 848259
> > >   w: http://musmato.com
> > > - - - - - - - - - - - - - - - - - - - -
> > >
> >
> >
> >
> > --
> > - - - - - - - - - - - - - - - - - - - -
> >   Pieter Claassen
> >   Musmato B.V.
> >   e: pieter.claassen@musmato.com
> >   t: +31 877 848259
> >   w: http://musmato.com
> > - - - - - - - - - - - - - - - - - - - -
> >
>
>
>
> --
> Regards - Ernesto Reinaldo Barreiro
> Antilia Soft
> http://antiliasoft.com/ <http://antiliasoft.com/antilia>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message