That sounds like a great issue to fix, thanks Ben! Is there any possibility you could file this in JIRA? I'm not working on this today and may forget about it otherwise.
On 7/27/06, Ben Sommerville <[EMAIL PROTECTED]> wrote:
Hi, 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="[EMAIL PROTECTED]" value="ognl:A" displayName="A" model="ognl:aModel"/> </div> <div class="field"> <label jwcid="@FieldLabel" field="component:B">B</label> <input jwcid="[EMAIL PROTECTED]" 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 :) Also, while I was working with this form I kept getting the following error in the console "[MarkupWriterSource] No markup filter could be found for content type 'text/xml;charset=UTF-8'; a default filter has been used." Any ideas what might be causing this? thanks -- Ben Sommerville --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Jesse Kuhnert Tacos/Tapestry, team member/developer Open source based consulting work centered around dojo/tapestry/tacos/hivemind.