Results 1 to 5 of 5

Thread: How to use URL parameters in ExtJS view?

  1. #1

    Default How to use URL parameters in ExtJS view?

    Hello,

    I have an index.jsp which besides other things contains a script tag calling a js file contructing an ExtJS panel.
    Now, if I want to do something in the view depending on parameters in the URL, how would I be able to access them in the js file (e.g. set a combo box value to the id in an url parameter myId)?

    Regards,
    Alex

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    You can't access the parameters in the the .js url. You can only access the ones in the .jsp url.

    (if you changed your .js to a .jsp then you would be able to do this on the server)

  3. #3

    Default

    I'm not completely sure, what you meant by ".js url" and ".jsp url" - let me rephrase the question a bit:

    I have a jsp file which should be accessable by a parameter, e.g. http://mypath/my.jsp?myId=10

    Now I need to set this myId as a value of a combo box in my ExtJS panel - what can I do to achieve that?

    Would I need to put the javascript code of the given panel directly in the jsp and use some ugly jsp substitution at the point where the combo value is set or is there a way of using just a script tag in the jsp to a separate my.js file and use some sort of shared object which is set in the jsp and read in the js file?

  4. #4
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    You need a small bit of javascript in your .jsp, e.g.
    Code:
    <script type="text/javascript">
    myId = <%= request.getParameter('myId') %>;
    </script>
    <script type="text/javascript" src="myscript.js"></script>
    (now myscript.js can use the global 'myId' variable)

  5. #5
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Or, depending on how you call your .jsp, you could use:
    Code:
    var params = Ext.urlDecode(location.search.substr(1));
    var myId = params.myId;
    Disclaimer: Completely untested code!

Similar Threads

  1. autoLoad url and html parameters to use id.
    By mangamine in forum Ext 3.x: Help & Discussion
    Replies: 5
    Last Post: 11 Apr 2010, 12:32 AM
  2. url parameters
    By alex1001 in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 9 Mar 2010, 7:12 AM
  3. URL parameters in Json store
    By simon in forum Ext 3.x: Help & Discussion
    Replies: 5
    Last Post: 22 Jun 2009, 3:11 AM
  4. Regarding Url Parameters
    By shajeerkt in forum Ext GWT: Help & Discussion (1.x)
    Replies: 0
    Last Post: 16 Jun 2009, 10:03 PM
  5. Reading the URL Querystring Parameters...
    By crpatrick in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 19 Dec 2007, 6:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •