You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Matthew Young <gi...@gmail.com> on 2008/03/19 21:44:08 UTC

does not work with HeaderContributor.forCss()?

Hi, I am finding that <wicket:component> doesn't add stylesheet link in
<head> from add(HeaderContributor). Is there any way to make it work?

I want to use <wicket:component> because can I add border around without
changing my component hierarchy.  If I add my border component in .java, it
works as expected but is something I rather not do in this situation:  I am
adding border around in base page and I don't want the child page to know
and just work as if no border component is added.

Here is a small case to demonstrate:

SomePage.java

import org.apache.wicket.markup.html.WebPage;

public class SomePage extends WebPage {
    public SomePage() {
//        add(new MyBorder("box"));   // this work
    }

}


SomePage.html

<html>
<head></head>
<body>
    <wicket:component class="com.mycompany.MyBorder">
        <p>You should see a yellow background<br/>
           and a red border</p>
    </wicket:component>

<!--    <span wicket:id="box">This is a box</span> -->  <!-- if this is use,
stylesheet show up -->
</body>
</html>


MyBorder.java

public class MyBorder extends Border {
    private static final long serialVersionUID = 1L;
    public MyBorder(String id)  {
        super(id);
        add(getCssContributor());
    }

    protected HeaderContributor getCssContributor()  {
        return HeaderContributor.forCss(MyBorder.class, "style.css");
    }
}


MyBorder.html

<html>
  <body>
    <wicket:border>
      <div class="box_me_up">
         <wicket:body/>
      </div>
    </wicket:border>
  </body>
</html>


style.css

.box_me_up {
    margin: 5px;
    padding: 5px;
    background: yellow;
    border: 2px solid red;
}

Re: does not work with HeaderContributor.forCss()?

Posted by Igor Vaynberg <ig...@gmail.com>.
On Wed, Mar 19, 2008 at 4:32 PM, Matthew Young <gi...@gmail.com> wrote:
> If not <wicket:component>, how can I introduce wrapping border component
>  around <wicket:child> without changing component hierarchy? As I said
>  before, I want my child page to not have to know.


you can write your own tags like wicket:message and wicket:component.
see wicketmessageresolver or wicketmessagetaghandler for examples.
this part of wicket is pretty open.

>  Just curious, what is the reason for getting rid of <wicket:component>?

it has always been only experimental. and it has always gone somewhat
against our philosophy.

-igor



>
>  On Wed, Mar 19, 2008 at 2:47 PM, Igor Vaynberg <ig...@gmail.com>
>  wrote:
>
>
>
>  > sorry, but we do not support wicket:component. in fact i thought it
>  > was already removed long ago...
>  >
>  > -igor
>  >
>  >
>  > On Wed, Mar 19, 2008 at 1:44 PM, Matthew Young <gi...@gmail.com> wrote:
>  > > Hi, I am finding that <wicket:component> doesn't add stylesheet link in
>  > >  <head> from add(HeaderContributor). Is there any way to make it work?
>  > >
>  > >  I want to use <wicket:component> because can I add border around
>  > without
>  > >  changing my component hierarchy.  If I add my border component in
>  > .java, it
>  > >  works as expected but is something I rather not do in this situation:
>  >  I am
>  > >  adding border around in base page and I don't want the child page to
>  > know
>  > >  and just work as if no border component is added.
>  > >
>  > >  Here is a small case to demonstrate:
>  > >
>  > >  SomePage.java
>  > >
>  > >  import org.apache.wicket.markup.html.WebPage;
>  > >
>  > >  public class SomePage extends WebPage {
>  > >     public SomePage() {
>  > >  //        add(new MyBorder("box"));   // this work
>  > >     }
>  > >
>  > >  }
>  > >
>  > >
>  > >  SomePage.html
>  > >
>  > >  <html>
>  > >  <head></head>
>  > >  <body>
>  > >     <wicket:component class="com.mycompany.MyBorder">
>  > >         <p>You should see a yellow background<br/>
>  > >            and a red border</p>
>  > >     </wicket:component>
>  > >
>  > >  <!--    <span wicket:id="box">This is a box</span> -->  <!-- if this is
>  > use,
>  > >  stylesheet show up -->
>  > >  </body>
>  > >  </html>
>  > >
>  > >
>  > >  MyBorder.java
>  > >
>  > >  public class MyBorder extends Border {
>  > >     private static final long serialVersionUID = 1L;
>  > >     public MyBorder(String id)  {
>  > >         super(id);
>  > >         add(getCssContributor());
>  > >     }
>  > >
>  > >     protected HeaderContributor getCssContributor()  {
>  > >         return HeaderContributor.forCss(MyBorder.class, "style.css");
>  > >     }
>  > >  }
>  > >
>  > >
>  > >  MyBorder.html
>  > >
>  > >  <html>
>  > >   <body>
>  > >     <wicket:border>
>  > >       <div class="box_me_up">
>  > >          <wicket:body/>
>  > >       </div>
>  > >     </wicket:border>
>  > >   </body>
>  > >  </html>
>  > >
>  > >
>  > >  style.css
>  > >
>  > >  .box_me_up {
>  > >     margin: 5px;
>  > >     padding: 5px;
>  > >     background: yellow;
>  > >     border: 2px solid red;
>  > >  }
>  > >
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  > For additional commands, e-mail: users-help@wicket.apache.org
>  >
>  >
>

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


Re: does not work with HeaderContributor.forCss()?

Posted by Matthew Young <gi...@gmail.com>.
If not <wicket:component>, how can I introduce wrapping border component
around <wicket:child> without changing component hierarchy? As I said
before, I want my child page to not have to know.

Just curious, what is the reason for getting rid of <wicket:component>?

On Wed, Mar 19, 2008 at 2:47 PM, Igor Vaynberg <ig...@gmail.com>
wrote:

> sorry, but we do not support wicket:component. in fact i thought it
> was already removed long ago...
>
> -igor
>
>
> On Wed, Mar 19, 2008 at 1:44 PM, Matthew Young <gi...@gmail.com> wrote:
> > Hi, I am finding that <wicket:component> doesn't add stylesheet link in
> >  <head> from add(HeaderContributor). Is there any way to make it work?
> >
> >  I want to use <wicket:component> because can I add border around
> without
> >  changing my component hierarchy.  If I add my border component in
> .java, it
> >  works as expected but is something I rather not do in this situation:
>  I am
> >  adding border around in base page and I don't want the child page to
> know
> >  and just work as if no border component is added.
> >
> >  Here is a small case to demonstrate:
> >
> >  SomePage.java
> >
> >  import org.apache.wicket.markup.html.WebPage;
> >
> >  public class SomePage extends WebPage {
> >     public SomePage() {
> >  //        add(new MyBorder("box"));   // this work
> >     }
> >
> >  }
> >
> >
> >  SomePage.html
> >
> >  <html>
> >  <head></head>
> >  <body>
> >     <wicket:component class="com.mycompany.MyBorder">
> >         <p>You should see a yellow background<br/>
> >            and a red border</p>
> >     </wicket:component>
> >
> >  <!--    <span wicket:id="box">This is a box</span> -->  <!-- if this is
> use,
> >  stylesheet show up -->
> >  </body>
> >  </html>
> >
> >
> >  MyBorder.java
> >
> >  public class MyBorder extends Border {
> >     private static final long serialVersionUID = 1L;
> >     public MyBorder(String id)  {
> >         super(id);
> >         add(getCssContributor());
> >     }
> >
> >     protected HeaderContributor getCssContributor()  {
> >         return HeaderContributor.forCss(MyBorder.class, "style.css");
> >     }
> >  }
> >
> >
> >  MyBorder.html
> >
> >  <html>
> >   <body>
> >     <wicket:border>
> >       <div class="box_me_up">
> >          <wicket:body/>
> >       </div>
> >     </wicket:border>
> >   </body>
> >  </html>
> >
> >
> >  style.css
> >
> >  .box_me_up {
> >     margin: 5px;
> >     padding: 5px;
> >     background: yellow;
> >     border: 2px solid red;
> >  }
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: does not work with HeaderContributor.forCss()?

Posted by Igor Vaynberg <ig...@gmail.com>.
sorry, but we do not support wicket:component. in fact i thought it
was already removed long ago...

-igor


On Wed, Mar 19, 2008 at 1:44 PM, Matthew Young <gi...@gmail.com> wrote:
> Hi, I am finding that <wicket:component> doesn't add stylesheet link in
>  <head> from add(HeaderContributor). Is there any way to make it work?
>
>  I want to use <wicket:component> because can I add border around without
>  changing my component hierarchy.  If I add my border component in .java, it
>  works as expected but is something I rather not do in this situation:  I am
>  adding border around in base page and I don't want the child page to know
>  and just work as if no border component is added.
>
>  Here is a small case to demonstrate:
>
>  SomePage.java
>
>  import org.apache.wicket.markup.html.WebPage;
>
>  public class SomePage extends WebPage {
>     public SomePage() {
>  //        add(new MyBorder("box"));   // this work
>     }
>
>  }
>
>
>  SomePage.html
>
>  <html>
>  <head></head>
>  <body>
>     <wicket:component class="com.mycompany.MyBorder">
>         <p>You should see a yellow background<br/>
>            and a red border</p>
>     </wicket:component>
>
>  <!--    <span wicket:id="box">This is a box</span> -->  <!-- if this is use,
>  stylesheet show up -->
>  </body>
>  </html>
>
>
>  MyBorder.java
>
>  public class MyBorder extends Border {
>     private static final long serialVersionUID = 1L;
>     public MyBorder(String id)  {
>         super(id);
>         add(getCssContributor());
>     }
>
>     protected HeaderContributor getCssContributor()  {
>         return HeaderContributor.forCss(MyBorder.class, "style.css");
>     }
>  }
>
>
>  MyBorder.html
>
>  <html>
>   <body>
>     <wicket:border>
>       <div class="box_me_up">
>          <wicket:body/>
>       </div>
>     </wicket:border>
>   </body>
>  </html>
>
>
>  style.css
>
>  .box_me_up {
>     margin: 5px;
>     padding: 5px;
>     background: yellow;
>     border: 2px solid red;
>  }
>

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