You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Nelson Segura <ns...@gmail.com> on 2011/06/17 06:21:04 UTC

component rendering order

Is there a way to force components to be rendered in different order
than in which they were added?
I have the following dilemma:

I have component on the header of my pages whose behavior
(visibility/content) depends on the results displayed in a data table.
Since the header of my pages is added in the base page, before the
tables are added, and the results are only known during the rendering
of the rows, I have no access to the information I need.

Is there any pattern solutions you guys can suggest for solving these
type of problems?

Help is greatly appreciated.

-Nelson

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


Re: component rendering order

Posted by Igor Vaynberg <ig...@gmail.com>.
in that case you have a couple of options
a) in page's onbeforerender traverse all children with a special
visitor that figures this out and controls the visibility of the
header
b) control the header's visibility with javascript
c) put the header as the last element on the page and control its
position with css

-igor


On Tue, Jun 21, 2011 at 2:15 PM, Nelson Segura <ns...@gmail.com> wrote:
> On Mon, Jun 20, 2011 at 9:59 AM, Igor Vaynberg <ig...@gmail.com> wrote:
>> components are rendered in the same order they are in markup. how does
>> your component know now if the table is empty or not?
>>
>
> Igor,
> It does not. The way it works is that if the table detects thespecial
> data during rendering (onBeforeRender) , it informs the page about it
> (by calling a page method).
> Any component, either table or other, that detects that data informs
> the page about it.
> Then the page renders the header component, using the data it received
> from the rest of the components of the page).
> That is why I need to change the rendering order, because the
> rendering of that header component depends on the presence of that
> special data in the page (which could be in the table)
> -Nelson
>
>> -igor
>>
>> On Mon, Jun 20, 2011 at 9:37 AM, Nelson Segura <ns...@gmail.com> wrote:
>>> On Thu, Jun 16, 2011 at 10:23 PM, Igor Vaynberg <ig...@gmail.com> wrote:
>>>> give your component the dataprovider that the datatable has and use
>>>> that to calc visibility.
>>>>
>>>> -igor
>>>
>>> This does not work for me because:
>>>
>>> a) my pages might have multiple providers, and each one of them might
>>> change the state of the header component, depending on data on the
>>> list
>>> b) my header does not know what lists are on the page,  as it is
>>> shared between different pages. I might be none, one, or multiple.
>>> c) providers are not the only elements that can cause the header
>>> component to change.
>>>
>>> It seems to me that I need to force the component to be rendered last,
>>> after all the providers/tables have had a change to analyze its data.
>>>
>>> I have worked around this by adding the header component after the
>>> page onBeforeRender(), and then calling the components
>>> onBeforeRender(), like this
>>>
>>> BasePage.java
>>>
>>> public void onBeforeRender() {
>>>  super.onBeforeRender();
>>>  addOrReplace(new MyComponent());
>>>  component.onBeforeRender()
>>> }
>>>
>>> It is not pretty, but I dont know other way to force a change in the
>>> rendering sequence of the components.
>>>
>>> -Nelson
>>>
>>>
>>>>
>>>> On Thu, Jun 16, 2011 at 9:22 PM, Nelson Segura <ns...@gmail.com> wrote:
>>>>> I might mention that I am still using a version of wicket where
>>>>> onConfigure is not available,and we are not due to upgrade until after
>>>>> I need to finish this component.
>>>>> -Nelson
>>>>>
>>>>> On Thu, Jun 16, 2011 at 9:21 PM, Nelson Segura <ns...@gmail.com> wrote:
>>>>>> Is there a way to force components to be rendered in different order
>>>>>> than in which they were added?
>>>>>> I have the following dilemma:
>>>>>>
>>>>>> I have component on the header of my pages whose behavior
>>>>>> (visibility/content) depends on the results displayed in a data table.
>>>>>> Since the header of my pages is added in the base page, before the
>>>>>> tables are added, and the results are only known during the rendering
>>>>>> of the rows, I have no access to the information I need.
>>>>>>
>>>>>> Is there any pattern solutions you guys can suggest for solving these
>>>>>> type of problems?
>>>>>>
>>>>>> Help is greatly appreciated.
>>>>>>
>>>>>> -Nelson
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> 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
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>
> ---------------------------------------------------------------------
> 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


Re: component rendering order

Posted by Nelson Segura <ns...@gmail.com>.
On Mon, Jun 20, 2011 at 9:59 AM, Igor Vaynberg <ig...@gmail.com> wrote:
> components are rendered in the same order they are in markup. how does
> your component know now if the table is empty or not?
>

Igor,
It does not. The way it works is that if the table detects thespecial
data during rendering (onBeforeRender) , it informs the page about it
(by calling a page method).
Any component, either table or other, that detects that data informs
the page about it.
Then the page renders the header component, using the data it received
from the rest of the components of the page).
That is why I need to change the rendering order, because the
rendering of that header component depends on the presence of that
special data in the page (which could be in the table)
-Nelson

> -igor
>
> On Mon, Jun 20, 2011 at 9:37 AM, Nelson Segura <ns...@gmail.com> wrote:
>> On Thu, Jun 16, 2011 at 10:23 PM, Igor Vaynberg <ig...@gmail.com> wrote:
>>> give your component the dataprovider that the datatable has and use
>>> that to calc visibility.
>>>
>>> -igor
>>
>> This does not work for me because:
>>
>> a) my pages might have multiple providers, and each one of them might
>> change the state of the header component, depending on data on the
>> list
>> b) my header does not know what lists are on the page,  as it is
>> shared between different pages. I might be none, one, or multiple.
>> c) providers are not the only elements that can cause the header
>> component to change.
>>
>> It seems to me that I need to force the component to be rendered last,
>> after all the providers/tables have had a change to analyze its data.
>>
>> I have worked around this by adding the header component after the
>> page onBeforeRender(), and then calling the components
>> onBeforeRender(), like this
>>
>> BasePage.java
>>
>> public void onBeforeRender() {
>>  super.onBeforeRender();
>>  addOrReplace(new MyComponent());
>>  component.onBeforeRender()
>> }
>>
>> It is not pretty, but I dont know other way to force a change in the
>> rendering sequence of the components.
>>
>> -Nelson
>>
>>
>>>
>>> On Thu, Jun 16, 2011 at 9:22 PM, Nelson Segura <ns...@gmail.com> wrote:
>>>> I might mention that I am still using a version of wicket where
>>>> onConfigure is not available,and we are not due to upgrade until after
>>>> I need to finish this component.
>>>> -Nelson
>>>>
>>>> On Thu, Jun 16, 2011 at 9:21 PM, Nelson Segura <ns...@gmail.com> wrote:
>>>>> Is there a way to force components to be rendered in different order
>>>>> than in which they were added?
>>>>> I have the following dilemma:
>>>>>
>>>>> I have component on the header of my pages whose behavior
>>>>> (visibility/content) depends on the results displayed in a data table.
>>>>> Since the header of my pages is added in the base page, before the
>>>>> tables are added, and the results are only known during the rendering
>>>>> of the rows, I have no access to the information I need.
>>>>>
>>>>> Is there any pattern solutions you guys can suggest for solving these
>>>>> type of problems?
>>>>>
>>>>> Help is greatly appreciated.
>>>>>
>>>>> -Nelson
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>

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


Re: component rendering order

Posted by Igor Vaynberg <ig...@gmail.com>.
components are rendered in the same order they are in markup. how does
your component know now if the table is empty or not?

-igor

On Mon, Jun 20, 2011 at 9:37 AM, Nelson Segura <ns...@gmail.com> wrote:
> On Thu, Jun 16, 2011 at 10:23 PM, Igor Vaynberg <ig...@gmail.com> wrote:
>> give your component the dataprovider that the datatable has and use
>> that to calc visibility.
>>
>> -igor
>
> This does not work for me because:
>
> a) my pages might have multiple providers, and each one of them might
> change the state of the header component, depending on data on the
> list
> b) my header does not know what lists are on the page,  as it is
> shared between different pages. I might be none, one, or multiple.
> c) providers are not the only elements that can cause the header
> component to change.
>
> It seems to me that I need to force the component to be rendered last,
> after all the providers/tables have had a change to analyze its data.
>
> I have worked around this by adding the header component after the
> page onBeforeRender(), and then calling the components
> onBeforeRender(), like this
>
> BasePage.java
>
> public void onBeforeRender() {
>  super.onBeforeRender();
>  addOrReplace(new MyComponent());
>  component.onBeforeRender()
> }
>
> It is not pretty, but I dont know other way to force a change in the
> rendering sequence of the components.
>
> -Nelson
>
>
>>
>> On Thu, Jun 16, 2011 at 9:22 PM, Nelson Segura <ns...@gmail.com> wrote:
>>> I might mention that I am still using a version of wicket where
>>> onConfigure is not available,and we are not due to upgrade until after
>>> I need to finish this component.
>>> -Nelson
>>>
>>> On Thu, Jun 16, 2011 at 9:21 PM, Nelson Segura <ns...@gmail.com> wrote:
>>>> Is there a way to force components to be rendered in different order
>>>> than in which they were added?
>>>> I have the following dilemma:
>>>>
>>>> I have component on the header of my pages whose behavior
>>>> (visibility/content) depends on the results displayed in a data table.
>>>> Since the header of my pages is added in the base page, before the
>>>> tables are added, and the results are only known during the rendering
>>>> of the rows, I have no access to the information I need.
>>>>
>>>> Is there any pattern solutions you guys can suggest for solving these
>>>> type of problems?
>>>>
>>>> Help is greatly appreciated.
>>>>
>>>> -Nelson
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>
> ---------------------------------------------------------------------
> 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


Re: component rendering order

Posted by Nelson Segura <ns...@gmail.com>.
On Thu, Jun 16, 2011 at 10:23 PM, Igor Vaynberg <ig...@gmail.com> wrote:
> give your component the dataprovider that the datatable has and use
> that to calc visibility.
>
> -igor

This does not work for me because:

a) my pages might have multiple providers, and each one of them might
change the state of the header component, depending on data on the
list
b) my header does not know what lists are on the page,  as it is
shared between different pages. I might be none, one, or multiple.
c) providers are not the only elements that can cause the header
component to change.

It seems to me that I need to force the component to be rendered last,
after all the providers/tables have had a change to analyze its data.

I have worked around this by adding the header component after the
page onBeforeRender(), and then calling the components
onBeforeRender(), like this

BasePage.java

public void onBeforeRender() {
 super.onBeforeRender();
 addOrReplace(new MyComponent());
 component.onBeforeRender()
}

It is not pretty, but I dont know other way to force a change in the
rendering sequence of the components.

-Nelson


>
> On Thu, Jun 16, 2011 at 9:22 PM, Nelson Segura <ns...@gmail.com> wrote:
>> I might mention that I am still using a version of wicket where
>> onConfigure is not available,and we are not due to upgrade until after
>> I need to finish this component.
>> -Nelson
>>
>> On Thu, Jun 16, 2011 at 9:21 PM, Nelson Segura <ns...@gmail.com> wrote:
>>> Is there a way to force components to be rendered in different order
>>> than in which they were added?
>>> I have the following dilemma:
>>>
>>> I have component on the header of my pages whose behavior
>>> (visibility/content) depends on the results displayed in a data table.
>>> Since the header of my pages is added in the base page, before the
>>> tables are added, and the results are only known during the rendering
>>> of the rows, I have no access to the information I need.
>>>
>>> Is there any pattern solutions you guys can suggest for solving these
>>> type of problems?
>>>
>>> Help is greatly appreciated.
>>>
>>> -Nelson
>>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>

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


Re: component rendering order

Posted by Igor Vaynberg <ig...@gmail.com>.
give your component the dataprovider that the datatable has and use
that to calc visibility.

-igor

On Thu, Jun 16, 2011 at 9:22 PM, Nelson Segura <ns...@gmail.com> wrote:
> I might mention that I am still using a version of wicket where
> onConfigure is not available,and we are not due to upgrade until after
> I need to finish this component.
> -Nelson
>
> On Thu, Jun 16, 2011 at 9:21 PM, Nelson Segura <ns...@gmail.com> wrote:
>> Is there a way to force components to be rendered in different order
>> than in which they were added?
>> I have the following dilemma:
>>
>> I have component on the header of my pages whose behavior
>> (visibility/content) depends on the results displayed in a data table.
>> Since the header of my pages is added in the base page, before the
>> tables are added, and the results are only known during the rendering
>> of the rows, I have no access to the information I need.
>>
>> Is there any pattern solutions you guys can suggest for solving these
>> type of problems?
>>
>> Help is greatly appreciated.
>>
>> -Nelson
>>
>
> ---------------------------------------------------------------------
> 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


Re: component rendering order

Posted by Nelson Segura <ns...@gmail.com>.
I might mention that I am still using a version of wicket where
onConfigure is not available,and we are not due to upgrade until after
I need to finish this component.
-Nelson

On Thu, Jun 16, 2011 at 9:21 PM, Nelson Segura <ns...@gmail.com> wrote:
> Is there a way to force components to be rendered in different order
> than in which they were added?
> I have the following dilemma:
>
> I have component on the header of my pages whose behavior
> (visibility/content) depends on the results displayed in a data table.
> Since the header of my pages is added in the base page, before the
> tables are added, and the results are only known during the rendering
> of the rows, I have no access to the information I need.
>
> Is there any pattern solutions you guys can suggest for solving these
> type of problems?
>
> Help is greatly appreciated.
>
> -Nelson
>

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