wicket-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Makundi <martin.maku...@koodaripalvelut.com>
Subject Re: isVisibleInHierarchy() possibly unnecessarily checks children whose parents are invisible?
Date Sun, 14 Nov 2010 20:01:10 GMT
Hi!

The fix I proposed does fix the probelm at hand but it makes page
rendering tremendeously slow due to the recursion:


Component componentParent = component.getParent();

is a recursive call that will be called O(n^n) times in hierarcy.


Something else must be proposed to fix this? The isEnabledInHierarchty
uses a caching mechanism. Maybe this will also need to cache the
"isparentvisible" at each level thus avoiding O(n^n) recursion.

Any suggestions how to speed it up?

**
Maritin



2010/11/13 Martin Makundi <martin.makundi@koodaripalvelut.com>:
> Hi!
>
> Created jira issue at https://issues.apache.org/jira/browse/WICKET-3166
>
> 2010/11/12 Martin Makundi <martin.makundi@koodaripalvelut.com>:
>> Hi!
>>
>> I have a page with two panels:
>>
>> page.add(panel1);
>> page.add(panel2);
>>
>> in some situations panel1 is not visible.
>>
>> However, a form submit event will visit all formcomponents of panel1 via:
>>
>>        at org.apache.wicket.markup.html.form.FormComponent.visitFormComponentsPostOrder(FormComponent.java:400)
>>        at org.apache.wicket.markup.html.form.Form.visitFormComponentsPostOrder(Form.java:1209)
>>        at org.apache.wicket.markup.html.form.Form.inputChanged(Form.java:1403)
>>        at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:865)
>>
>> This results in a crash because panel1 components are not prepared to
>> be invoked via isvisible when the panel itself is not visible.
>>
>> I wonder if the component.isVisibleInHierarchy could be changed as
>> follows, to first check parent visibility:
>>
>>  public final boolean isVisibleInHierarchy()
>>  {
>>    Component component = this;
>>    while (component != null)
>>    {
>>      Component componentParent = component.getParent();
>>
>>      if (((componentParent == null) ||
>> componentParent.isVisibleInHierarchy()) &&
>> component.determineVisibility())
>>      {
>>        component = componentParent;
>>      }
>>      else
>>      {
>>        return false;
>>      }
>>    }
>>    return true;
>>  }
>>
>> Similar change could/should maybe be possible also for isEnabledInHierarchy ?
>>
>> Comments?
>>
>> **
>> Martin
>>
>

Mime
View raw message