ok, i solved my issue earlier by changing my IResourceListener in
favor of a plain old BookmarkablePage and this works fine now. as i
still think the behaviour i was experiencing is weird, i filed an
issue: https://issues.apache.org/jira/browse/WICKET-2204
additionally, the fact that urlFor ( ResourceStreamRequestTarget )
returns null still remains as a doubt.
so, roughly:
public class SWFPage extends WebPage {
private final String url;
public SWFPage(PageParameters params) {
getRequestCycle().setRequestTarget(new
ResourceStreamRequestTarget(new AbstractResourceStreamWriter() {
public void write(OutputStream output) {
try {
getResponse().getOutputStream().write( __ your byte
array __ );
} catch (IOException e) {
throw new RuntimeException("Exception reading from
bytes", e);
}
}
public String getContentType() {
return "application/x-shockwave-flash";
}
}));
}
used along with a Behavior that implements IHeaderContributor and
renders the needed javascript snippet to the html head works great.
francisco
2009/4/1 francisco treacy <[email protected]>:
> i updated to 1.4-rc2, but that didn't help.
>
> right now, with exactly the same codebase, the url is being correctly
> generated in my development environment - but outputting the bad url
> in our continuous integration server version.
>
> i set up several breakpoints in the WebRequestCodingStrategy class to
> analyze step by step how urls are being built. but i have no idea when
> it is going to start working differently again, and be able to
> compare. i'm really puzzled.
>
> hints anyone, on what could be causing this? so i can go debug there
>
> thanks
>
> francisco
>
>
>
> 2009/4/1 francisco treacy <[email protected]>:
>> thanks maarten, but i still can't get the url for the resource in the
>> renderHead method.
>>
>> in the open flash chart example, there are two types of urls built:
>> - resourcereferences (easy peasy to get the url)
>> - resource, via RequestCycle.get().urlFor(OpenFlashChart.this,
>> IResourceListener.INTERFACE);
>>
>> remember, my component is:
>> public abstract class SWFComponent extends WebMarkupContainer
>> implements IResourceListener, IHeaderContributor
>>
>> in my case i need the url to a *resource*, so i tried:
>>
>> a) RequestCycle.get().urlFor(SWFComponent.this,
>> IResourceListener.INTERFACE); or urlFor(IResourceListener.INTERFACE);
>> in the onBeforeRender method
>> => it outputs the url to a *bookmarkable page* / not my resource:
>> ?wicket:bookmarkablePage=:app.wicket.project.DocumentPage&wicket:interface=:2:docsPanel:viewer:flash::IResourceListener::
>>
>> b) RequestCycle.get().urlFor(SWFComponent.this,
>> IResourceListener.INTERFACE); in the renderHead method
>> => it outputs the url to another different *bookmarkable page* /
>> not my resource:
>> ?wicket:bookmarkablePage=:app.wicket.document.DocumentDetailPage&wicket:interface=:10:detailPanel:viewer:flash::IResourceListener::
>>
>> c) urlFor(IResourceListener.INTERFACE); in the renderHead method
>> => *sometimes* it works.
>>
>> this means *sometimes* it outputs
>> "?wicket:interface=:3:docsPanel:viewer:flash::IResourceListener:: "
>> (this is correct - it works) , but some other times it outputs "
>> ?wicket:bookmarkablePage=:app.wicket.document.DocumentDetailPage&wicket:interface=:10:detailPanel:viewer:flash::IResourceListener::
>> " (this is not correct - it doesn't work).
>>
>> this mysterious behaviour hasn't occured just once, it randomly
>> happened after compilation several times.
>>
>> is this a bug or why does it behave like that? am i misusing the api?
>> should the resource, markup container and/or header contributor live
>> in different classes? suggestions?
>>
>> thanks again
>>
>> francisco
>>
>>
>> 2009/3/31 Maarten Bosteels <[email protected]>:
>>> Have you seen this page [1], it also features an SWFObject.
>>>
>>> http://cwiki.apache.org/WICKET/open-flash-chart-and-wicket.html
>>>
>>> regards,
>>> Maarten
>>>
>>> On Tue, Mar 31, 2009 at 3:36 PM, francisco treacy
>>> <[email protected]> wrote:
>>>> hi all,
>>>>
>>>> i can't seem to find the way to get an url for a given RequestTarget.
>>>> i'm using wicket 1.4-rc1.
>>>>
>>>> basically i have an SWFComponent : http://paste.pocoo.org/show/110435/
>>>>
>>>> my problem is in line 35, when i call urlFor(target) to the renderHead
>>>> method. the target is of type ResourceStreamRequestTarget and when i
>>>> dig into the sources for the urlFor call, i end up in
>>>> WebRequestCodingStrategy#encode:
>>>>
>>>> // fall through for non-default request targets
>>>> url = doEncode(requestCycle, requestTarget);
>>>>
>>>> doEncode javadoc reads:
>>>>
>>>> * In case you are using custom targets that are not part of the
>>>> default target hierarchy, you
>>>> * need to override this method, which will be called after the
>>>> defaults have been tried. When
>>>> * this doesn't provide a url either (returns null), an exception
>>>> will be thrown by the encode
>>>> * method saying that encoding could not be done.
>>>>
>>>> where am i supposed to override this method?
>>>>
>>>> additionally, wicket doesn't seem to throw an exception as stated - it
>>>> silently returns the null value.
>>>>
>>>> any ideas on how to get the url, or improvements to the code i pasted
>>>> to make it work?
>>>>
>>>> thank you,
>>>>
>>>> francisco
>>>>
>>>> ps: note that the ResourceStreamRequestTarget works fine. for instance
>>>> if i call getRequestCycle().setRequestTarget(target); on renderHead,
>>>> the http response streams the swf file.
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [email protected]
>>>> For additional commands, e-mail: [email protected]
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]