why don't you use a property model? That will handle null values for you.
And then specify a converter to the label itself so that it formats the date
as you want.

then you can just do this:

add(new Label("product-description", product.getDescription()));

add(new Label("product-photo-date", new PropertyModel(product, "
photo.dateTime")));
add(new Label("product-photo-time", new PropertyModel(product, "
photo.dateTime")));

But doesn't the product description of dates change after creation of that
label?
and also should product be kept into memory?

Then look at the Compound models (and you need BoundedCompound because you
want to display one property of product twice)
and the LoadableDetachable models to keep the product out of the session.

johan


On 11/24/06, Francisco Treacy <[EMAIL PROTECTED]> wrote:

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! 
Questions/Réponses<http://fr.rd.yahoo.com/evt=42054/*http://fr.answers.yahoo.com>
.

-------------------------------------------------------------------------
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



-------------------------------------------------------------------------
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