Alright, this is my last try replying with MS Outlook. =) And I will also add 
more info to help with this thread.

You can use borders to acomplish what you want. Here's an example:

#JAVA
public abstract class ConditionalHiddenBorder extends Border {

   public ConditionalHiddenBorder(String id) {
      super(id);
   }

   public abstract boolean isVisible();

}

#HTML
   <html>
   <body>
     <wicket:border>
       <wicket:body/>
     </wicket:border>
   </body>
   </html>

#EXAMPLE (Wicket's Quickstart)
   public HomePage() {
      final Label label = new Label("message", "If you see this message wicket 
is properly configured and running");
      ConditionalHiddenBorder chb = new ConditionalHiddenBorder("border") {

         public boolean isVisible() {
            return label.getDefaultModelObject() != null;
         }
      };
      chb.add(label);
      add(chb);
   }

#HTML Example
        <div wicket:id="border">
                <span wicket:id="message">message will be here</span>
        </div>

Hope this reply works!

cheers,
Bruno

-----Original Message-----
From: kan [mailto:[EMAIL PROTECTED]
Sent: Monday, December 01, 2008 9:03 AM
To: users@wicket.apache.org
Subject: make invisible if model object is null


I use the next construction very often:

[markup]
<wicket:enclosure child="something">
<p>Something here, description, comments etc: <span
wicket:id="somethinig"></span></p>
</wicket:enclosure>

[java]
add(new Label("something")
{
        @Override
        public boolean isVisible() {
                return super.isVisible() && getDefaultModelObject() != null;
        }
});

And there are a lot different components which should be hidden with
some arounding text if they have null value of model object.
How to make this more elegant?
First obvious way - inherit from Label, and make something
LabelInvisibleNull, but it is very bad, because a lot different
components (not only Label, but Image, WebMarkupContainer, some my
custom components, etc) require this behavior.
Second - more meaningful - make a IBehavior. But it doesn't work. In
"bind" is to early to check model, but in "beforeRender" is too late
to change visibility.
Is there any other option?


-- 
WBR, kan.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

***************************************************************************************************
"Atenção: Esta mensagem foi enviada para uso exclusivo do(s) destinatários(s) 
acima identificado(s),
podendo conter informações e/ou documentos confidencias/privilegiados e seu 
sigilo é protegido por 
lei. Caso você tenha recebido por engano, por favor, informe o remetente e 
apague-a de seu sistema.
Notificamos que é proibido por lei a sua retenção, disseminação, distribuição, 
cópia ou uso sem 
expressa autorização do remetente. Opiniões pessoais do remetente não refletem, 
necessariamente, 
o ponto de vista da CETIP, o qual é divulgado somente por pessoas autorizadas."


"Warning: This message was sent for exclusive use of the addressees above 
identified, possibly 
containing information and or privileged/confidential documents whose content 
is protected by law. 
In case you have mistakenly received it, please notify the sender and delete it 
from your system. 
Be noticed that the law forbids the retention, dissemination, distribution, 
copy or use without 
express authorization from the sender. Personal opinions of the sender do not 
necessarily reflect 
CETIP's point of view, which is only divulged by authorized personnel."
***************************************************************************************************

Reply via email to