Thanks Scott. I'll have a look into it tonight (10 hours from now). Juergen
On 11/24/05, Scott Sauyet <[EMAIL PROTECTED]> wrote: > Juergen Donnerstag wrote: > >>I don't know if my use-case is enough of a reason to clutter up the > >>interface of WebPage. I also don't know if there is a reason to widen > >>this facility beyond adding AttributeModifiers. But for what it's > >>worth, here is my simple suggestion. > > > > > > Honestly, I'm not in favour of cluttering the interface. What about an > > Interface with one method which if your Page implements it, the method > > is called. That method could be addBodyAttributeModifier. Thus, we do > > not clutter the interface, but it is far less obvious for wicket user > > what to do to achieve it => good javadoc/wiki > > Attached is another patch doing something similar to this suggestion. I > added wicket.markup.html.IBodyTagContributor with the method > > public AttributeModifier[] getBodyAttributeModifiers(); > > I couldn't really use addBodyAttributeModifier(), as it's > BodyOnLoadContainer which is going to be calling the interface. > > I'm not sure if it's more Wicketish to return an array like this or a > List. (I haven't really used Java 1.5 much, but this is one place where > I really long for the generic version with List<AttributeModifier>.) > > Thanks for the pointer. This solution feels much more acceptable to me. > I still don't know if there is any reason to expand on this, but now > it's easy to simply expand the interface, although I suppose that needs > to be done before the interface is made public. > > -- Scott > > > Index: src/java/wicket/markup/html/BodyOnLoadContainer.java > =================================================================== > --- src/java/wicket/markup/html/BodyOnLoadContainer.java (revision 103) > +++ src/java/wicket/markup/html/BodyOnLoadContainer.java (working copy) > @@ -75,6 +75,13 @@ > { > add(new AttributeModifier("onload", true, new > Model(onLoad))); > } > + if (this.getPage() instanceof IBodyTagContributor) { > + IBodyTagContributor bodyContributor = (IBodyTagContributor) > this.getPage(); > + AttributeModifier[] modifiers = > bodyContributor.getBodyAttributeModifiers(); > + for (int i = 0; i < modifiers.length; i++) { > + add(modifiers[i]); > + } > + } > } > > // go on with default implementation > Index: src/java/wicket/markup/html/IBodyTagContributor.java > =================================================================== > --- src/java/wicket/markup/html/IBodyTagContributor.java (revision 0) > +++ src/java/wicket/markup/html/IBodyTagContributor.java (revision 0) > @@ -0,0 +1,38 @@ > +/* > + * $Id$ > + * $Revision$ > + * > + * > ============================================================================== > + * Licensed under the Apache License, Version 2.0 (the "License"); you may > not > + * use this file except in compliance with the License. You may obtain a > copy of > + * the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in writing, software > + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT > + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the > + * License for the specific language governing permissions and limitations > under > + * the License. > + */ > +package wicket.markup.html; > + > +import wicket.AttributeModifier; > + > + > +/** > + * An interface to be implemented by components which are able to add > + * information to the body tag associated with the markup. > + * > + * @author Scott Sauyet > + */ > +public interface IBodyTagContributor > +{ > + /** > + * Fetch a list of [EMAIL PROTECTED] wicket.AttributeModifier > AttributeModifiers} for > + * the body tag. > + * > + * @return all AttributeModifiers which contribute to the <BODY> > tag. > + */ > + public AttributeModifier[] getBodyAttributeModifiers(); > +} > > > ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_idv37&alloc_id865&op=click _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user