-Igor
On 4/29/06, Aaron Hiniker <[EMAIL PROTECTED]> wrote:
Heh, sorry-- I think i'm close to getting this to where I have the functionality where I need it to be, as well as minimal coupling between the components. Just one last issue I'm fighting:
@Override
protected void onBeforeRender()
{
replace( alternatable.getAlternateComponent( COMPONENT_ID ) );
super.onBeforeRender();
}
is throwing:
wicket.WicketRuntimeException: Cannot modify component hierarchy during render phaseat wicket.Page.checkHierarchyChange(Page.java:1035)
at wicket.Page.componentAdded(Page.java:879)
at wicket.MarkupContainer.addedComponent(MarkupContainer.java:1026)
at wicket.MarkupContainer.replace (MarkupContainer.java:598)
at us.myblock.components.border.AlternatablePanel.onBeforeRender(AlternatablePanel.java:41)
at wicket.Component.render(Component.java:1504)
(wicket 1.2-rc1)
When *can* I modify the hierarchy? onBeginRequest() is depricated...
Aaron
On Fri, 2006-04-28 at 20:13 -0700, Igor Vaynberg wrote:
you lost me.
But the problem here is the markupID. How can I get the proper markupID to the component at *construction* time, so that I don't have to construct the object from the interface method (it's actually not possible for me to do since I have a set of 4-5 dependant panels who's models are dependant on each other).
but you have the markup id. every component has it passed in to its constructor.
What I'm looking to avoid is circumstances where I need to spend 10-15 lines of code to wire up an anonymous class to handle component-swapping while keeping each component accessible to the outside world (if that makes any sense).
this makes no sense. you want to have two components, only one of them in the component hierarchy and the other one floating somewhere? this doesnt work. components have to be in the hierarchy where they belong. furthermore in wicket1.3 you will not be able to have a component outside of hierarchy because instead of add() you will pass in the parent into constructor.
the interface that takes the id in acts as a factory.
i guess you can try and better describe the usecase, maybe give a few specific examples because i am totally lost.
A component that can display itself, or a "No Items Selected" panel based on it's selection model
Looking at this doesnt really make sense. You are adding a specific component and then all of a sudden that component replaces itself with another one but yet somehow stays connected to the hierachy AND there is only placeholder for one component in the markup? this doesnt work. either the component replaces itself with another and is then out, or you have two placeholders in your markup, add both components all the time, hide one and show the other.
another idea you might want to try is a border. the border can have inside it the "alternate" component, and can wrap the regular component. by default the alternate is not visible. then when some condition occurs the border shows the alternate and callse setBorderBodyVisible(false) on itself that will hide whatever components are inside the border.
-Igor