You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Anna Simbirtsev <as...@gmail.com> on 2010/01/22 22:17:12 UTC

Using SimpleAttributeModifier

Hi,

I am trying to use SimpleAttributeModifier to make an ADD MORE link
invisible once the maximum number of text fields that it adds have been
reached.
But I can not get it to render the link component.

My code:

 addLink = new AjaxSubmitLink("addRow", form) {

            private static final long serialVersionUID =
8103461308100688184L;

            @Override
            public void onSubmit(AjaxRequestTarget target, Form<?> form) {
                 if (tech_count < max_tech_contacts) {
                     lv.getModelObject().add(new String());
                     if (target != null) {
                         target.addComponent(
techPanel);
                         tech_count++;
                     }
                     if (tech_count >= max_tech_contacts)
                         addLink.add(new SimpleAttributeModifier( "style",
"display:none"));
                 }
            }
  };
 addLink.setDefaultFormProcessing(false);
 form.add(addLink);

I am guessing it adds style="display:none" to the addLink, but does not
render it again, so the link is still visible.

Thanks,
Anna

Re: Using SimpleAttributeModifier

Posted by Anna Simbirtsev <as...@gmail.com>.
Thanks a lot, it worked.:)

On Fri, Jan 22, 2010 at 4:24 PM, Sven Meier <sv...@meiers.net> wrote:

> target.addComponent(addLink) ??
>
> BTW you could override isVisible() and getOutputMarkupPlaceholderTag()
> instead of the attribute modifier.
>
> Sven
>
>
> Anna Simbirtsev wrote:
>
>> Hi,
>>
>> I am trying to use SimpleAttributeModifier to make an ADD MORE link
>> invisible once the maximum number of text fields that it adds have been
>> reached.
>> But I can not get it to render the link component.
>>
>> My code:
>>
>>  addLink = new AjaxSubmitLink("addRow", form) {
>>
>>            private static final long serialVersionUID =
>> 8103461308100688184L;
>>
>>            @Override
>>            public void onSubmit(AjaxRequestTarget target, Form<?> form) {
>>                 if (tech_count < max_tech_contacts) {
>>                     lv.getModelObject().add(new String());
>>                     if (target != null) {
>>                         target.addComponent(
>> techPanel);
>>                         tech_count++;
>>                     }
>>                     if (tech_count >= max_tech_contacts)
>>                         addLink.add(new SimpleAttributeModifier( "style",
>> "display:none"));
>>                 }
>>            }
>>  };
>>  addLink.setDefaultFormProcessing(false);
>>  form.add(addLink);
>>
>> I am guessing it adds style="display:none" to the addLink, but does not
>> render it again, so the link is still visible.
>>
>> Thanks,
>> Anna
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Anna Simbirtsev
(416) 729-7331

Re: Using SimpleAttributeModifier

Posted by Sven Meier <sv...@meiers.net>.
target.addComponent(addLink) ??

BTW you could override isVisible() and getOutputMarkupPlaceholderTag() instead of the attribute modifier.

Sven

Anna Simbirtsev wrote:
> Hi,
>
> I am trying to use SimpleAttributeModifier to make an ADD MORE link
> invisible once the maximum number of text fields that it adds have been
> reached.
> But I can not get it to render the link component.
>
> My code:
>
>  addLink = new AjaxSubmitLink("addRow", form) {
>
>             private static final long serialVersionUID =
> 8103461308100688184L;
>
>             @Override
>             public void onSubmit(AjaxRequestTarget target, Form<?> form) {
>                  if (tech_count < max_tech_contacts) {
>                      lv.getModelObject().add(new String());
>                      if (target != null) {
>                          target.addComponent(
> techPanel);
>                          tech_count++;
>                      }
>                      if (tech_count >= max_tech_contacts)
>                          addLink.add(new SimpleAttributeModifier( "style",
> "display:none"));
>                  }
>             }
>   };
>  addLink.setDefaultFormProcessing(false);
>  form.add(addLink);
>
> I am guessing it adds style="display:none" to the addLink, but does not
> render it again, so the link is still visible.
>
> Thanks,
> Anna
>
>   


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