You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Alex Kwan <er...@hotmail.com> on 2004/03/13 04:16:40 UTC

Can not change form content dynamiclly?

Hi, All
    Recently, I ran into a strange problem. I have a form that contains
some submit buttons. Just below the buttons, there are several input field.
Whether to show these field are judged by the listeners of the submit
buttons. For example, if I click the showName field button, the name input
field will be shown and other buttons will be hide.

    But in the rewind cycle, The listeners are invoked according to the
rendering order, so the button listeners are invoked before rerendering the
field. The tapestry will check the form's elements and find the count of the
element changed,
so it will report the stale link exception.


    Now how can I handle this situation?

    Any suggestion will be appreciated.


Alex Kwan

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


Re: Can not change form content dynamiclly?

Posted by Jamie Orchard-Hays <ja...@dang.com>.
OK, I started a Gotchas page with the first big gotcha that got me when 
I started Tapestry: misusing initialize()!

Jamie

On Mar 12, 2004, at 10:21 PM, Erik Hatcher wrote:

> Use contrib:FormConditional instead of Conditional - that will do the 
> trick.
>
> Anybody wanna volunteer to start a "Gotchas" wiki page? :)
>
> 	Erik
>
>
> On Mar 12, 2004, at 10:16 PM, Alex Kwan wrote:
>
>> Hi, All
>>     Recently, I ran into a strange problem. I have a form that 
>> contains
>> some submit buttons. Just below the buttons, there are several input 
>> field.
>> Whether to show these field are judged by the listeners of the submit
>> buttons. For example, if I click the showName field button, the name 
>> input
>> field will be shown and other buttons will be hide.
>>
>>     But in the rewind cycle, The listeners are invoked according to 
>> the
>> rendering order, so the button listeners are invoked before 
>> rerendering the
>> field. The tapestry will check the form's elements and find the count 
>> of the
>> element changed,
>> so it will report the stale link exception.
>>
>>
>>     Now how can I handle this situation?
>>
>>     Any suggestion will be appreciated.
>>
>>
>> Alex Kwan
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


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


Re: Can not change form content dynamiclly?

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
Use contrib:FormConditional instead of Conditional - that will do the 
trick.

Anybody wanna volunteer to start a "Gotchas" wiki page? :)

	Erik


On Mar 12, 2004, at 10:16 PM, Alex Kwan wrote:

> Hi, All
>     Recently, I ran into a strange problem. I have a form that contains
> some submit buttons. Just below the buttons, there are several input 
> field.
> Whether to show these field are judged by the listeners of the submit
> buttons. For example, if I click the showName field button, the name 
> input
> field will be shown and other buttons will be hide.
>
>     But in the rewind cycle, The listeners are invoked according to the
> rendering order, so the button listeners are invoked before 
> rerendering the
> field. The tapestry will check the form's elements and find the count 
> of the
> element changed,
> so it will report the stale link exception.
>
>
>     Now how can I handle this situation?
>
>     Any suggestion will be appreciated.
>
>
> Alex Kwan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


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


Re: Can not change form content dynamiclly?

Posted by Alex Kwan <er...@hotmail.com>.
Thanks Vince and Erik.
    You two always give me the best answers.
    But this does show some trick aspects of Tapestry. I hope we can have a
better solution to these kind problems.
    BTW: I really want to contribute to the Tapestry Gotchas:)

Alex


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


RE: Can not change form content dynamiclly?

Posted by Vince Platt <Vi...@comcast.net>.
Alex, have you tried performing your actions in the Form component's listener?  I don't know if I understood your problem exactly, but I suspect that using the form's listener will solve the issue.  If you read the description for the Form component (http://jakarta.apache.org/tapestry/doc/ComponentReference/Form.html) a little more closely, you'll notice that the listener for a Form gets executed AFTER  the components have all finished their processing.  The implication of this is that you can not RELIABLY modify or read the posted data until the Form's listener is executed.  It sometimes does work out OK, but not always and experience has shown me that it shouldn't be relied upon.  

Also, you mentioned that you have several submit buttons.  In order to be able to tell which button was clicked and caused the submit, you will want to either have the Submit listeners set a flag which you then check in the Form's listener, or you can use the 'tag' and 'listener' parameters for the Submit component as documented (http://jakarta.apache.org/tapestry/doc/ComponentReference/Submit.html).

I hope that helps!
-Vince


-----Original Message-----
From: Alex Kwan [mailto:erazor_kwan@hotmail.com]
Sent: Friday, March 12, 2004 9:17 PM
To: Tapestry users
Subject: Can not change form content dynamiclly?


Hi, All
    Recently, I ran into a strange problem. I have a form that contains
some submit buttons. Just below the buttons, there are several input field.
Whether to show these field are judged by the listeners of the submit
buttons. For example, if I click the showName field button, the name input
field will be shown and other buttons will be hide.

    But in the rewind cycle, The listeners are invoked according to the
rendering order, so the button listeners are invoked before rerendering the
field. The tapestry will check the form's elements and find the count of the
element changed,
so it will report the stale link exception.


    Now how can I handle this situation?

    Any suggestion will be appreciated.


Alex Kwan



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