Thanks,

I'm putting it in the book as well :-). I was busy writing and this
struck a bit of inspiration...

Martijn

On 2/19/06, Christian Hvid <[EMAIL PROTECTED]> wrote:
> It works. Perfect.
>
> On 19 Feb 2006, at 14:51, Martijn Dashorst wrote:
>
> > Use an AttributeModifier for this:
> >
> > label1.add(new AttributeModifier("class", true, new Model() {
> >     Object getObject(Component comp) {
> >         return Math.random()>0.5 ? "SomeClass" : "AnotherClass";
> >     }
> > });
> >
> > Martijn
> >
> > On 2/19/06, Christian Hvid <[EMAIL PROTECTED]> wrote:
> >> Hi wicket list.
> >>
> >> I am trying to set the class attribute of a wicket component:
> >>
> >> <html>
> >> <body>
> >> <span wicket:id="label1">...</span>
> >> </body>
> >> </html>
> >>
> >> public class MyPage extends WebPage {
> >>    private Label label1;
> >>    public MyPage() {
> >>      add(label1 = new Label("label1", "some text"));
> >>
> >>      // How do I do this vvvvv ?
> >>
> >>      if (Math.random() > 0.5) label1.setStyleClass("SomeClass");
> >>      else label1.setStyleClass("AnotherClass");
> >>
> >>      // ???
> >>    }
> >> }
> >>
> >> I want it to render as either:
> >>
> >> <html>
> >> <body>
> >> <span class="SomeClass">some text</span>
> >> </body>
> >> </html>
> >>
> >> or:
> >>
> >> <html>
> >> <body>
> >> <span class="AnotherClass">some text</span>
> >> </body>
> >> </html>
> >>
> >> Can anyone help?
> >>
> >> Thanks in advance.
> >>
> >> And thanks for a good looking web framework.
> >>
> >> -- Christian
> >>
> >>
> >>
> >> -------------------------------------------------------
> >> 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://sel.as-us.falkag.net/sel?
> >> cmd=lnk&kid=103432&bid=230486&dat=121642
> >> _______________________________________________
> >> Wicket-user mailing list
> >> [email protected]
> >> https://lists.sourceforge.net/lists/listinfo/wicket-user
> >>
> >
> >
> > --
> > Living a wicket life...
> >
> > Martijn Dashorst - http://www.jroller.com/page/dashorst
> >
> > Wicket 1.1.1 is out: http://wicket.sourceforge.net/wicket-1.1
> >
> >
> > -------------------------------------------------------
> > 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://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
> > _______________________________________________
> > Wicket-user mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>
>
> -------------------------------------------------------
> 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://sel.as-us.falkag.net/sel?cmdlnk&kid3432&bid#0486&dat1642
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>


--
Living a wicket life...

Martijn Dashorst - http://www.jroller.com/page/dashorst

Wicket 1.1.1 is out: http://wicket.sourceforge.net/wicket-1.1


-------------------------------------------------------
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://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to