[CLOSED] [Bug 2.3.1] Exception attempting to refer to Parent Control in Handler of Control found in its Bin

  1. #1

    [CLOSED] [Bug 2.3.1] Exception attempting to refer to Parent Control in Handler of Control found in its Bin

    <%@ Page Language="C#" %>
    
    
    <!DOCTYPE html>
    <html>
    <head id="Head1" runat="server">
        <title>Test42</title>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
    
    
            <ext:Viewport ID="vp" runat="server" Layout="VBoxLayout">
                <LayoutConfig>
                    <ext:VBoxLayoutConfig Align="Stretch" />
                </LayoutConfig>
                <Items>
    
    
                    <ext:Panel ID="P" runat="server" Border="false" Padding="3" Flex="1" Title="Test42" Layout="VBoxLayout">
                        <LayoutConfig>
                            <ext:VBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
                            <ext:Label runat="server" Html="test" />
                        </Items>
                        <Bin>
                            <ext:DatePicker ID="Dates" runat="server" Floating="true" StyleSpec="z-index:255;" AutoShow="true">
                                <Listeners>
                                    <Render Handler="#{P}.getValue();" />
                                </Listeners>
                            </ext:DatePicker>
                        </Bin>
                    </ext:Panel>
                </Items>
            </ext:Viewport>
    
    
        </form>
    </body>
    </html>
    Last edited by Daniil; Dec 03, 2013 at 12:50 PM. Reason: [CLOSED]
  2. #2
    Hello!

    You try to call getValue before the parent control is actually rendered. Try to use AfterRender
  3. #3
    Okay. I thought I was on to something, but you're right. That makes some sense.
  4. #4
    However, I'm finding I'm still having the problem in my production case with AfterRender. So it looks like I'll just have to continue to work the example till it happens in the test case. I'll keep trying to reproduce this issue.
  5. #5
    Okay, this shows the issue. The exception triggers, and if you expand App in the debug console, you'll find it does not contain App.P
    <%@ Page Language="C#" %>
    
    
    <script runat="server">
    	protected void Page_Load( object sender, EventArgs e ) {
    	}
    </script>
    
    
    <!DOCTYPE html>
    <html>
    <head id="Head1" runat="server">
    	<title>Test42</title>
    </head>
    <body>
    	<form id="Form1" runat="server">
    		<ext:ResourceManager ID="ResourceManager1" runat="server" ScriptMode="Debug" SourceFormatting="true" />
    
    
    		<ext:Viewport ID="vp" runat="server" Layout="VBoxLayout">
    			<LayoutConfig>
    				<ext:VBoxLayoutConfig Align="Stretch" />
    			</LayoutConfig>
    			<Items>
    
    
    				<ext:Panel ID="P" runat="server" Border="false" Padding="3" Flex="1" Title="Test42" Layout="VBoxLayout">
    					<LayoutConfig>
    						<ext:VBoxLayoutConfig Align="Stretch" />
    					</LayoutConfig>
    					<Items>
    						<ext:Label runat="server" Html="test" />
    					</Items>
    					<Bin>
    						<ext:DatePicker ID="Dates" runat="server" Floating="true" StyleSpec="z-index:1001;" AutoShow="true">
    						<Listeners>
    							<AfterRender Handler="alert(#{P}.id);" />
    						</Listeners>
    						</ext:DatePicker>
    					</Bin>
    				</ext:Panel>
    
    
    			</Items>
    		</ext:Viewport>
    	</form>
    </body>
    </html>
  6. #6
    Hi everybody,

    A floating control with AutoShow="true" is created and rendered before the initComponent call of its parent where we share a component in the App namespace. And we cannot see any way to address that.

    The options are:

    1. Delay="1"
    <AfterRender Handler="alert(#{P}.id);" Delay="1" />
    2. Remove AutoShow="true" and show the DatePicker in its parent's AfterRender or AfterLayout. It is even better if you need to align a bin component to its parent.
  7. #7
    Quote Originally Posted by Daniil View Post
    1. Delay="1"
    <AfterRender Handler="alert(#{P}.id);" Delay="1" />
    After updating from the trunk, it can be replaced with:
    <AfterRender Handler="alert(this.binOwner.id);" Delay="1" />
    Please note that it doesn't fix the issue with AutoShow="true".
  8. #8
    Quote Originally Posted by Daniil View Post
    A floating control with AutoShow="true" is created and rendered before the initComponent call of its parent where we share a component in the App namespace. And we cannot see any way to address that.
    I was pretty sure this would be a sizable architectural issue since this problem does not occur for anything but bins and bins are not treated to the same render nesting pattern as child controls, even though they probably should have their own render path from an architectural standpoint. If I wanted to go to the next level, I could build a number of floating controls, some as complex user controls, I'd definitely run the risk of the same pattern failure. Looking at the code, it looks like it might be a sizeable effort, so the real question is, is it worth it? Yes, I can work around it. This is a question about the tool and its robustness at handling every scenario. You decide! It's a big one that affects probably a small number of developers.

    Quote Originally Posted by Daniil View Post
    1. Delay="1"
    <AfterRender Handler="alert(#{P}.id);" Delay="1" />
    I tried this in my production solution and this didn't work. I tried it in this test and it does. I wish I could remember what the issue was in production, but I can't go back and test anymore. However, if you're saying this solves the problem, then maybe the simple solution is the renderer can detect if the object being rendered is inside a bin and it has a transformation in any of the events, you can set delay to 1 if it's 0 automatically. It's a hack but it would solve the problem altogether.

    Quote Originally Posted by Daniil View Post
    2. Remove AutoShow="true" and show the DatePicker in its parent's AfterRender or AfterLayout. It is even better if you need to align a bin component to its parent.
    I ended up moving the alert to the parent's afterrender, but from a design localization perspective, this means that if I ever wanted to disable the single control, I can't just set Dates.Visible and have all it's subcomponents be turned off. I'd also have to turn it off in the parent's listener. This is very difficult if the DatePicker is inside a UserControl and the parent puts the user control in the bin, that is, if the determination to turn off the DatePicker is determined necessary while within the usercontrol. Moreover, the parent might not yet have access to the child object yet either. Your solution would run the same problem.

    But you're right, there are ways around this. Again, this thread was mostly about revealing the bug to you.
  9. #9
    Quote Originally Posted by michaeld View Post
    if the object being rendered is inside a bin and it has a transformation in any of the events, you can set delay to 1 if it's 0 automatically. It's a hack but it would solve the problem altogether.
    How can we detect that a developer needs a reference to parent in that listener? I think a developer might need a listener to be executed without any delay.

    Well, we don't see a clear solution for that case.

Similar Threads

  1. The Control Not Found!
    By flaviodamaia in forum 2.x Help
    Replies: 1
    Last Post: Feb 20, 2013, 1:51 PM
  2. Replies: 2
    Last Post: Jan 09, 2013, 12:52 AM
  3. Replies: 2
    Last Post: Nov 15, 2012, 12:52 AM
  4. Replies: 6
    Last Post: Dec 07, 2011, 12:55 PM
  5. Replies: 4
    Last Post: Feb 23, 2010, 7:38 AM

Posting Permissions