You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Vince Platt <Vi...@comcast.net> on 2004/03/11 21:24:28 UTC

DirectLink and rewinding

Everyone, I have a situation where I need a DirectLink component to access some persistent properties (which are updated by Checkbox components) during execution of the DirectLink's listener.  I know that because the form rewind is not performed before the DirectLink listeners, those persistent properties do not yet contain the updated values that were submitted by the user.  I know I can circumvent this issue by using a Form listener instead, as the rewind has already occurred before those listeners get executed, but I would rather avoid doing that.  (The short story here is that this is for a component which resides in another component instance, which resides on the Form.  I would like to avoid breaking the form up to solve the problem.)

So, I apologize if I seem to lack imagination on this problem, but I'm a little under the gun here and not feeling the best; so I thought I would ask for ideas.  I am a little perplexed as to why the DirectLink and all other non-Form component listeners must get executed before a rewind.  

Thank you!



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


Re: DirectLink and rewinding

Posted by Jamie Orchard-Hays <ja...@dang.com>.
Direct link has parameters--you could stuff the properties in there.

Or, you could use ActionLink, which has a rewind phase (no parameters).


----- Original Message ----- 
From: "Vince Platt" <Vi...@comcast.net>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Thursday, March 11, 2004 3:24 PM
Subject: DirectLink and rewinding


Everyone, I have a situation where I need a DirectLink component to access
some persistent properties (which are updated by Checkbox components) during
execution of the DirectLink's listener.  I know that because the form rewind
is not performed before the DirectLink listeners, those persistent
properties do not yet contain the updated values that were submitted by the
user.  I know I can circumvent this issue by using a Form listener instead,
as the rewind has already occurred before those listeners get executed, but
I would rather avoid doing that.  (The short story here is that this is for
a component which resides in another component instance, which resides on
the Form.  I would like to avoid breaking the form up to solve the problem.)

So, I apologize if I seem to lack imagination on this problem, but I'm a
little under the gun here and not feeling the best; so I thought I would ask
for ideas.  I am a little perplexed as to why the DirectLink and all other
non-Form component listeners must get executed before a rewind.

Thank you!



---------------------------------------------------------------------
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: DirectLink and rewinding

Posted by Colin Sampaleanu <co...@exis.com>.
I actually had a somewhat similar issue in some code on which I was 
working about 3 weeks ago and had to put aside due to time pressures. 
The table component uses a DirectLink for the column headers, which is 
supposed to sort the column. But if you come in off that DirectLink, and 
the table model is coming from a persistent page property, then it's not 
around any longer, since the rewind hasn't been done yet.


Vince Platt wrote:

>I also thought a LinkSubmit would work, except that my DirectLink has a target="_new" which gives me a new window without using JavaScript which then gets redirected to a JSP page that hosts the Crystal Reports 10 Java Reporting Component.  That totally breaks the LinkSubmit as it makes the new window come up with the one liner JavaScript in the URL, which isn't good for anything.  Unfortunately, it kind of has to be that way since I have to go out to JSP instead of Tapestry (side note, there probably could be some conceivable way to get them to cooperate, but there just isn't enough time) because Tapestry and JSP don't play well together in the same context (yeah, I tried; it wasn't pretty). 
>
>Anyway, I digress...  
>
>I've read up a little more on the DirectLink and ActionLink components, and it would appear from the documentation that the listeners for each will simply be rewound only up to "Whatever state the page was in when the action URL was rendered in the previous request cycle is restored before the ActionLink component's listener is invoked" (http://jakarta.apache.org/tapestry/doc/DevelopersGuide/cycle.action.html) for the ActionLink and "The state of the page when the listener is invoked is its state just prior to rendering (in the previous request cycle)" (http://jakarta.apache.org/tapestry/doc/DevelopersGuide/cycle.direct.html) for the DirectLink.  So, it would appear that the new data posted by the user would not be available yet, and in fact seems unavailable at all until a Form listener is executed.  And that is the crux of my problem.  I need the data the user just posted, not the data that was presented to the user on the last round trip.  
>
>As far as sending the parameters to the JSP page, I've got that all nailed down and it's no issue.  
>
>I am thinking I will be forced to butcher the page a bit into smaller Forms so our Tapestry component can have its own form.  That should clear the problem right up.
>
>It feels like I'm missing a more elegant solution though.  Shouldn't a application/horizontal component be able to participate in all POST time activities, whether or not it's nested in a Form component?  It certainly would be nice.  Hopefully, I'm just missing something really obvious and someone will make me feel silly.  That would be a good thing right now.  :+)
>
>Thanks for the quick responses!
>-Vince
>
>
>-----Original Message-----
>From: Paul Ferraro [mailto:pmf8@columbia.edu]
>Sent: Thursday, March 11, 2004 2:54 PM
>To: Tapestry users
>Subject: Re: DirectLink and rewinding
>
>
>Maybe I'm misunderstanding your problem, but if you are trying to submit 
>a form via a link, then you need to use a LinkSubmit component, not a 
>DirectLink component.  That will ensure that your form is properly 
>rewound before triggering your LinkSubmit's IActionListener.
>
>Paul Ferraro
>
>Ezra Epstein wrote:
>
>  
>
>>>Everyone, I have a situation where I need a DirectLink component 
>>>to access some persistent properties (which are updated by 
>>>Checkbox components) during execution of the DirectLink's 
>>>listener.  I know that because the form rewind is not performed 
>>>before the DirectLink listeners, those persistent properties do 
>>>not yet contain the updated values that were submitted by the 
>>>user.  I know I can circumvent this issue by using a Form 
>>>listener instead, as the rewind has already occurred before those 
>>>listeners get executed, but I would rather avoid doing that.  
>>>(The short story here is that this is for a component which 
>>>resides in another component instance, which resides on the Form. 
>>>I would like to avoid breaking the form up to solve the problem.)
>>>   
>>>
>>>      
>>>
>>1.  There's ActionLink which does get executed after a rewind.  That's the quickest fix.
>>
>>2.  You can provide parameters to the DirectLink.  I have plenty of cases of this if you want examples.  The gist is: take the id (or other small and easily serializable repesentation) of the object(s) and use it (them) as parameters for the DirectLink.  Then in the Listener use these parameters to load the real objects -- I generally just write a lazy loader for the object so I just set the Id (or whatever) in the Listener method and then the implementation of my get method takes it from there....  (Again, let me know if an example of the code would be handy.)
>>
>> 
>>
>>    
>>
>>>So, I apologize if I seem to lack imagination on this problem, 
>>>but I'm a little under the gun here and not feeling the best; so 
>>>I thought I would ask for ideas.  I am a little perplexed as to 
>>>why the DirectLink and all other non-Form component listeners 
>>>must get executed before a rewind.  
>>>   
>>>
>>>      
>>>
>>I don't know enough about the internals to say, but hope my recommendations above help a bit.
>>
>>== Ezra E.
>>    
>>
>
>
>
>---------------------------------------------------------------------
>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: DirectLink and rewinding

Posted by Vince Platt <Vi...@comcast.net>.
I also thought a LinkSubmit would work, except that my DirectLink has a target="_new" which gives me a new window without using JavaScript which then gets redirected to a JSP page that hosts the Crystal Reports 10 Java Reporting Component.  That totally breaks the LinkSubmit as it makes the new window come up with the one liner JavaScript in the URL, which isn't good for anything.  Unfortunately, it kind of has to be that way since I have to go out to JSP instead of Tapestry (side note, there probably could be some conceivable way to get them to cooperate, but there just isn't enough time) because Tapestry and JSP don't play well together in the same context (yeah, I tried; it wasn't pretty). 

Anyway, I digress...  

I've read up a little more on the DirectLink and ActionLink components, and it would appear from the documentation that the listeners for each will simply be rewound only up to "Whatever state the page was in when the action URL was rendered in the previous request cycle is restored before the ActionLink component's listener is invoked" (http://jakarta.apache.org/tapestry/doc/DevelopersGuide/cycle.action.html) for the ActionLink and "The state of the page when the listener is invoked is its state just prior to rendering (in the previous request cycle)" (http://jakarta.apache.org/tapestry/doc/DevelopersGuide/cycle.direct.html) for the DirectLink.  So, it would appear that the new data posted by the user would not be available yet, and in fact seems unavailable at all until a Form listener is executed.  And that is the crux of my problem.  I need the data the user just posted, not the data that was presented to the user on the last round trip.  

As far as sending the parameters to the JSP page, I've got that all nailed down and it's no issue.  

I am thinking I will be forced to butcher the page a bit into smaller Forms so our Tapestry component can have its own form.  That should clear the problem right up.

It feels like I'm missing a more elegant solution though.  Shouldn't a application/horizontal component be able to participate in all POST time activities, whether or not it's nested in a Form component?  It certainly would be nice.  Hopefully, I'm just missing something really obvious and someone will make me feel silly.  That would be a good thing right now.  :+)

Thanks for the quick responses!
-Vince


-----Original Message-----
From: Paul Ferraro [mailto:pmf8@columbia.edu]
Sent: Thursday, March 11, 2004 2:54 PM
To: Tapestry users
Subject: Re: DirectLink and rewinding


Maybe I'm misunderstanding your problem, but if you are trying to submit 
a form via a link, then you need to use a LinkSubmit component, not a 
DirectLink component.  That will ensure that your form is properly 
rewound before triggering your LinkSubmit's IActionListener.

Paul Ferraro

Ezra Epstein wrote:

>>Everyone, I have a situation where I need a DirectLink component 
>>to access some persistent properties (which are updated by 
>>Checkbox components) during execution of the DirectLink's 
>>listener.  I know that because the form rewind is not performed 
>>before the DirectLink listeners, those persistent properties do 
>>not yet contain the updated values that were submitted by the 
>>user.  I know I can circumvent this issue by using a Form 
>>listener instead, as the rewind has already occurred before those 
>>listeners get executed, but I would rather avoid doing that.  
>>(The short story here is that this is for a component which 
>>resides in another component instance, which resides on the Form. 
>> I would like to avoid breaking the form up to solve the problem.)
>>    
>>
>
>1.  There's ActionLink which does get executed after a rewind.  That's the quickest fix.
>
>2.  You can provide parameters to the DirectLink.  I have plenty of cases of this if you want examples.  The gist is: take the id (or other small and easily serializable repesentation) of the object(s) and use it (them) as parameters for the DirectLink.  Then in the Listener use these parameters to load the real objects -- I generally just write a lazy loader for the object so I just set the Id (or whatever) in the Listener method and then the implementation of my get method takes it from there....  (Again, let me know if an example of the code would be handy.)
>
>  
>
>>So, I apologize if I seem to lack imagination on this problem, 
>>but I'm a little under the gun here and not feeling the best; so 
>>I thought I would ask for ideas.  I am a little perplexed as to 
>>why the DirectLink and all other non-Form component listeners 
>>must get executed before a rewind.  
>>    
>>
>
>I don't know enough about the internals to say, but hope my recommendations above help a bit.
>
>== Ezra E.



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


Re: DirectLink and rewinding

Posted by Paul Ferraro <pm...@columbia.edu>.
Maybe I'm misunderstanding your problem, but if you are trying to submit 
a form via a link, then you need to use a LinkSubmit component, not a 
DirectLink component.  That will ensure that your form is properly 
rewound before triggering your LinkSubmit's IActionListener.

Paul Ferraro

Ezra Epstein wrote:

>>Everyone, I have a situation where I need a DirectLink component 
>>to access some persistent properties (which are updated by 
>>Checkbox components) during execution of the DirectLink's 
>>listener.  I know that because the form rewind is not performed 
>>before the DirectLink listeners, those persistent properties do 
>>not yet contain the updated values that were submitted by the 
>>user.  I know I can circumvent this issue by using a Form 
>>listener instead, as the rewind has already occurred before those 
>>listeners get executed, but I would rather avoid doing that.  
>>(The short story here is that this is for a component which 
>>resides in another component instance, which resides on the Form. 
>> I would like to avoid breaking the form up to solve the problem.)
>>    
>>
>
>1.  There's ActionLink which does get executed after a rewind.  That's the quickest fix.
>
>2.  You can provide parameters to the DirectLink.  I have plenty of cases of this if you want examples.  The gist is: take the id (or other small and easily serializable repesentation) of the object(s) and use it (them) as parameters for the DirectLink.  Then in the Listener use these parameters to load the real objects -- I generally just write a lazy loader for the object so I just set the Id (or whatever) in the Listener method and then the implementation of my get method takes it from there....  (Again, let me know if an example of the code would be handy.)
>
>  
>
>>So, I apologize if I seem to lack imagination on this problem, 
>>but I'm a little under the gun here and not feeling the best; so 
>>I thought I would ask for ideas.  I am a little perplexed as to 
>>why the DirectLink and all other non-Form component listeners 
>>must get executed before a rewind.  
>>    
>>
>
>I don't know enough about the internals to say, but hope my recommendations above help a bit.
>
>== Ezra E.
>
>
>---------------------------------------------------------------------
>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: DirectLink and rewinding

Posted by Ezra Epstein <ee...@prajnait.com>.
> Everyone, I have a situation where I need a DirectLink component 
> to access some persistent properties (which are updated by 
> Checkbox components) during execution of the DirectLink's 
> listener.  I know that because the form rewind is not performed 
> before the DirectLink listeners, those persistent properties do 
> not yet contain the updated values that were submitted by the 
> user.  I know I can circumvent this issue by using a Form 
> listener instead, as the rewind has already occurred before those 
> listeners get executed, but I would rather avoid doing that.  
> (The short story here is that this is for a component which 
> resides in another component instance, which resides on the Form. 
>  I would like to avoid breaking the form up to solve the problem.)

1.  There's ActionLink which does get executed after a rewind.  That's the quickest fix.

2.  You can provide parameters to the DirectLink.  I have plenty of cases of this if you want examples.  The gist is: take the id (or other small and easily serializable repesentation) of the object(s) and use it (them) as parameters for the DirectLink.  Then in the Listener use these parameters to load the real objects -- I generally just write a lazy loader for the object so I just set the Id (or whatever) in the Listener method and then the implementation of my get method takes it from there....  (Again, let me know if an example of the code would be handy.)

> So, I apologize if I seem to lack imagination on this problem, 
> but I'm a little under the gun here and not feeling the best; so 
> I thought I would ask for ideas.  I am a little perplexed as to 
> why the DirectLink and all other non-Form component listeners 
> must get executed before a rewind.  

I don't know enough about the internals to say, but hope my recommendations above help a bit.

== Ezra E.


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