First, i'd recommend you overriding isVisible method instead of
setting the visible flag, it gives you more flexibility. Second, you
shouldn't query the database in constructor, implement the
IDataProvider and let dataview deal with case when there are no items
in datatable. If you return empty list the dataview will be empty too.
-Matej
On 8/9/07, Johan Maasing <[EMAIL PROTECTED]> wrote:
> I am rather new to wicket, coming from a Tapestry angle. Anyway, my
> question is rather basic.
> I gather that all components on a page must be rendered?
> Suppose I have a common dataview with a dataprovider on a page, basic
> CRUD-stuff. My page constructor looks like this:
>
> try {
> ...query the database and build the provider and dataview
> } catch (SQLException e) {
> feedback.error("Very bad things happened");
> // What to do here??
> }
>
> What is the best practice for removing/disabling components in the
> catch clause? I can not create the dataview (called "dataview" in the
> HTML) since the backend has died but wicket needs a component there?
>
> Currently I do somehting like this
>
> } catch (Exception e) {
> add(new Label("dataview", "").setVisible(false));
> }
>
> and that works fine but it seems a bit un-DRY to have to add dummy
> components for the error case. Is my understanding correct?
>
> Cheers,
> /Johan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]