• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

[HELPED] Can a MVC app receive an initial URL string with parms?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [HELPED] Can a MVC app receive an initial URL string with parms?

    In the ole days before Valence, a common iSeries HTTP cgi request may have looked something like:
    "http://myhost.myserver.com:8080/pgms/myprogram.pgm?request=veninq&sys=1&ven=1234&usr=us er&opt=Y"
    Once the program from the URL executed, then another html page might be displayed with hidden URLs and/or forms that make additional posts, and so on.

    Now, of course, in an MVC app, all of the necessary code is contained in one "application". This app is loaded "all at once" and then processing begins.

    I have a need wherein I need to break up this app so that it can be called via URL's that contain the parms needed to process different parts of the application. Or, if not breaking up the app, create hooks and/or entry points to the app based on the URL string.

    After hours of googling and researching, I have yet to see a hint of how this could be done. Can this be done? If so, some hints on how to get started would be greatly appreciated.

  • #2
    After certain components render or stores load, you may want to reference url Params and then take certain actions.

    Can you be more specific about what or when you want to do?

    Comment


    • #3
      Also if based on the params sent you need to pass different param values for stores etc you could make sure all stores are autoLoad false. Then in your app's launch use Ext.getUrlParam() to determine what next actions need to be made.

      Quick Example

      Passing different param values based on passed params and loading a different view based off the params passed in.

      Code:
      launch: function() {
              var baseLocation = Ext.getUrlParam().baseLocation,
                  store = Ext.getStore('Abc'),
                  extraParams = store.getProxy().extraParams;
      
              if (baseLocation){
                  Ext.apply(extraParams, {
                      loc : baseLocation
                  });
                  Ext.create('MyApp.view.Main2');
              } else {
                  Ext.apply(extraParams, {
                      loc : 'defaultlocation'
                  });
                  Ext.create('MyApp.view.Main');
              }

      Comment


      • #4
        @eweiler: think of an app outside the valence portal. instead of the URL being "index.html" that has the app.js defined and therefore "launches", I want to be able for the web server to receive a URL (like the one described in the initial post) and then (I guess) be able to read those parms and then pass them to the javascript app so that the app launches with the received parms and then does what it needs to based on the parms received... But, I have no clue how to "receive" these parms and pass them along to the app. Maybe it can't be an "app" and needs to be an Ext.onReady() .js.. IDK.

        Comment


        • #5
          Thanks Big John! this gets me started and makes some sense. I play around and see what I can figure out. I'm still a little sketchy on what the initial URL string might look like in order to get to .js with the launch in it...

          Comment


          • #6
            Mike,

            If your launching the application from another app in Valence you could use the Valence.app.launch method passing it an object.

            Code:
                    /**
            	* Programmatically launches an app in the portal, or if already open, switches to the app.
            	* @ param {Object} o Object containing the following config:
            	*
            	* - `app`  The app ID
            	* - `params`  The parameters to be passed in url format to the called app.
                    */
            You could also create 2 different Valence Apps and each one having different Optional Parameters.

            Comment


            • #7
              these apps will be outside the portal.. i don't see the Ext.getUrlParam in the API docs... maybe it's a basic javascript function.. still looking around..

              Comment


              • #8
                Ext.getUrlParam is added by Valence;

                Code:
                        Ext.getUrlParam = function(param) {
                		var params = Ext.urlDecode(location.search.substring(1));
                		return param ? params[param] : params;
                	};

                Comment

                Working...
                X