You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Ben Sommerville (JIRA)" <ta...@jakarta.apache.org> on 2006/07/28 01:53:13 UTC

[jira] Created: (TAPESTRY-1023) Calling updateComponent in @EventListener method on a component that is prerendered results in null update

Calling updateComponent in @EventListener method on a component that is prerendered results in null update
----------------------------------------------------------------------------------------------------------

                 Key: TAPESTRY-1023
                 URL: http://issues.apache.org/jira/browse/TAPESTRY-1023
             Project: Tapestry
          Issue Type: Bug
          Components: Framework
    Affects Versions: 4.1
         Environment: Tapestery 4.1 Head,  JBoss 4.0.4 GA,  Windows XP
            Reporter: Ben Sommerville


I had a problem with @EventListener tonight but I'm not sure if this is a 
bug or ignorance on my part. 
(I am working with the latest 4.1 version from svn) 
  
First let me explain what I am trying to do.... 
I have a form with several PropertySelection input fields on it.  What I 
want to do is change the selectable options based on what has already been 
selected.  
e.g.  Say the form has two select fields A & B 
A has options 1,2,3. 
If the value of A is 1, then B should have options 11, 12, 13 
If the value of A is 2, then B should have options 21, 22, 23 
If the value of A is 3, then B should have options 31, 32, 33 
  
Now in the page template the fields are defined as follows 
  
<div class="field"> 
    <label jwcid="@FieldLabel" field="component:A">Role</label> 
    <input jwcid="A@PropertySelection" value="ognl:A" displayName="A" 
           model="ognl:aModel"/> 
</div> 
<div class="field"> 
    <label jwcid="@FieldLabel" field="component:B">B</label> 
    <input jwcid="B@PropertySelection" value="ognl:B" displayName="B" 
           model="ognl:bModel"/> 
</div> 

To update the options displayed by B I defined the following method 

@EventListener(targets="A", events="onchange", submitForm ="form") 
public void selectA(IRequestCycle cycle) { 
   bModel = .... New model for b based on value of A .... 
   cycle.getResponseBuilder().updateComponent("b"); 
} 
  
What I was expecting to happen was that when the value of A was changed then 
B would be rerendered with the new options based on A's value. 
What actually happened was that as soon as I changed the value of A then B 
was rendered with no options at all. 

After a bit of debugging I eventually worked out that what was happening 
was: 
- A's value was changed & the event listener was invoked 
- The model for B was updated correctly 
- The FieldLabel that refered to B was rendered with a NullWriter 
- this field label prerendered B (to get its id) with the NullWriter 
- B was rendered with a real writer but didn't output anything because it 
had been prerendered 
- The page was updated an empty B element (cause the NullWriter discards 
everything). 

To work around this I gave the FieldLabel (for B) an explicit id and added 
an updateComponent call for the this id.  When I did this the page behaved 
as I was expecting. 

Now my question: Is this behaviour correct? 
                 Or have I approached the problem incorrectly? 

It seems a bit unintuitive, I would prefer B to render properly when I asked 
it to be updated, rather than having to update both it and the label. 

However I'm not sure how to get my desired behaviour.  Maybe the 
DojoAjaxResponseBuilder could check the form prerender map after each 
component render and clear out any prerender's with null results.... 
...or maybe wiser heads can come up with a much more elegant solution :) 



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Updated: (TAPESTRY-1023) Calling updateComponent in @EventListener method on a component that is prerendered results in null update

Posted by "Jesse Kuhnert (JIRA)" <ta...@jakarta.apache.org>.
     [ http://issues.apache.org/jira/browse/TAPESTRY-1023?page=all ]

Jesse Kuhnert updated TAPESTRY-1023:
------------------------------------

    Fix Version/s: 4.1.1
                       (was: 4.1)

> Calling updateComponent in @EventListener method on a component that is prerendered results in null update
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-1023
>                 URL: http://issues.apache.org/jira/browse/TAPESTRY-1023
>             Project: Tapestry
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 4.1
>         Environment: Tapestery 4.1 Head,  JBoss 4.0.4 GA,  Windows XP
>            Reporter: Ben Sommerville
>         Assigned To: Jesse Kuhnert
>             Fix For: 4.1.1
>
>         Attachments: TAP-1023.patch
>
>
> I had a problem with @EventListener tonight but I'm not sure if this is a 
> bug or ignorance on my part. 
> (I am working with the latest 4.1 version from svn) 
>   
> First let me explain what I am trying to do.... 
> I have a form with several PropertySelection input fields on it.  What I 
> want to do is change the selectable options based on what has already been 
> selected.  
> e.g.  Say the form has two select fields A & B 
> A has options 1,2,3. 
> If the value of A is 1, then B should have options 11, 12, 13 
> If the value of A is 2, then B should have options 21, 22, 23 
> If the value of A is 3, then B should have options 31, 32, 33 
>   
> Now in the page template the fields are defined as follows 
>   
> <div class="field"> 
>     <label jwcid="@FieldLabel" field="component:A">Role</label> 
>     <input jwcid="A@PropertySelection" value="ognl:A" displayName="A" 
>            model="ognl:aModel"/> 
> </div> 
> <div class="field"> 
>     <label jwcid="@FieldLabel" field="component:B">B</label> 
>     <input jwcid="B@PropertySelection" value="ognl:B" displayName="B" 
>            model="ognl:bModel"/> 
> </div> 
> To update the options displayed by B I defined the following method 
> @EventListener(targets="A", events="onchange", submitForm ="form") 
> public void selectA(IRequestCycle cycle) { 
>    bModel = .... New model for b based on value of A .... 
>    cycle.getResponseBuilder().updateComponent("b"); 
> } 
>   
> What I was expecting to happen was that when the value of A was changed then 
> B would be rerendered with the new options based on A's value. 
> What actually happened was that as soon as I changed the value of A then B 
> was rendered with no options at all. 
> After a bit of debugging I eventually worked out that what was happening 
> was: 
> - A's value was changed & the event listener was invoked 
> - The model for B was updated correctly 
> - The FieldLabel that refered to B was rendered with a NullWriter 
> - this field label prerendered B (to get its id) with the NullWriter 
> - B was rendered with a real writer but didn't output anything because it 
> had been prerendered 
> - The page was updated an empty B element (cause the NullWriter discards 
> everything). 
> To work around this I gave the FieldLabel (for B) an explicit id and added 
> an updateComponent call for the this id.  When I did this the page behaved 
> as I was expecting. 
> Now my question: Is this behaviour correct? 
>                  Or have I approached the problem incorrectly? 
> It seems a bit unintuitive, I would prefer B to render properly when I asked 
> it to be updated, rather than having to update both it and the label. 
> However I'm not sure how to get my desired behaviour.  Maybe the 
> DojoAjaxResponseBuilder could check the form prerender map after each 
> component render and clear out any prerender's with null results.... 
> ...or maybe wiser heads can come up with a much more elegant solution :) 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Commented: (TAPESTRY-1023) Calling updateComponent in @EventListener method on a component that is prerendered results in null update

Posted by "Ben Sommerville (JIRA)" <ta...@jakarta.apache.org>.
    [ http://issues.apache.org/jira/browse/TAPESTRY-1023?page=comments#action_12424291 ] 
            
Ben Sommerville commented on TAPESTRY-1023:
-------------------------------------------

I think I have a solution.

It appears to me that the only component that uses (invokes) prerendering is the FieldLabel.  The only reason it prerenders a field is to obtain its id (on the client).  With the other changes in 4.1 around the generation (& caching) of client id, I'd say a better approach would be to ditch the prerendering functionality altogether & just allow the FieldLabel component to obtain the client id of its field.

This has the advantage of simplifying components (they no longer need to worry about prerendering) & makes everthing work with theDojoResponseBuilder.



> Calling updateComponent in @EventListener method on a component that is prerendered results in null update
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-1023
>                 URL: http://issues.apache.org/jira/browse/TAPESTRY-1023
>             Project: Tapestry
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 4.1
>         Environment: Tapestery 4.1 Head,  JBoss 4.0.4 GA,  Windows XP
>            Reporter: Ben Sommerville
>         Assigned To: Jesse Kuhnert
>             Fix For: 4.1
>
>
> I had a problem with @EventListener tonight but I'm not sure if this is a 
> bug or ignorance on my part. 
> (I am working with the latest 4.1 version from svn) 
>   
> First let me explain what I am trying to do.... 
> I have a form with several PropertySelection input fields on it.  What I 
> want to do is change the selectable options based on what has already been 
> selected.  
> e.g.  Say the form has two select fields A & B 
> A has options 1,2,3. 
> If the value of A is 1, then B should have options 11, 12, 13 
> If the value of A is 2, then B should have options 21, 22, 23 
> If the value of A is 3, then B should have options 31, 32, 33 
>   
> Now in the page template the fields are defined as follows 
>   
> <div class="field"> 
>     <label jwcid="@FieldLabel" field="component:A">Role</label> 
>     <input jwcid="A@PropertySelection" value="ognl:A" displayName="A" 
>            model="ognl:aModel"/> 
> </div> 
> <div class="field"> 
>     <label jwcid="@FieldLabel" field="component:B">B</label> 
>     <input jwcid="B@PropertySelection" value="ognl:B" displayName="B" 
>            model="ognl:bModel"/> 
> </div> 
> To update the options displayed by B I defined the following method 
> @EventListener(targets="A", events="onchange", submitForm ="form") 
> public void selectA(IRequestCycle cycle) { 
>    bModel = .... New model for b based on value of A .... 
>    cycle.getResponseBuilder().updateComponent("b"); 
> } 
>   
> What I was expecting to happen was that when the value of A was changed then 
> B would be rerendered with the new options based on A's value. 
> What actually happened was that as soon as I changed the value of A then B 
> was rendered with no options at all. 
> After a bit of debugging I eventually worked out that what was happening 
> was: 
> - A's value was changed & the event listener was invoked 
> - The model for B was updated correctly 
> - The FieldLabel that refered to B was rendered with a NullWriter 
> - this field label prerendered B (to get its id) with the NullWriter 
> - B was rendered with a real writer but didn't output anything because it 
> had been prerendered 
> - The page was updated an empty B element (cause the NullWriter discards 
> everything). 
> To work around this I gave the FieldLabel (for B) an explicit id and added 
> an updateComponent call for the this id.  When I did this the page behaved 
> as I was expecting. 
> Now my question: Is this behaviour correct? 
>                  Or have I approached the problem incorrectly? 
> It seems a bit unintuitive, I would prefer B to render properly when I asked 
> it to be updated, rather than having to update both it and the label. 
> However I'm not sure how to get my desired behaviour.  Maybe the 
> DojoAjaxResponseBuilder could check the form prerender map after each 
> component render and clear out any prerender's with null results.... 
> ...or maybe wiser heads can come up with a much more elegant solution :) 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Updated: (TAPESTRY-1023) Calling updateComponent in @EventListener method on a component that is prerendered results in null update

Posted by "Jesse Kuhnert (JIRA)" <ta...@jakarta.apache.org>.
     [ http://issues.apache.org/jira/browse/TAPESTRY-1023?page=all ]

Jesse Kuhnert updated TAPESTRY-1023:
------------------------------------

    Component/s: Annotations
                     (was: Framework)

> Calling updateComponent in @EventListener method on a component that is prerendered results in null update
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-1023
>                 URL: http://issues.apache.org/jira/browse/TAPESTRY-1023
>             Project: Tapestry
>          Issue Type: Bug
>          Components: Annotations
>    Affects Versions: 4.1
>         Environment: Tapestery 4.1 Head,  JBoss 4.0.4 GA,  Windows XP
>            Reporter: Ben Sommerville
>         Assigned To: Jesse Kuhnert
>             Fix For: 4.1.1
>
>         Attachments: TAP-1023.patch
>
>
> I had a problem with @EventListener tonight but I'm not sure if this is a 
> bug or ignorance on my part. 
> (I am working with the latest 4.1 version from svn) 
>   
> First let me explain what I am trying to do.... 
> I have a form with several PropertySelection input fields on it.  What I 
> want to do is change the selectable options based on what has already been 
> selected.  
> e.g.  Say the form has two select fields A & B 
> A has options 1,2,3. 
> If the value of A is 1, then B should have options 11, 12, 13 
> If the value of A is 2, then B should have options 21, 22, 23 
> If the value of A is 3, then B should have options 31, 32, 33 
>   
> Now in the page template the fields are defined as follows 
>   
> <div class="field"> 
>     <label jwcid="@FieldLabel" field="component:A">Role</label> 
>     <input jwcid="A@PropertySelection" value="ognl:A" displayName="A" 
>            model="ognl:aModel"/> 
> </div> 
> <div class="field"> 
>     <label jwcid="@FieldLabel" field="component:B">B</label> 
>     <input jwcid="B@PropertySelection" value="ognl:B" displayName="B" 
>            model="ognl:bModel"/> 
> </div> 
> To update the options displayed by B I defined the following method 
> @EventListener(targets="A", events="onchange", submitForm ="form") 
> public void selectA(IRequestCycle cycle) { 
>    bModel = .... New model for b based on value of A .... 
>    cycle.getResponseBuilder().updateComponent("b"); 
> } 
>   
> What I was expecting to happen was that when the value of A was changed then 
> B would be rerendered with the new options based on A's value. 
> What actually happened was that as soon as I changed the value of A then B 
> was rendered with no options at all. 
> After a bit of debugging I eventually worked out that what was happening 
> was: 
> - A's value was changed & the event listener was invoked 
> - The model for B was updated correctly 
> - The FieldLabel that refered to B was rendered with a NullWriter 
> - this field label prerendered B (to get its id) with the NullWriter 
> - B was rendered with a real writer but didn't output anything because it 
> had been prerendered 
> - The page was updated an empty B element (cause the NullWriter discards 
> everything). 
> To work around this I gave the FieldLabel (for B) an explicit id and added 
> an updateComponent call for the this id.  When I did this the page behaved 
> as I was expecting. 
> Now my question: Is this behaviour correct? 
>                  Or have I approached the problem incorrectly? 
> It seems a bit unintuitive, I would prefer B to render properly when I asked 
> it to be updated, rather than having to update both it and the label. 
> However I'm not sure how to get my desired behaviour.  Maybe the 
> DojoAjaxResponseBuilder could check the form prerender map after each 
> component render and clear out any prerender's with null results.... 
> ...or maybe wiser heads can come up with a much more elegant solution :) 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Resolved: (TAPESTRY-1023) Calling updateComponent in @EventListener method on a component that is prerendered results in null update

Posted by "Jesse Kuhnert (JIRA)" <ta...@jakarta.apache.org>.
     [ http://issues.apache.org/jira/browse/TAPESTRY-1023?page=all ]

Jesse Kuhnert resolved TAPESTRY-1023.
-------------------------------------

    Resolution: Fixed

Thanks for all your hard work on this one Ben. It's fixed now. 

> Calling updateComponent in @EventListener method on a component that is prerendered results in null update
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-1023
>                 URL: http://issues.apache.org/jira/browse/TAPESTRY-1023
>             Project: Tapestry
>          Issue Type: Bug
>          Components: Annotations
>    Affects Versions: 4.1
>         Environment: Tapestery 4.1 Head,  JBoss 4.0.4 GA,  Windows XP
>            Reporter: Ben Sommerville
>         Assigned To: Jesse Kuhnert
>             Fix For: 4.1.1
>
>         Attachments: TAP-1023.patch, TAP-1023.patch
>
>
> I had a problem with @EventListener tonight but I'm not sure if this is a 
> bug or ignorance on my part. 
> (I am working with the latest 4.1 version from svn) 
>   
> First let me explain what I am trying to do.... 
> I have a form with several PropertySelection input fields on it.  What I 
> want to do is change the selectable options based on what has already been 
> selected.  
> e.g.  Say the form has two select fields A & B 
> A has options 1,2,3. 
> If the value of A is 1, then B should have options 11, 12, 13 
> If the value of A is 2, then B should have options 21, 22, 23 
> If the value of A is 3, then B should have options 31, 32, 33 
>   
> Now in the page template the fields are defined as follows 
>   
> <div class="field"> 
>     <label jwcid="@FieldLabel" field="component:A">Role</label> 
>     <input jwcid="A@PropertySelection" value="ognl:A" displayName="A" 
>            model="ognl:aModel"/> 
> </div> 
> <div class="field"> 
>     <label jwcid="@FieldLabel" field="component:B">B</label> 
>     <input jwcid="B@PropertySelection" value="ognl:B" displayName="B" 
>            model="ognl:bModel"/> 
> </div> 
> To update the options displayed by B I defined the following method 
> @EventListener(targets="A", events="onchange", submitForm ="form") 
> public void selectA(IRequestCycle cycle) { 
>    bModel = .... New model for b based on value of A .... 
>    cycle.getResponseBuilder().updateComponent("b"); 
> } 
>   
> What I was expecting to happen was that when the value of A was changed then 
> B would be rerendered with the new options based on A's value. 
> What actually happened was that as soon as I changed the value of A then B 
> was rendered with no options at all. 
> After a bit of debugging I eventually worked out that what was happening 
> was: 
> - A's value was changed & the event listener was invoked 
> - The model for B was updated correctly 
> - The FieldLabel that refered to B was rendered with a NullWriter 
> - this field label prerendered B (to get its id) with the NullWriter 
> - B was rendered with a real writer but didn't output anything because it 
> had been prerendered 
> - The page was updated an empty B element (cause the NullWriter discards 
> everything). 
> To work around this I gave the FieldLabel (for B) an explicit id and added 
> an updateComponent call for the this id.  When I did this the page behaved 
> as I was expecting. 
> Now my question: Is this behaviour correct? 
>                  Or have I approached the problem incorrectly? 
> It seems a bit unintuitive, I would prefer B to render properly when I asked 
> it to be updated, rather than having to update both it and the label. 
> However I'm not sure how to get my desired behaviour.  Maybe the 
> DojoAjaxResponseBuilder could check the form prerender map after each 
> component render and clear out any prerender's with null results.... 
> ...or maybe wiser heads can come up with a much more elegant solution :) 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Commented: (TAPESTRY-1023) Calling updateComponent in @EventListener method on a component that is prerendered results in null update

Posted by "Ben Sommerville (JIRA)" <ta...@jakarta.apache.org>.
    [ http://issues.apache.org/jira/browse/TAPESTRY-1023?page=comments#action_12424282 ] 
            
Ben Sommerville commented on TAPESTRY-1023:
-------------------------------------------

Digging into prerendering a bit more, I think I found another bug (haven't confirmed it with a test tho).  

If a  FieldLabel is after its field & has prerender set to false, then it will end up with a null (or incorrect) "for" attribute.  This is because the "for" attribute is set from its field.clientId.  When the field is rendered first, its clientId is set to null once it has rendered (AbstractComponent.render).  Then when the FieldLabel goes to get the client id it is no longer available.

> Calling updateComponent in @EventListener method on a component that is prerendered results in null update
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-1023
>                 URL: http://issues.apache.org/jira/browse/TAPESTRY-1023
>             Project: Tapestry
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 4.1
>         Environment: Tapestery 4.1 Head,  JBoss 4.0.4 GA,  Windows XP
>            Reporter: Ben Sommerville
>         Assigned To: Jesse Kuhnert
>             Fix For: 4.1
>
>
> I had a problem with @EventListener tonight but I'm not sure if this is a 
> bug or ignorance on my part. 
> (I am working with the latest 4.1 version from svn) 
>   
> First let me explain what I am trying to do.... 
> I have a form with several PropertySelection input fields on it.  What I 
> want to do is change the selectable options based on what has already been 
> selected.  
> e.g.  Say the form has two select fields A & B 
> A has options 1,2,3. 
> If the value of A is 1, then B should have options 11, 12, 13 
> If the value of A is 2, then B should have options 21, 22, 23 
> If the value of A is 3, then B should have options 31, 32, 33 
>   
> Now in the page template the fields are defined as follows 
>   
> <div class="field"> 
>     <label jwcid="@FieldLabel" field="component:A">Role</label> 
>     <input jwcid="A@PropertySelection" value="ognl:A" displayName="A" 
>            model="ognl:aModel"/> 
> </div> 
> <div class="field"> 
>     <label jwcid="@FieldLabel" field="component:B">B</label> 
>     <input jwcid="B@PropertySelection" value="ognl:B" displayName="B" 
>            model="ognl:bModel"/> 
> </div> 
> To update the options displayed by B I defined the following method 
> @EventListener(targets="A", events="onchange", submitForm ="form") 
> public void selectA(IRequestCycle cycle) { 
>    bModel = .... New model for b based on value of A .... 
>    cycle.getResponseBuilder().updateComponent("b"); 
> } 
>   
> What I was expecting to happen was that when the value of A was changed then 
> B would be rerendered with the new options based on A's value. 
> What actually happened was that as soon as I changed the value of A then B 
> was rendered with no options at all. 
> After a bit of debugging I eventually worked out that what was happening 
> was: 
> - A's value was changed & the event listener was invoked 
> - The model for B was updated correctly 
> - The FieldLabel that refered to B was rendered with a NullWriter 
> - this field label prerendered B (to get its id) with the NullWriter 
> - B was rendered with a real writer but didn't output anything because it 
> had been prerendered 
> - The page was updated an empty B element (cause the NullWriter discards 
> everything). 
> To work around this I gave the FieldLabel (for B) an explicit id and added 
> an updateComponent call for the this id.  When I did this the page behaved 
> as I was expecting. 
> Now my question: Is this behaviour correct? 
>                  Or have I approached the problem incorrectly? 
> It seems a bit unintuitive, I would prefer B to render properly when I asked 
> it to be updated, rather than having to update both it and the label. 
> However I'm not sure how to get my desired behaviour.  Maybe the 
> DojoAjaxResponseBuilder could check the form prerender map after each 
> component render and clear out any prerender's with null results.... 
> ...or maybe wiser heads can come up with a much more elegant solution :) 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Updated: (TAPESTRY-1023) Calling updateComponent in @EventListener method on a component that is prerendered results in null update

Posted by "Jesse Kuhnert (JIRA)" <ta...@jakarta.apache.org>.
     [ http://issues.apache.org/jira/browse/TAPESTRY-1023?page=all ]

Jesse Kuhnert updated TAPESTRY-1023:
------------------------------------

    Fix Version/s: 4.1

> Calling updateComponent in @EventListener method on a component that is prerendered results in null update
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-1023
>                 URL: http://issues.apache.org/jira/browse/TAPESTRY-1023
>             Project: Tapestry
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 4.1
>         Environment: Tapestery 4.1 Head,  JBoss 4.0.4 GA,  Windows XP
>            Reporter: Ben Sommerville
>         Assigned To: Jesse Kuhnert
>             Fix For: 4.1
>
>
> I had a problem with @EventListener tonight but I'm not sure if this is a 
> bug or ignorance on my part. 
> (I am working with the latest 4.1 version from svn) 
>   
> First let me explain what I am trying to do.... 
> I have a form with several PropertySelection input fields on it.  What I 
> want to do is change the selectable options based on what has already been 
> selected.  
> e.g.  Say the form has two select fields A & B 
> A has options 1,2,3. 
> If the value of A is 1, then B should have options 11, 12, 13 
> If the value of A is 2, then B should have options 21, 22, 23 
> If the value of A is 3, then B should have options 31, 32, 33 
>   
> Now in the page template the fields are defined as follows 
>   
> <div class="field"> 
>     <label jwcid="@FieldLabel" field="component:A">Role</label> 
>     <input jwcid="A@PropertySelection" value="ognl:A" displayName="A" 
>            model="ognl:aModel"/> 
> </div> 
> <div class="field"> 
>     <label jwcid="@FieldLabel" field="component:B">B</label> 
>     <input jwcid="B@PropertySelection" value="ognl:B" displayName="B" 
>            model="ognl:bModel"/> 
> </div> 
> To update the options displayed by B I defined the following method 
> @EventListener(targets="A", events="onchange", submitForm ="form") 
> public void selectA(IRequestCycle cycle) { 
>    bModel = .... New model for b based on value of A .... 
>    cycle.getResponseBuilder().updateComponent("b"); 
> } 
>   
> What I was expecting to happen was that when the value of A was changed then 
> B would be rerendered with the new options based on A's value. 
> What actually happened was that as soon as I changed the value of A then B 
> was rendered with no options at all. 
> After a bit of debugging I eventually worked out that what was happening 
> was: 
> - A's value was changed & the event listener was invoked 
> - The model for B was updated correctly 
> - The FieldLabel that refered to B was rendered with a NullWriter 
> - this field label prerendered B (to get its id) with the NullWriter 
> - B was rendered with a real writer but didn't output anything because it 
> had been prerendered 
> - The page was updated an empty B element (cause the NullWriter discards 
> everything). 
> To work around this I gave the FieldLabel (for B) an explicit id and added 
> an updateComponent call for the this id.  When I did this the page behaved 
> as I was expecting. 
> Now my question: Is this behaviour correct? 
>                  Or have I approached the problem incorrectly? 
> It seems a bit unintuitive, I would prefer B to render properly when I asked 
> it to be updated, rather than having to update both it and the label. 
> However I'm not sure how to get my desired behaviour.  Maybe the 
> DojoAjaxResponseBuilder could check the form prerender map after each 
> component render and clear out any prerender's with null results.... 
> ...or maybe wiser heads can come up with a much more elegant solution :) 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Updated: (TAPESTRY-1023) Calling updateComponent in @EventListener method on a component that is prerendered results in null update

Posted by "Ben Sommerville (JIRA)" <ta...@jakarta.apache.org>.
     [ http://issues.apache.org/jira/browse/TAPESTRY-1023?page=all ]

Ben Sommerville updated TAPESTRY-1023:
--------------------------------------

    Attachment: TAP-1023.patch

Patch to remove prerender functions and substitute ability to allocated client id of component before it is rendered.  This removes the problem of the Ajax Response builder not rendering components refered to by FieldLabels.

FieldLabel still needs "prerender" attribute to work out whether it is before its field & thus needs to allocate the client id.

Hmm,  I just realised that FieldLabel will still have a problem if it is after its field.  The client id will be cleared after the field renders & FieldLable will no longer have access.

However this aside, the patch should solve the main problem.

> Calling updateComponent in @EventListener method on a component that is prerendered results in null update
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-1023
>                 URL: http://issues.apache.org/jira/browse/TAPESTRY-1023
>             Project: Tapestry
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 4.1
>         Environment: Tapestery 4.1 Head,  JBoss 4.0.4 GA,  Windows XP
>            Reporter: Ben Sommerville
>         Assigned To: Jesse Kuhnert
>             Fix For: 4.1
>
>         Attachments: TAP-1023.patch
>
>
> I had a problem with @EventListener tonight but I'm not sure if this is a 
> bug or ignorance on my part. 
> (I am working with the latest 4.1 version from svn) 
>   
> First let me explain what I am trying to do.... 
> I have a form with several PropertySelection input fields on it.  What I 
> want to do is change the selectable options based on what has already been 
> selected.  
> e.g.  Say the form has two select fields A & B 
> A has options 1,2,3. 
> If the value of A is 1, then B should have options 11, 12, 13 
> If the value of A is 2, then B should have options 21, 22, 23 
> If the value of A is 3, then B should have options 31, 32, 33 
>   
> Now in the page template the fields are defined as follows 
>   
> <div class="field"> 
>     <label jwcid="@FieldLabel" field="component:A">Role</label> 
>     <input jwcid="A@PropertySelection" value="ognl:A" displayName="A" 
>            model="ognl:aModel"/> 
> </div> 
> <div class="field"> 
>     <label jwcid="@FieldLabel" field="component:B">B</label> 
>     <input jwcid="B@PropertySelection" value="ognl:B" displayName="B" 
>            model="ognl:bModel"/> 
> </div> 
> To update the options displayed by B I defined the following method 
> @EventListener(targets="A", events="onchange", submitForm ="form") 
> public void selectA(IRequestCycle cycle) { 
>    bModel = .... New model for b based on value of A .... 
>    cycle.getResponseBuilder().updateComponent("b"); 
> } 
>   
> What I was expecting to happen was that when the value of A was changed then 
> B would be rerendered with the new options based on A's value. 
> What actually happened was that as soon as I changed the value of A then B 
> was rendered with no options at all. 
> After a bit of debugging I eventually worked out that what was happening 
> was: 
> - A's value was changed & the event listener was invoked 
> - The model for B was updated correctly 
> - The FieldLabel that refered to B was rendered with a NullWriter 
> - this field label prerendered B (to get its id) with the NullWriter 
> - B was rendered with a real writer but didn't output anything because it 
> had been prerendered 
> - The page was updated an empty B element (cause the NullWriter discards 
> everything). 
> To work around this I gave the FieldLabel (for B) an explicit id and added 
> an updateComponent call for the this id.  When I did this the page behaved 
> as I was expecting. 
> Now my question: Is this behaviour correct? 
>                  Or have I approached the problem incorrectly? 
> It seems a bit unintuitive, I would prefer B to render properly when I asked 
> it to be updated, rather than having to update both it and the label. 
> However I'm not sure how to get my desired behaviour.  Maybe the 
> DojoAjaxResponseBuilder could check the form prerender map after each 
> component render and clear out any prerender's with null results.... 
> ...or maybe wiser heads can come up with a much more elegant solution :) 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Commented: (TAPESTRY-1023) Calling updateComponent in @EventListener method on a component that is prerendered results in null update

Posted by "Ben Sommerville (JIRA)" <ta...@jakarta.apache.org>.
    [ http://issues.apache.org/jira/browse/TAPESTRY-1023?page=comments#action_12423964 ] 
            
Ben Sommerville commented on TAPESTRY-1023:
-------------------------------------------

I thought about this a bit more overnight & decided that my suggested solution probably won't work.   Removing the component from the prerender map will result in the component rendering twice.  I'm pretty sure this is not a good thing & could lead to some strange bugs :).

Ideally when prerendering a component that is being updated we would use a real writer, rather than the NullWriter.  But I cant see how to accomplish this without rendering all components with a real writer (or significantly changing the writer interface)

> Calling updateComponent in @EventListener method on a component that is prerendered results in null update
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-1023
>                 URL: http://issues.apache.org/jira/browse/TAPESTRY-1023
>             Project: Tapestry
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 4.1
>         Environment: Tapestery 4.1 Head,  JBoss 4.0.4 GA,  Windows XP
>            Reporter: Ben Sommerville
>
> I had a problem with @EventListener tonight but I'm not sure if this is a 
> bug or ignorance on my part. 
> (I am working with the latest 4.1 version from svn) 
>   
> First let me explain what I am trying to do.... 
> I have a form with several PropertySelection input fields on it.  What I 
> want to do is change the selectable options based on what has already been 
> selected.  
> e.g.  Say the form has two select fields A & B 
> A has options 1,2,3. 
> If the value of A is 1, then B should have options 11, 12, 13 
> If the value of A is 2, then B should have options 21, 22, 23 
> If the value of A is 3, then B should have options 31, 32, 33 
>   
> Now in the page template the fields are defined as follows 
>   
> <div class="field"> 
>     <label jwcid="@FieldLabel" field="component:A">Role</label> 
>     <input jwcid="A@PropertySelection" value="ognl:A" displayName="A" 
>            model="ognl:aModel"/> 
> </div> 
> <div class="field"> 
>     <label jwcid="@FieldLabel" field="component:B">B</label> 
>     <input jwcid="B@PropertySelection" value="ognl:B" displayName="B" 
>            model="ognl:bModel"/> 
> </div> 
> To update the options displayed by B I defined the following method 
> @EventListener(targets="A", events="onchange", submitForm ="form") 
> public void selectA(IRequestCycle cycle) { 
>    bModel = .... New model for b based on value of A .... 
>    cycle.getResponseBuilder().updateComponent("b"); 
> } 
>   
> What I was expecting to happen was that when the value of A was changed then 
> B would be rerendered with the new options based on A's value. 
> What actually happened was that as soon as I changed the value of A then B 
> was rendered with no options at all. 
> After a bit of debugging I eventually worked out that what was happening 
> was: 
> - A's value was changed & the event listener was invoked 
> - The model for B was updated correctly 
> - The FieldLabel that refered to B was rendered with a NullWriter 
> - this field label prerendered B (to get its id) with the NullWriter 
> - B was rendered with a real writer but didn't output anything because it 
> had been prerendered 
> - The page was updated an empty B element (cause the NullWriter discards 
> everything). 
> To work around this I gave the FieldLabel (for B) an explicit id and added 
> an updateComponent call for the this id.  When I did this the page behaved 
> as I was expecting. 
> Now my question: Is this behaviour correct? 
>                  Or have I approached the problem incorrectly? 
> It seems a bit unintuitive, I would prefer B to render properly when I asked 
> it to be updated, rather than having to update both it and the label. 
> However I'm not sure how to get my desired behaviour.  Maybe the 
> DojoAjaxResponseBuilder could check the form prerender map after each 
> component render and clear out any prerender's with null results.... 
> ...or maybe wiser heads can come up with a much more elegant solution :) 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Assigned: (TAPESTRY-1023) Calling updateComponent in @EventListener method on a component that is prerendered results in null update

Posted by "Jesse Kuhnert (JIRA)" <ta...@jakarta.apache.org>.
     [ http://issues.apache.org/jira/browse/TAPESTRY-1023?page=all ]

Jesse Kuhnert reassigned TAPESTRY-1023:
---------------------------------------

    Assignee: Jesse Kuhnert

> Calling updateComponent in @EventListener method on a component that is prerendered results in null update
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-1023
>                 URL: http://issues.apache.org/jira/browse/TAPESTRY-1023
>             Project: Tapestry
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 4.1
>         Environment: Tapestery 4.1 Head,  JBoss 4.0.4 GA,  Windows XP
>            Reporter: Ben Sommerville
>         Assigned To: Jesse Kuhnert
>
> I had a problem with @EventListener tonight but I'm not sure if this is a 
> bug or ignorance on my part. 
> (I am working with the latest 4.1 version from svn) 
>   
> First let me explain what I am trying to do.... 
> I have a form with several PropertySelection input fields on it.  What I 
> want to do is change the selectable options based on what has already been 
> selected.  
> e.g.  Say the form has two select fields A & B 
> A has options 1,2,3. 
> If the value of A is 1, then B should have options 11, 12, 13 
> If the value of A is 2, then B should have options 21, 22, 23 
> If the value of A is 3, then B should have options 31, 32, 33 
>   
> Now in the page template the fields are defined as follows 
>   
> <div class="field"> 
>     <label jwcid="@FieldLabel" field="component:A">Role</label> 
>     <input jwcid="A@PropertySelection" value="ognl:A" displayName="A" 
>            model="ognl:aModel"/> 
> </div> 
> <div class="field"> 
>     <label jwcid="@FieldLabel" field="component:B">B</label> 
>     <input jwcid="B@PropertySelection" value="ognl:B" displayName="B" 
>            model="ognl:bModel"/> 
> </div> 
> To update the options displayed by B I defined the following method 
> @EventListener(targets="A", events="onchange", submitForm ="form") 
> public void selectA(IRequestCycle cycle) { 
>    bModel = .... New model for b based on value of A .... 
>    cycle.getResponseBuilder().updateComponent("b"); 
> } 
>   
> What I was expecting to happen was that when the value of A was changed then 
> B would be rerendered with the new options based on A's value. 
> What actually happened was that as soon as I changed the value of A then B 
> was rendered with no options at all. 
> After a bit of debugging I eventually worked out that what was happening 
> was: 
> - A's value was changed & the event listener was invoked 
> - The model for B was updated correctly 
> - The FieldLabel that refered to B was rendered with a NullWriter 
> - this field label prerendered B (to get its id) with the NullWriter 
> - B was rendered with a real writer but didn't output anything because it 
> had been prerendered 
> - The page was updated an empty B element (cause the NullWriter discards 
> everything). 
> To work around this I gave the FieldLabel (for B) an explicit id and added 
> an updateComponent call for the this id.  When I did this the page behaved 
> as I was expecting. 
> Now my question: Is this behaviour correct? 
>                  Or have I approached the problem incorrectly? 
> It seems a bit unintuitive, I would prefer B to render properly when I asked 
> it to be updated, rather than having to update both it and the label. 
> However I'm not sure how to get my desired behaviour.  Maybe the 
> DojoAjaxResponseBuilder could check the form prerender map after each 
> component render and clear out any prerender's with null results.... 
> ...or maybe wiser heads can come up with a much more elegant solution :) 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Updated: (TAPESTRY-1023) Calling updateComponent in @EventListener method on a component that is prerendered results in null update

Posted by "Ben Sommerville (JIRA)" <ta...@jakarta.apache.org>.
     [ http://issues.apache.org/jira/browse/TAPESTRY-1023?page=all ]

Ben Sommerville updated TAPESTRY-1023:
--------------------------------------

    Attachment: TAP-1023.patch

Slightly improved patch.
This handles getting the clientId of a component after it has been rendered.


> Calling updateComponent in @EventListener method on a component that is prerendered results in null update
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-1023
>                 URL: http://issues.apache.org/jira/browse/TAPESTRY-1023
>             Project: Tapestry
>          Issue Type: Bug
>          Components: Annotations
>    Affects Versions: 4.1
>         Environment: Tapestery 4.1 Head,  JBoss 4.0.4 GA,  Windows XP
>            Reporter: Ben Sommerville
>         Assigned To: Jesse Kuhnert
>             Fix For: 4.1.1
>
>         Attachments: TAP-1023.patch, TAP-1023.patch
>
>
> I had a problem with @EventListener tonight but I'm not sure if this is a 
> bug or ignorance on my part. 
> (I am working with the latest 4.1 version from svn) 
>   
> First let me explain what I am trying to do.... 
> I have a form with several PropertySelection input fields on it.  What I 
> want to do is change the selectable options based on what has already been 
> selected.  
> e.g.  Say the form has two select fields A & B 
> A has options 1,2,3. 
> If the value of A is 1, then B should have options 11, 12, 13 
> If the value of A is 2, then B should have options 21, 22, 23 
> If the value of A is 3, then B should have options 31, 32, 33 
>   
> Now in the page template the fields are defined as follows 
>   
> <div class="field"> 
>     <label jwcid="@FieldLabel" field="component:A">Role</label> 
>     <input jwcid="A@PropertySelection" value="ognl:A" displayName="A" 
>            model="ognl:aModel"/> 
> </div> 
> <div class="field"> 
>     <label jwcid="@FieldLabel" field="component:B">B</label> 
>     <input jwcid="B@PropertySelection" value="ognl:B" displayName="B" 
>            model="ognl:bModel"/> 
> </div> 
> To update the options displayed by B I defined the following method 
> @EventListener(targets="A", events="onchange", submitForm ="form") 
> public void selectA(IRequestCycle cycle) { 
>    bModel = .... New model for b based on value of A .... 
>    cycle.getResponseBuilder().updateComponent("b"); 
> } 
>   
> What I was expecting to happen was that when the value of A was changed then 
> B would be rerendered with the new options based on A's value. 
> What actually happened was that as soon as I changed the value of A then B 
> was rendered with no options at all. 
> After a bit of debugging I eventually worked out that what was happening 
> was: 
> - A's value was changed & the event listener was invoked 
> - The model for B was updated correctly 
> - The FieldLabel that refered to B was rendered with a NullWriter 
> - this field label prerendered B (to get its id) with the NullWriter 
> - B was rendered with a real writer but didn't output anything because it 
> had been prerendered 
> - The page was updated an empty B element (cause the NullWriter discards 
> everything). 
> To work around this I gave the FieldLabel (for B) an explicit id and added 
> an updateComponent call for the this id.  When I did this the page behaved 
> as I was expecting. 
> Now my question: Is this behaviour correct? 
>                  Or have I approached the problem incorrectly? 
> It seems a bit unintuitive, I would prefer B to render properly when I asked 
> it to be updated, rather than having to update both it and the label. 
> However I'm not sure how to get my desired behaviour.  Maybe the 
> DojoAjaxResponseBuilder could check the form prerender map after each 
> component render and clear out any prerender's with null results.... 
> ...or maybe wiser heads can come up with a much more elegant solution :) 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org