One thing that would be lost without having a mandatory prefix is the runtime checking that every component in the html has a coresponding java component.

 

i.e. anything with id=’wicket-whatever’ MUST have a component bound to it.

 

I don’t think that is any great loss.

 

Cameron

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gili
Sent: Saturday, 12 March 2005 2:25 AM
To: [email protected]
Subject: RE: [Wicket-develop] Wicket prefix

 


Your web design team that knows nothing about Wicket need know nothing. Their preexisting methods that pick up tags by their IDs will keep on working assuming they are working with static HTML. I am only discussing what happens with dynamically generated code and its IDs.

I don't understand the strong reluctance to have developers create new components like this:

Label myLabel = new Label("wicket-label1", "This is my label text");

versus

Label myLabel = new Label("label1", "This is my label text");

Remember, your Java developers can create components and assign them any variable names they wish. The only thing they would need to change is the "binding name" and insert "wicket-" into it. I really don't think this has anything to do with naming conventions. Java developers can call their own variables whatever they want. Obviously there needs to be some sort of contract when interfacing outside their bounds (the markup). And I mean, you're already doing this! Right now you're coding:

Label myLabel = new Label("label1", "This is my label text");

but if your component ends up generating any JS or CSS it needs to be smart enough to insert "wicket-" in front of it. Either way you have to be aware of this prefix issue which is why I'm saying we might as well give the developer full-control over it.

As for the prefix being a "best-practice", I think that is a subjective matter. We should really leave it up to developers to name their variables any way they see fit. I know of no programming language that imposes prefixes on variable names. Why start now?

Gili

--Original Message Text---
From: Christopher Turner
Date: Fri, 11 Mar 2005 10:02:11 +0100

Perhaps I was not being 100% clear. My web page design team know NOTHING about wicket. I want them free to use any HTML or _javascript_ constructs that they wish, be able to utilise their existing library of _javascript_ functions (with whatever ids these already use) and tools and so on. I don't want to enforce any particular programming style, naming convention or anything on them. I would prefer that they just get on with their job of writing good looking pages. In the same way I want my development team to just worry about writing good quality Java code without having to worry about component naming conventions and so on - I want them to call a name component "name" component, not some weird made up name just in case the web team happened to already have taken the name id.

Having the wicket prefix is therefore essential for binding together the HTML pages and the Java components in a way that doesn't cause name clashes and which also makes it obvious which tags in the HTML are bound to wicket components and which is not.

Regardless of the above I would suggest that it is 'best practice' to use the wicket prefix anyway even as a sole developer. Even as a single developer working on a project, were I to leave my company then it would be much easier for another developer to pick the code and HTML up after I was gone and be immediately able to see which HTML tags bind to Wicket components and which do not. Not having the wicket prefix (or whatever you choose to call it) visible in the HTML source is a bit like writing code without comments - the only way you can understand how it works is to open all the files and look for where identical names are used!

Regards,
Chris

Reply via email to