one is static, the other dynamic.

You can make setVisible more dynamic by doing it in page.onBeforeRender

Martijn

On Wed, Apr 1, 2009 at 11:42 AM, Boydens Joeri (OZ) <joeri.boyd...@oz.be> wrote:
>
> Is there prefered way between the methods below?
>
> if (condition) {
>        component.setVisible(false);
> }
>
> OR
>
> component {
> @Override
> public boolean isVisible() {
>        return !condition;
> }
>
> If I use the above I can group my components and set them with the
> setVisible method depending on the condition, with the last method I
> have to add the the condition to every component.
>
>
> -----Oorspronkelijk bericht-----
> Van: Daan van Etten [mailto:d...@stuq.nl]
> Verzonden: woensdag 1 april 2009 11:20
> Aan: users@wicket.apache.org
> Onderwerp: Re: clean way to add visibility constraints
>
> You could write a method that sets the visibility on the relevant
> components.
> The Form components have to be visible to that method though (or you
> have to use a visitor).
>
> Regards,
>
> Daan
>
> Op 1 apr 2009, om 08:32 heeft Boydens Joeri (OZ) het volgende
> geschreven:
>
>> Hi,
>>
>>
>>
>> I have this page where I have different components that need to be
>> show
>> or hidden, depending on the value of some model fields.  I implemented
>> this by overriding the isVisible method of the components.  Now I was
>> wondering if there is a less verbose way of handling this? (I can't
>> group the components because it's not possible in the html markup).
>>
>>
>>
>> item.add(new TextField("value") {
>>
>>                                         public boolean isVisible() {
>>
>>
>> OnlineBookingParametersArticle     article =
>> (OnlineBookingParametersArticle) getParent().getModel().getObject();
>>
>>                                               return
>> article.getArticle().getNumberInStock() > 0;
>>
>>                                         }
>>
>>                                   });
>>
>>
>>
>>                                   item.add(new
>> Label("article.numberOfArticlesLabel", "Geen beschikbaar") {
>>
>>                                         public boolean isVisible() {
>>
>>
>> OnlineBookingParametersArticle     article =
>> (OnlineBookingParametersArticle) getParent().getModel().getObject();
>>
>>                                               return
>> article.getArticle().getNumberInStock() <= 0;
>>
>>                                         }
>>
>>                                   });
>>
>>
>>
>>                                   item.add(new
>> Label("article.description"));
>>
>>
>>
>>                                   item.add(new
>> WebMarkupContainer("participantInfo") {
>>
>>                                                     public boolean
>> isVisible() {
>>
>>
>> OnlineBookingParametersArticle       article =
>> (OnlineBookingParametersArticle) getParent().getModel().getObject();
>>
>>                                                           return
>> article.getArticle().getNumberInStock() > 0;
>>
>>                                                     }
>>
>>                                               }
>>
>>                                               .add(new
>> Label("article.numberOfRequiredParticipants"))
>>
>>                                               .add(new
>> Label("article.maximumNumberOfParticipants")));
>>
>>
>>
>>
>>
>>                                   item.add(new Link("contactLink"){
>>
>>                                         @Override
>>
>>                                         public void onClick(){
>>
>>                                               //TODO : go to correct
>> page
>>
>>                                         }
>>
>>                                         @Override
>>
>>                                         public boolean isVisible() {
>>
>>
>> OnlineBookingParametersArticle     article =
>> (OnlineBookingParametersArticle) getParent().getModel().getObject();
>>
>>                                               return
>> article.getArticle().getNumberInStock() <= 0;
>>
>>                                         }
>>
>>                                   });
>>
>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.5 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

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

Reply via email to