1. #1
    Ext JS Premium Member smokeman's Avatar
    Join Date
    Jul 2007
    Posts
    475
    Vote Rating
    2
    smokeman is on a distinguished road

      0  

    Default url prefix not working

    url prefix not working


    I have a url prefix of http://localserver:8080/Projectname/
    that is defined in the project settings.
    that points to my java project, which resides in eclips/tomcat on my local development station.

    I then have my ajax requests that I point to a java servlet. The servlets work at http://localserver:8080/projectname/servletname

    when I use a url definition of 'ServletName', I get a server error of http://localserver:8080/projectname/...pp/ServletName path not found

    when I use a url definition of '/ServletName', It bypases the projectname, and goes straight to the root of the tomcat server, and not /project/servletname.

    I thought url prefix was supposed to prepend that string to the begginning of all server calls...?
    why is this not working?

  2. #2
    Sencha User
    Join Date
    Jun 2012
    Posts
    22
    Vote Rating
    7
    sonnypickett is on a distinguished road

      0  

    Default


    The prefix isn't prepended to url in the published code. So without the slash it's naturally going to look for the resource in relation to the current document location (app.html). If your data provider is in a different spot you have to hard code the complete url in the proxy's url field.

    Interesting though, fetching data into a store from within Architect probably works since it does use the URL prefix to make the call.

  3. #3
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,308
    Vote Rating
    125
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    To confirm, urlPrefix is a development time setting inside of Architect.

    It tells Architect how to resolve your relative urls before the project has been placed on a webserver. Because Architect is an application and not a typical browser it doesn't have to abide by the standard restrictions of XHR re: cross domain.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  4. #4
    Ext JS Premium Member smokeman's Avatar
    Join Date
    Jul 2007
    Posts
    475
    Vote Rating
    2
    smokeman is on a distinguished road

      0  

    Default


    so, my only option is to prepend /projectname to each url, so that the url definition looks like this:
    url:'/projectname/servlet',
    then when publishing, go back, and do a find/replace on the resulting .js files?

  5. #5
    Sencha User
    Join Date
    Jun 2012
    Posts
    22
    Vote Rating
    7
    sonnypickett is on a distinguished road

      0  

    Default


    what I have done when getting data from an external app server is put the full URL to the service in the url....i.e. http://localhost:9000/engine/datastore

  6. #6
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,308
    Vote Rating
    125
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    The intent is that you use relative or absolute urls in your project.

    When the code is deployed to the server of your choice then where ever it resides is kind of like the urlPrefix.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  7. #7
    Ext JS Premium Member smokeman's Avatar
    Join Date
    Jul 2007
    Posts
    475
    Vote Rating
    2
    smokeman is on a distinguished road

      0  

    Default


    so, if I click the deploy every time I save, option, would the entire prefix url get prepended to the url config on each ajax call?

    I would just have to pick a different location to deploy to, correct?

  8. #8
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,308
    Vote Rating
    125
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    Quote Originally Posted by smokeman View Post
    so, if I click the deploy every time I save, option, would the entire prefix url get prepended to the url config on each ajax call?
    No... your relative urls will continue to work as relative urls.

    Quote Originally Posted by smokeman View Post
    I would just have to pick a different location to deploy to, correct?
    Maybe you should explain in further detail what your problem is because I don't understand it. Standard Ajax requests are almost always relative/absolute urls without the http(s)://domain.com portion of the url. This makes your code portable in that it can be deployed to various different places.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  9. #9
    Ext JS Premium Member smokeman's Avatar
    Join Date
    Jul 2007
    Posts
    475
    Vote Rating
    2
    smokeman is on a distinguished road

      0  

    Default


    project settings
    projectsettings.jpg
    that is what I want prepended to url's

    If I put an ajax url definition like this:
    Code:
    Ext.Ajax.request({
        url:'/AjaxUserTR1Interface',
        method: 'POST',
        params:{fn:'getsessionvar',key:'Authenticated'},
        callback:function(opts,suss,resp){
    I get this:
    path1.jpg
    as expected, since using a forward slash in front of a url should go to the root of the site.

    when I use this definition:
    Code:
    Ext.Ajax.request({
        url:'AjaxUserTR1Interface',
        method: 'POST',
        params:{fn:'getsessionvar',key:'Authenticated'},
        callback:function(opts,suss,resp){
    I get this:
    path2.jpg

    that is the path that I think should be correct, but it is referencing from within the project...

    I need this to work, no matter if the project is published to /Atlas/ajax/AtlasNav,
    or to the root of the webserver http://server.com/ajax/AtlasNav

  10. #10
    Ext JS Premium Member smokeman's Avatar
    Join Date
    Jul 2007
    Posts
    475
    Vote Rating
    2
    smokeman is on a distinguished road

      1  

    Default


    I'm going to use ../../ to fix this, however I would think this would be handled in architect, to prepend the prefix url to all requests...

    not sure I understand what you were talking about earlier...

    I am not deploying though, I am running the project out of the project's saved folder.

Thread Participants: 2