You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by ADong <gz...@hotmail.com> on 2005/01/13 05:57:50 UTC

How to do to activate ExternalService in a listener method.

hi,
   The Form component uses DirectLink to activate a page and pass parameters. I 
have a question about this. After the Form was submitted, the listener method 
passed parameters and activated a new page. and then, if I refresh the page, 
the Form will be submitted again. 
   I will not want to submit the Form again, when the page is refreshed. I 
think that if I could activate ExternalService in listener method, and create 
the URLs as ExternalLink to jump to a new page. 
   Could you tell me how to do? 


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


Re: How to do to activate ExternalService in a listener method.

Posted by ADong <gz...@hotmail.com>.
   I will study your method conscientiously . Make me know Tapestry more 
deeply. 
   Thank you very much, Paul :)







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


Re: How to do to activate ExternalService in a listener method.

Posted by Martin Gladdish <ma...@egsgroup.com>.
Thanks Jon.

I'd just found that myself stepping through the code as your reply came 
in :)

Martin.

On 13 Jan 2005, at 15:51, Jonathan Millett wrote:

> In your RedirectException, use a fully qualified url.
> If the url starts with '/' or contains '://', then RedirectException 
> will cause a 3xx redirect to returned to the client.
> If the url is a relative url, the request just gets redirected 
> internally to another servlet.  Since this doesn't update the client 
> url, a refresh will just resubmit the same form post.
>
> Jon
>
> Martin Gladdish wrote:
>
>> Paul,
>>
>> I've got a similar situation to this, where submitting the form and  
>> then refreshing the resultant page submits the form again. The  
>> difference is that I am already throwing a RedirectException in my 
>> form  listener to go to a non-tapestry page.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
Martin Gladdish
e-Government Solutions (UK) Ltd
Tel: 020 7539 2823


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


Re: How to do to activate ExternalService in a listener method.

Posted by Jonathan Millett <jo...@millett.net>.
In your RedirectException, use a fully qualified url.
If the url starts with '/' or contains '://', then RedirectException 
will cause a 3xx redirect to returned to the client.
If the url is a relative url, the request just gets redirected 
internally to another servlet.  Since this doesn't update the client 
url, a refresh will just resubmit the same form post.

Jon

Martin Gladdish wrote:

> Paul,
>
> I've got a similar situation to this, where submitting the form and  
> then refreshing the resultant page submits the form again. The  
> difference is that I am already throwing a RedirectException in my 
> form  listener to go to a non-tapestry page.



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


Re: How to do to activate ExternalService in a listener method.

Posted by Martin Gladdish <ma...@egsgroup.com>.
Paul,

I've got a similar situation to this, where submitting the form and  
then refreshing the resultant page submits the form again. The  
difference is that I am already throwing a RedirectException in my form  
listener to go to a non-tapestry page.

public abstract class SpotQuotePage extends BasePage implements  
PageRenderListener, IExternalPage {

     public abstract SpotQuote getSpotQuote();
     public abstract void setSpotQuote(SpotQuote spotQuote);


     public void formSubmit(IRequestCycle cycle) {

         // check for errors
         IValidationDelegate delegate = (IValidationDelegate)  
getBeans().getBean("delegate");
         if (delegate.getHasErrors()) {
             return;
         }

         // process new quote information
         Visit visit = (Visit) getVisit();
         SpotQuoteService spotQuoteService =  
ServiceLocator.getServiceLocator(visit.getUserProfile()).getSpotQuoteSer 
vice();
         try {
             spotQuoteService.saveSpotQuote(getSpotQuote());
         }
         catch (ServiceException se) {
             delegate.record("Error saving spot quote: " +  
se.getMessage(), ValidationConstraint.CONSISTENCY);
             return;
         }

         // go back to the non-tapestry spot quote front page.
         throw new RedirectException("quote/open.jsp");
     }

     // more code omitted....
}

Any ideas what I can do in this situation to prevent the form being  
re-submitted?

Many thanks,

Martin Gladdish.


On 13 Jan 2005, at 07:09, Paul Ferraro wrote:

> The following method will generate a RedirectException for an  
> IExternalPage:
>
> public RedirectException createExternalRedirectException(IRequestCycle  
> requestCycle, String targetPage, Object[] rawParameters)
> {
>    Object[] squeezedParameters =  
> DirectLink.constructServiceParameters(rawParameters);
>    if (squeezedParameters == null)
>    {         squeezedParameters = new Object[0];
>    }
>    Object[] serviceParameters = new Object[squeezedParameters.length +  
> 1];
>    serviceParameters[0] = targetPage;
>    System.arraycopy(squeezedParameters, 0, serviceParameters, 1,  
> squeezedParameters.length);
>    ILink link =  
> requestCycle.getEngine().getService(Tapestry.EXTERNAL_SERVICE).getLink( 
> requestCycle, requestCycle.getPage(), serviceParameters);
>    return new RedirectException(link.getURL());
> }
>
> Tapestry 3.1 will address the cumbersome aspects of generating  
> intra-application RedirectExceptions.
>
> Paul
>
> ADong wrote:
>
>>
>>
>>  I know that throwing a RedirectExcetpion can jump to a JSP page. But  
>> I don't kown how to pass parameters and generating the url as  
>> ExternalLink。
>>  Could you tell me in detail?
>>  Thank you very much.
>>
>> ADong
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>
>
Martin Gladdish
e-Government Solutions (UK) Ltd
Tel: 020 7539 2823

Re: How to do to activate ExternalService in a listener method.

Posted by Paul Ferraro <pm...@columbia.edu>.
The following method will generate a RedirectException for an IExternalPage:

public RedirectException createExternalRedirectException(IRequestCycle 
requestCycle, String targetPage, Object[] rawParameters)
{
    Object[] squeezedParameters = 
DirectLink.constructServiceParameters(rawParameters);
    if (squeezedParameters == null)
    {  
        squeezedParameters = new Object[0];
    }
    Object[] serviceParameters = new Object[squeezedParameters.length + 1];
    serviceParameters[0] = targetPage;
    System.arraycopy(squeezedParameters, 0, serviceParameters, 1, 
squeezedParameters.length);
    ILink link = 
requestCycle.getEngine().getService(Tapestry.EXTERNAL_SERVICE).getLink(requestCycle, 
requestCycle.getPage(), serviceParameters);
    return new RedirectException(link.getURL());
}

Tapestry 3.1 will address the cumbersome aspects of generating 
intra-application RedirectExceptions.

Paul

ADong wrote:

>
>
>  I know that throwing a RedirectExcetpion can jump to a JSP page. But I don't 
>kown how to pass parameters and generating the url as ExternalLink。
>  Could you tell me in detail?
>  Thank you very much.
>
>ADong
>
>
>
>
>---------------------------------------------------------------------
>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: How to do to activate ExternalService in a listener method.

Posted by ADong <gz...@hotmail.com>.



  I know that throwing a RedirectExcetpion can jump to a JSP page. But I don't 
kown how to pass parameters and generating the url as ExternalLink。
  Could you tell me in detail?
  Thank you very much.

ADong




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


Re: How to do to activate ExternalService in a listener method.

Posted by Paul Ferraro <pm...@columbia.edu>.
Throw a RedirectException at the end of your listener method.  Use the 
external service to generate an ILink capable of generating the url from 
which to construct the RedirectException.

Paul

ADong wrote:

>hi,
>   The Form component uses DirectLink to activate a page and pass parameters. I 
>have a question about this. After the Form was submitted, the listener method 
>passed parameters and activated a new page. and then, if I refresh the page, 
>the Form will be submitted again. 
>   I will not want to submit the Form again, when the page is refreshed. I 
>think that if I could activate ExternalService in listener method, and create 
>the URLs as ExternalLink to jump to a new page. 
>   Could you tell me how to do? 
>
>
>---------------------------------------------------------------------
>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