Re: Design of components utilizing JS, was: Wicket and JQuery - lavalamp

2009-08-17 Thread Joseph Pachod



m a totally newbie in the JS domain so your ramark really helps me
learning this stuff.
  

Have a look at http://docs.jquery.com/Plugins/Authoring

It provides lot of interesting hints on how to write jQuery plugins :)

++

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Design of components utilizing JS, was: Wicket and JQuery - lavalamp

2009-08-16 Thread Uwe Schäfer

Eyal Golan schrieb:

hi Eyal


Hi all,I've created a small Wicket module for the lavalamp JQuery library
(some links below).


nice. why not on wicketstuff?


Please be kind and give me any suggestion and insights.


i just looked at it quickly, but two things strike me:

1st: afaik you should not use
$(document).ready(... as it would break compatibility with other JS 
frameworks redefining the $


jQuery(document).ready(...
or

(function($) { /* some code that uses $ */ })(jQuery)

would be better. please keep in mind, you only contribute one component 
to the page, so there might be a bunch of others ;)


2nd is more general and valid with about any wicket component that uses 
a JS lib. I´m making the jQuery case here:


as it is a good practice to add functions (aka plugins) to the jQuery 
object, including the jQuery script more than once in a page is not only 
 useless waste of bandwidth and lowers user experience, but does 
severel harm (last wins).


so adding your component to a page potentially breaks most of the nice 
other components that relied on plugins loaded before your (bundled) 
jQuery script.


duh!

there is only one way out, i think. as we all know that wicket is clever 
enough to sort out duplicate header contributors, we should make use of 
them!


so, what we could do instead of bundling jquery with every damn 
component whould be to just express the dependency to it.
i suggest to use wicketstuff-core/jslibraries in order to have a common 
ground to create these header contributors.


so instead of

CompressedResourceReference JQUERY_JS = new 
CompressedResourceReference(			JQueryLavaLampBehavior.class, jquery.js);

response.renderJavascriptReference(JQUERY_JS);

you could simply put
add(JSLib.getHeaderContribution(VersionDescriptor
.alwayLatest(Library.JQUERY));
into your component, and make our lives much easier.

advertisment
a good side effect is to give the user of your component a chance to use 
a CDN instead of a bundled version to optimize loadtime

/advertisment

cu uwe

oh, and PS: i don´t get LockButton/ResetButton/validate in the global 
namespace?! (see jquery.lavalamp.js) :)


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Design of components utilizing JS, was: Wicket and JQuery - lavalamp

2009-08-16 Thread egolan74


Uwe Schäfer-2 wrote:
 
 nice. why not on wicketstuff?
 

I'll be glad putting it there. It's my intention.
I've checked out wicketstuff. Should I just add my code and check in?
Who should I contact to about this?


Uwe Schäfer-2 wrote:
 
 1st: afaik you should not use
 $(document).ready(... as it would break compatibility with other JS 
 frameworks redefining the $
 
 jQuery(document).ready(...
 or
 
 (function($) { /* some code that uses $ */ })(jQuery)
 
 would be better. please keep in mind, you only contribute one component 
 to the page, so there might be a bunch of others ;)
 
I am a totally newbie in the JS domain so your ramark really helps me
learning this stuff.


Uwe Schäfer-2 wrote:
 
 as it is a good practice to add functions (aka plugins) to the jQuery 
 object, including the jQuery script more than once in a page is not only 
   useless waste of bandwidth and lowers user experience, but does 
 severel harm (last wins).
 

I think that when I add it to the wicketstuff-jquery module, this problem
will vanish.
I've noticed that the parent behavior of the Wicket-JQuery checks (in the
responseHead method) checks if it's already been added.
My behavior will extend this one so it shouldn't harm anything.

Or am I wrong?


Uwe Schäfer-2 wrote:
 
 oh, and PS: i don´t get LockButton/ResetButton/validate in the global 
 namespace?! (see jquery.lavalamp.js) :)
 

I'll look into that as well.

And many thanks.

I'll tell you the truth, I'm pretty exited adding a (even as small as it is)
module and to contribute something I picked up...

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



-
Eyal Golan
egola...@gmail.com

Visit:  http://jvdrums.sourceforge.net/ JVDrums 
LinkedIn:  http://www.linkedin.com/in/egolan74 LinkedIn 
-- 
View this message in context: 
http://www.nabble.com/Wicket-and-JQuery---lavalamp-tp24985566p24993063.html
Sent from the Wicket - User 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