Well, if you use a wicket:id in the HTML, then you have to fill it - doing
nothing about it is invalid. So here you could either place an empty text
e.g:
 
if (product.getPhoto() != null) {
            add(new Label("product-photo-date",
CommonUtil.getFormattedDate(product.getPhoto().getDateTime())));
            add(new Label("product-photo-time",
CommonUtil.getFormattedTime(product.getPhoto().getDateTime())));
        }
else
{
     add(new Label("product-photo-date", ""));
            add(new Label("product-photo-time", ""));
}
 
or you make it a subelement of a parent that could be disabled... similar to
the method noted here:
http://cwiki.apache.org/WICKET/forms-with-dynamic-elements.html and here:
http://cwiki.apache.org/WICKET/create-dynamic-markup-hierarchies-using-panel
s.html
 
best Regards
 
 
 
 


  _____  

Von: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Im Auftrag von Francisco
Treacy
Gesendet: Freitag, 24. November 2006 15:30
An: wicket-user@lists.sourceforge.net
Betreff: [Wicket-user] question about showing components or not


Hi wicketers,

I would like to ask you what's the best way to perform the following:
Say I have Products. There are Products that have a Photo and there are
Products that don't.

        // Set data to the page
        add(new Label("product-description", product.getDescription()));
       
        if (product.getPhoto() != null) {
            add(new Label("product-photo-date",
CommonUtil.getFormattedDate(product.getPhoto().getDateTime())));
            add(new Label("product-photo-time",
CommonUtil.getFormattedTime(product.getPhoto().getDateTime())));
        }

In my html i have 

<span wicket:id="product-description">[product-description]</span>
(eventually add something here)
<span wicket:id="product-photo-date">[product-photo-date]</span>
<span wicket:id="product-photo-time">[product-photo-time]</span>
(eventually add something here)

And Wicket will complain if product.getPhoto() is null, of course, cause
product-photo-date and product-photo-time were never added to the page
component.

I really don't see how to avoid this check, or how to solve this elegantly.
Perhaps missing something obvious, hope not :)

And afaik the useComponentUseCheck setting at application level checks the
other way round (if elements declared in java Page are marked-up in html
code). Anyway, I have it set to false.

Thanks in advance, and thanks as well for such a nice web framework,

Francisco


  _____  

Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions !
Profitez des connaissances, des opinions et des expériences des internautes
sur Yahoo!  <http://fr.rd.yahoo.com/evt=42054/*http://fr.answers.yahoo.com>
Questions/Réponses.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to