Each component also has a unique id in its relation to the page called a
path, so if you don't want to bother with setting the id itself you can
always use component.getpath() to get a unique id. Comes in handy in these
types of situations.

-Igor
 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> Eelco Hillenius
> Sent: Tuesday, August 23, 2005 1:07 PM
> To: wicket-user@lists.sourceforge.net
> Subject: Re: [Wicket-user] javascript and divIds
> 
> Or, if you want to set it programatically, you can attach an 
> AttributeModifier to it, like:
> 
> WebMarkupContainer c = new WebMarkupContainer("foo"); IModel 
> replacementModel = new Model("divId"); c.add(new 
> AttributeModifier("id", true, replacementModel)); add(c);
> 
> <div wicket:id="foo">bar</div>
> 
> And, as you probably need some javascript for this too, you 
> could even make this a nice custom component so that you can 
> drop this in any page without having to know anything more 
> about it. Best would be to use a Panel then:
> 
> public class MagicPanel extends Panel {
> 
>    public MagicPanel(String id, String targetId, IModel contents) {
>      super(id);
>      WebMarkupContainer c = new WebMarkupContainer("container");
>      IModel replacementModel = new Model(targetId);
>      c.add(new AttributeModifier("id", true, replacementModel));
>      c.add(new Label("contents", contents));
>      add(c);
>      addToHeader( new JavaScriptReference( .... your packaged 
> javascript file here ...) );
>    }
> }
> 
> <wicket:head>
>   <... javascript contribution here ...> </wicket:head> <wicket:panel>
>   <div wicket:id="container">
>    <span wicket:id="contents">blah</span>
>   </div>
> </wicket:panel>
> 
> 
> Just an example of course. But I hope it inspires you to play 
> around a bit :)
> 
> Eelco
> 
> 
> 
> On 8/23/05, Gwyn Evans <[EMAIL PROTECTED]> wrote:
> > Hi,
> >  I'm not sure I get what the issue might be, as (as I 
> understand it) 
> > Wicket will leave the "id" tag alone, so you'd just set it in your 
> > component's HTML and it should get rendered intact?
> > 
> > /Gwyn
> > 
> > On 23/08/05, flemming <[EMAIL PROTECTED]> wrote:
> > > Hi there
> > >
> > > First I would like to say that I think Wicket Rocks. I am an old 
> > > struts guy, so I can really see the advantages over struts.
> > >
> > >
> > > However some things are of course more easy to do with 
> Struts than wicket.
> > >
> > > In struts I have made a custom tag that gives me a panel with a 
> > > headline
> > >
> > > ============================
> > > |                                        show/hide btn div |
> > > ============================
> > > <div id="divId">                                    |
> > >  diff content that can be hided or        |
> > > shown.                                                  |
> > > </div>                                                   |
> > > ============================
> > >
> > > The show / hide functionality is implemented in javascript.
> > >
> > > Now the difficult thing for me is that I also want to make such a 
> > > component in Wicket.
> > >
> > > Can anybody tell me how I set the divId in the div?  I want that 
> > > when I click show/hide button onclick="toogleShowHide(divId);"
> > >
> > > The javascript I have just included in head tag. But I 
> need to make 
> > > sure that the divIds are the same within the same panel.
> > >
> > >
> > > Or am I doing it a wrong way? or perhaps a more easy way to do it?
> > >
> > >
> > > Regards
> > > Flemming Boller
> > >
> > 
> > 
> > -------------------------------------------------------
> > SF.Net email is Sponsored by the Better Software Conference & EXPO 
> > September 19-22, 2005 * San Francisco, CA * Development Lifecycle 
> > Practices Agile & Plan-Driven Development * Managing 
> Projects & Teams 
> > * Testing & QA Security * Process Improvement & Measurement * 
> > http://www.sqe.com/bsce5sf 
> > _______________________________________________
> > Wicket-user mailing list
> > Wicket-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/wicket-user
> >
> 
> 
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & 
> EXPO September 19-22, 2005 * San Francisco, CA * Development 
> Lifecycle Practices Agile & Plan-Driven Development * 
> Managing Projects & Teams * Testing & QA Security * Process 
> Improvement & Measurement * http://www.sqe.com/bsce5sf 
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
> 
> 
> 




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to