I haven't tried this... but it might work.

public class MyStringRequestTarget extends StringRequestTarget {

/**
 * @param string
 */
public MyStringRequestTarget(String string) {
super(string);
}

/**
 * @param contentType
 * @param encoding
 * @param string
 */
public MyStringRequestTarget(String contentType, String encoding,
String string) {
super(contentType, encoding, string);
}

@Override
public void respond(RequestCycle requestCycle) {
WebResponse response = ((WebResponse)requestCycle.getResponse());
response.getHttpServletResponse().setHeader("Cache-Control", "no-cache");
super.respond(requestCycle);
}
}

Best,

Ernesto

On Fri, Dec 18, 2009 at 4:39 AM, Jazon <[email protected]> wrote:

> In my web app, I need to return some String. So I am using
> StringRequestTarget, instead of WebPage.
> The string is dynamic, so, I would like to disable browser cache.
> I know WebPage can override setHeaders to set no-cache.
> Is there a way to do the same thing when using  StringRequestTarget?
>
> the following is my code snippet.
> Thanks for any help.
>
> mount(new URIRequestTargetUrlCodingStrategy("/ExportList") {
>
>                        @Override
>                        public IRequestTarget decode(RequestParameters
> requestParameters) {
>
>                                final ValueMap requestParams =
> decodeParameters(requestParameters);
>
>                                int listId = requestParams.getInt("id");
>                                String listString =
> myService.getList(listId);
>
>                                return new StringRequestTarget(listString);
>                        }
>                });
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to