Hi!

Well.. you have the url.. you can reference it from javascript by
expressing it in for exampel a javascript variable... would that work
for you?

        protected void onRender(MarkupStream markupStream) {
          super.onRender(markupStream);
          JavascriptUtils.writeOpenTag(getResponse());
            getResponse().write("var xmlurl='" + xmlurl + "';" );
          JavascriptUtils.writeCloseTag(getResponse());
        }

**
Martin

2010/3/21 JonnyL <[email protected]>:
>
> Hi,
>
> I still don't get it. I have added the code you suggested and that returns
> the url to the resource, but how do I reference the resource in the page.
> Apologies if this is a dumb question, but I am stumped on this.
>
> Thanks
>
>
>
>
>
> MartinM wrote:
>>
>> Hi!
>>
>> Here is how it works with css, look in Palette.java:
>>
>> new ResourceReference(Palette.class, "palette.css")
>>
>>       /**
>>        * Renders header contributions
>>        *
>>        * @param response
>>        */
>>       public void renderHead(IHeaderResponse response)
>>       {
>>               ResourceReference css = getCSS();
>>               if (css != null)
>>               {
>>                       response.renderCSSReference(css);
>>               }
>>       }
>>
>>
>> Furthermore in HeaderResponse the code is like:
>>
>> /**
>>        * @see
>> org.apache.wicket.markup.html.IHeaderResponse#renderCSSReference(org.apache.wicket.ResourceReference)
>>        */
>>       public void renderCSSReference(ResourceReference reference)
>>       {
>>               if (reference == null)
>>               {
>>                       throw new IllegalArgumentException("reference cannot 
>> be null");
>>               }
>>               if (!closed)
>>               {
>>                       CharSequence url = 
>> RequestCycle.get().urlFor(reference);
>>                       renderCSSReference(url.toString(), null);
>>               }
>>       }
>>
>>
>>
>> So I would assume that you can get the url by calling:
>>
>> String xmlUrl = RequestCycle.get().urlFor(new
>> ResourceReference(MyClassInSamePackage.class,
>> "myown.xml")).toString();
>>
>> I haven't tried that but something like that should work.
>>
>>
>> **
>> Martin
>>
>>
>> 2010/3/21 JonnyL <[email protected]>:
>>>
>>> Hi,
>>>
>>> Can you expand on option a). I am adding my JS and CSS as resources by
>>> creating ResourceReference() for them and using renderCSSreference() and
>>> renderJavascriptReference() to add them to the pages header, but how I do
>>> not know how to add a resource reference to the XML file.
>>>
>>> Thanks
>>>
>>>
>>>
>>> MartinM wrote:
>>>>
>>>> Hi!
>>>>
>>>> I can suggest two things:
>>>> a) reference it as resource in wicket, similar way you do with
>>>> javascript or css, find out its url
>>>> b) put the xml file in your src/webapp directory, static files can be
>>>> accessed directly from there.
>>>>
>>>> **
>>>> Martin
>>>>
>>>> 2010/3/21 JonnyL <[email protected]>:
>>>>>
>>>>> Hi Martin,
>>>>>
>>>>> Yes, the XML file is a remote file on the server. I have written a
>>>>> javascript function that returns a node value from the XML file, the
>>>>> javascript function is in a JS file which is referenced in the page
>>>>> header.
>>>>> The javascript cannot access the XML file because I believe it is not
>>>>> referenced as a resource by Wicket.
>>>>>
>>>>> Any suggestions on how I should reference the XML file?
>>>>>
>>>>> Thanks for the speedy response.
>>>>>
>>>>>
>>>>> THe javascript  and
>>>>>
>>>>> MartinM wrote:
>>>>>>
>>>>>> Hi!
>>>>>>
>>>>>> You mean remote xml file.. on the server.
>>>>>>
>>>>>> **
>>>>>> Martin
>>>>>>
>>>>>> 2010/3/21 Jon <[email protected]>:
>>>>>>> My Wicket app has a page that calls a Javascript function that
>>>>>>> accesses
>>>>>>> an XML file. I have added the Javascript resource and it runs, but it
>>>>>>> cannot access the XML file. How do I set the XML file as a resource
>>>>>>> so
>>>>>>> it can be accessed by Javascript?
>>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: [email protected]
>>>>>> For additional commands, e-mail: [email protected]
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://old.nabble.com/Access-file-from-Javascript-tp27975931p27976065.html
>>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> 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]
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Access-file-from-Javascript-tp27975931p27976913.html
>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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]
>>
>>
>>
>
> --
> View this message in context: 
> http://old.nabble.com/Access-file-from-Javascript-tp27975931p27976988.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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]

Reply via email to