You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jim <op...@gmail.com> on 2008/04/09 18:04:53 UTC

[T4.1] Custom Dojo & relative URIs

Hello,

I'm using Dojo 1.0.2 with Tapestry 4.1.5, using the Tacos approach as a 
guide.  I have a question about the "files" property in the following:

<implementation service-id="tapestry.js.JavascriptManager">
    <invoke-factory>
      <construct 
class="org.apache.tapestry.javascript.JavascriptManagerImpl">
        <set-service property="assetSource" 
service-id="tapestry.asset.AssetSource"/>
        <set property="files" 
value="http://[host]:[port]/[AppName]/[path-to-dojo.js]" />
        <set property="formFiles" value="" />
        <set property="widgetFiles" value="" />
        <set property="folder" value="" />
        <set property="tapestryFile" 
value="classpath:/tacos-js/tap-dojo1.0.2.js" />
        <set property="tapestryFolder" value="classpath:/tacos-js/" />
      </construct>
    </invoke-factory>
  </implementation>

That "files" property -- everything works fine if I put an absolute URL 
in there, and this configuration annoyance is eased somewhat if I use 
system property-replacement instead of a hard-coded URL.  However, I 
have users accessing this application through SSH tunnels, so this 
absolute-URL approach breaks down.  I tried using various relative paths 
but get Exceptions stemming from: "Unable to update property files of 
object org.apache.tapestry.javascript.JavascriptManagerImpl@a16605" when 
I use anything but an absolute path.

Anyone know how to get around this, or a better way?

Thanks,
Jim



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


Re: [T4.1] Custom Dojo & relative URIs

Posted by Jim <op...@gmail.com>.
Attempting my own question, looks like JavascriptManagerImpl is using 
URLResource like so:

097        public void setFiles(String files)
098        {
099            _files = buildAssetList(files, "files");
100        }

132        private List buildAssetList(String files, String name)
133        {
134            String[] js = TapestryUtils.split(files);
135            
136            List list = new ArrayList(js.length);
137            for (int i=0; i<js.length; i++) {
138                list.add(findAsset(js[i], name + i));
139            }
140    
141            return list;
142        }

144        private IAsset findAsset(String path, String description)
145        {
146            IAsset asset = null;
147            if ( !HiveMind.isBlank(path) )
148            {
149                Location location = new DescribedLocation(new URLResource(path), description);
150                asset = _assetSource.findAsset(null, path, null, location);
151            }
152            return asset;
153        }

I'm going to subclass JavascriptManagerImpl, add an injected 
ServletContext property, and override setFiles(..) to ultimately use 
ContextResource instead.

Jim


Jim wrote:
> Hello,
>
> I'm using Dojo 1.0.2 with Tapestry 4.1.5, using the Tacos approach as 
> a guide.  I have a question about the "files" property in the following:
>
> <implementation service-id="tapestry.js.JavascriptManager">
>    <invoke-factory>
>      <construct 
> class="org.apache.tapestry.javascript.JavascriptManagerImpl">
>        <set-service property="assetSource" 
> service-id="tapestry.asset.AssetSource"/>
>        <set property="files" 
> value="http://[host]:[port]/[AppName]/[path-to-dojo.js]" />
>        <set property="formFiles" value="" />
>        <set property="widgetFiles" value="" />
>        <set property="folder" value="" />
>        <set property="tapestryFile" 
> value="classpath:/tacos-js/tap-dojo1.0.2.js" />
>        <set property="tapestryFolder" value="classpath:/tacos-js/" />
>      </construct>
>    </invoke-factory>
>  </implementation>
>
> That "files" property -- everything works fine if I put an absolute 
> URL in there, and this configuration annoyance is eased somewhat if I 
> use system property-replacement instead of a hard-coded URL.  However, 
> I have users accessing this application through SSH tunnels, so this 
> absolute-URL approach breaks down.  I tried using various relative 
> paths but get Exceptions stemming from: "Unable to update property 
> files of object 
> org.apache.tapestry.javascript.JavascriptManagerImpl@a16605" when I 
> use anything but an absolute path.
>
> Anyone know how to get around this, or a better way?
>
> Thanks,
> Jim
>
>
>


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


Re: [T4.1] Custom Dojo & relative URIs

Posted by Jim <op...@gmail.com>.
Oh sweet, didn't know about the "context:" prefix; I assumed URLResource
only took absolute URLs.  This works perfect, thanks Andreas!

Andreas Andreou wrote:
> The files property (as well as the others) expects a comma separated
> list of assets.
>
> If you're hosting the dojo files yourself, you can use something like:
> <set property="files" value="context:/dojo102/dojo.js" />
> which will build relative urls.
>
> Also, there's nothing stopping you from using multiple JavascriptManagers
> in your app - just define as many as you want and (conditioinally)
> attach whichever you want
> to your @Shell
>
>
> On Wed, Apr 9, 2008 at 7:04 PM, Jim <op...@gmail.com> wrote:
>   
>> Hello,
>>
>>  I'm using Dojo 1.0.2 with Tapestry 4.1.5, using the Tacos approach as a
>> guide.  I have a question about the "files" property in the following:
>>
>>  <implementation service-id="tapestry.js.JavascriptManager">
>>    <invoke-factory>
>>      <construct
>> class="org.apache.tapestry.javascript.JavascriptManagerImpl">
>>        <set-service property="assetSource"
>> service-id="tapestry.asset.AssetSource"/>
>>        <set property="files"
>> value="http://[host]:[port]/[AppName]/[path-to-dojo.js]" />
>>        <set property="formFiles" value="" />
>>        <set property="widgetFiles" value="" />
>>        <set property="folder" value="" />
>>        <set property="tapestryFile"
>> value="classpath:/tacos-js/tap-dojo1.0.2.js" />
>>        <set property="tapestryFolder" value="classpath:/tacos-js/" />
>>      </construct>
>>    </invoke-factory>
>>   </implementation>
>>
>>  That "files" property -- everything works fine if I put an absolute URL in
>> there, and this configuration annoyance is eased somewhat if I use system
>> property-replacement instead of a hard-coded URL.  However, I have users
>> accessing this application through SSH tunnels, so this absolute-URL
>> approach breaks down.  I tried using various relative paths but get
>> Exceptions stemming from: "Unable to update property files of object
>> org.apache.tapestry.javascript.JavascriptManagerImpl@a16605" when I use
>> anything but an absolute path.
>>
>>  Anyone know how to get around this, or a better way?
>>
>>  Thanks,
>>  Jim
>>
>>
>>
>>  ---------------------------------------------------------------------
>>  To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>  For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>     
>
>
>
>   



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


Re: [T4.1] Custom Dojo & relative URIs

Posted by Andreas Andreou <an...@gmail.com>.
The files property (as well as the others) expects a comma separated
list of assets.

If you're hosting the dojo files yourself, you can use something like:
<set property="files" value="context:/dojo102/dojo.js" />
which will build relative urls.

Also, there's nothing stopping you from using multiple JavascriptManagers
in your app - just define as many as you want and (conditioinally)
attach whichever you want
to your @Shell


On Wed, Apr 9, 2008 at 7:04 PM, Jim <op...@gmail.com> wrote:
> Hello,
>
>  I'm using Dojo 1.0.2 with Tapestry 4.1.5, using the Tacos approach as a
> guide.  I have a question about the "files" property in the following:
>
>  <implementation service-id="tapestry.js.JavascriptManager">
>    <invoke-factory>
>      <construct
> class="org.apache.tapestry.javascript.JavascriptManagerImpl">
>        <set-service property="assetSource"
> service-id="tapestry.asset.AssetSource"/>
>        <set property="files"
> value="http://[host]:[port]/[AppName]/[path-to-dojo.js]" />
>        <set property="formFiles" value="" />
>        <set property="widgetFiles" value="" />
>        <set property="folder" value="" />
>        <set property="tapestryFile"
> value="classpath:/tacos-js/tap-dojo1.0.2.js" />
>        <set property="tapestryFolder" value="classpath:/tacos-js/" />
>      </construct>
>    </invoke-factory>
>   </implementation>
>
>  That "files" property -- everything works fine if I put an absolute URL in
> there, and this configuration annoyance is eased somewhat if I use system
> property-replacement instead of a hard-coded URL.  However, I have users
> accessing this application through SSH tunnels, so this absolute-URL
> approach breaks down.  I tried using various relative paths but get
> Exceptions stemming from: "Unable to update property files of object
> org.apache.tapestry.javascript.JavascriptManagerImpl@a16605" when I use
> anything but an absolute path.
>
>  Anyone know how to get around this, or a better way?
>
>  Thanks,
>  Jim
>
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>  For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

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