You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Iain Reddick <ia...@beatsystems.com> on 2009/07/30 19:55:30 UTC

Components and nullable data

Hi all,

One of the difficulties I am finding with wicket is the best practice 
when displaying/using data that is potentially null.

Example:

I have a "user" object which has a nullable "group" property. I want to 
show a link to the group details page when the "group" property is not 
null, but show nothing otherwise (let's keep this simple).

My issue is that either way, I have to construct the link component and 
add it to the page, whether I want it is visible or not. This is tricky 
at the best of times, as I must always carry out a lot of  "is null" logic.

The construction issue becomes multiplied if I want the same behaviour 
on a stateful page (i.e. the link, etc. can be appropriate for linking 
to the group, or be null and not visible and can switch between the two 
states).

My question is - am I missing something, or do I just need to have a 
better strategy for this type of situation?

If the answer is the latter, does anyone have any tips and/or components 
that would cut down on the extra coding?

Thanks

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


Re: Components and nullable data

Posted by Igor Vaynberg <ig...@gmail.com>.
add(new Link<User>("editgroup", user) {
  onclick() {
   ...
  }

  isvisible() {
   return user.getgroup()!=null;
  }
}

?

-igor

2009/7/30 Iain Reddick <ia...@beatsystems.com>:
> Hi all,
>
> One of the difficulties I am finding with wicket is the best practice when
> displaying/using data that is potentially null.
>
> Example:
>
> I have a "user" object which has a nullable "group" property. I want to show
> a link to the group details page when the "group" property is not null, but
> show nothing otherwise (let's keep this simple).
>
> My issue is that either way, I have to construct the link component and add
> it to the page, whether I want it is visible or not. This is tricky at the
> best of times, as I must always carry out a lot of  "is null" logic.
>
> The construction issue becomes multiplied if I want the same behaviour on a
> stateful page (i.e. the link, etc. can be appropriate for linking to the
> group, or be null and not visible and can switch between the two states).
>
> My question is - am I missing something, or do I just need to have a better
> strategy for this type of situation?
>
> If the answer is the latter, does anyone have any tips and/or components
> that would cut down on the extra coding?
>
> Thanks
>
> ---------------------------------------------------------------------
> 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