• 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.

[Answered] Tab Title - AppName

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

  • [Answered] Tab Title - AppName

    I need the ability to change the title on the App Tab. I programmatically launch multiple versions of an app, and need each launched app to have a unique name. (App 1, App 2, App 3...)

    Previous versions of Valence had a appName parameter that could be passed on the app launch API. What is the comparable methdology in Valence 5?

    - JP

  • #2
    Is there any way to change the tab title after the app has been launched?

    Comment


    • #3
      I think we may be able to accomplish this through the Hook.js file. What would the rules be? For example I launch app "Orders". Then I launch another tab of "Orders"...should that be "Orders-2"?

      Comment


      • #4
        Thanks Sean. My specific use is as follows:

        - A Customer Report needs to open up a separate Customer View tab.

        - Rather than the Customer View tab being simply called "Customer View", I want it to be called Customer# ABC123.

        - Multiple customer tabs can be opened from the Customer report, so each tab needs to be easily identifiable with the customer#.

        Attached is a screenshot of the existing Valence3.2 portal which uses the appName on the app launch.

        A javascript method to change the tab name is fine with me.
        You do not have permission to view this gallery.
        This gallery has 1 photos.

        Comment


        • #5
          OK, I have a solution for you. It will require the following changes on your end though.

          When you call Valence.util.app.Launch you will need to pass as follows:
          Code:
          Valence.util.App.launch({
              app    : 1001 // your app id,
              params : 'updateTitle=MyNewAppTitle'
          });
          Next, you will need to modify the "Hook.js" for your instance. This can be found under /resources/desktop. Locate the the "launchApp" listener and add the following code:

          Code:
          launchapp : function (app) {
              me.onLaunchApp(app);
          },
          Next, add the new "onLauncApp" method in the Hook.js.

          Code:
          onLaunchApp : function(app){
                  var qs          = Ext.urlDecode(app.getWin().location.search.substring(1));
                      getParam    = function(param){
                          return param ? qs[param] : qs;
                      },
                      key         = getParam('key'),
                      updateTitle = getParam('updateTitle');
          
                  if (!Ext.isEmpty(key) && !Ext.isEmpty(updateTitle)){
                      app.title = updateTitle;
                      var runningAppRec = Valence.util.App.getRunningApp(key);
                      if (runningAppRec){
                          runningAppRec.set('name',Valence.util.Helper.encodeUTF16(updateTitle)); 
                          runningAppRec.commit();
                      }
                      if (!Ext.isEmpty(app.tab)){
                          app.tab.setText(updateTitle);
                      } else {
                          app.fireEvent('activate',app);
                      }
                  }
              }
          That should do it....

          Comment


          • #6
            Not sure of the correct spot to put onLaunchApp in the hook.js.... Does onLaunchApp go into the same constructor section right after the launchapp listener?

            I can't get app.getWin().location.search.substr(1) to return the URL parameters.

            Comment


            • #7
              The onLaunchApp method would go immediately after the constructor.

              Comment


              • #8
                I have an issue with the statement: app.getWin().location.search.substring(1)

                I am get some type of error that I can't debug so the hook never processes the statement.

                I'm still running the Ext3.4 valence-debug in my apps. Perhaps the app.getWin() isn't defined in 3.4?

                Is there another method that I can use to access the URL params? window.location.hostname only give me the portal URL.and not the parameters.

                Thanks for your help.

                Comment


                • #9
                  So you are running Valence 5 but using the valence-debug from version 3 of Valence?

                  Comment


                  • #10
                    Yes, that's correct.

                    Comment


                    • #11
                      Can you change your app to point to the valence-debug from version 5?

                      Comment


                      • #12
                        The valence-debug.js has been updated to the latest version 5. The tab rename works great.

                        Thanks a lot for all your help! :-)

                        - JP

                        Comment


                        • #13
                          Sean, would this technique work to change Title based on a grid toolbar filter field versus the first Launch of app? Guys on shopfloor can run up to 4 machines, so they would have 4 tabs open, each filtered by one of work center numbers. Instead of just saying "WC Schedule" on all 4 tabs, it would be great to have say "WC Schedule - nnn". But when app initially launched, I won't know that number until they apply filter.

                          Comment


                          • #14
                            Terry,

                            As of the latest release of 5.2 "5.2.20190307.0" you can pass title when launching the application and that will override the title of the application within the portal.

                            Example launch Nitro File Editor with a different title:
                            Code:
                            Valence.util.App.launch({
                                app      : 88,
                                title    : 'Nitro File Editor 1',
                                forceNew : true
                            });
                            Of course, your application will have to be using the latest valence.js from the resources folder.

                            File Editor Title Overridden.png

                            Comment


                            • #15
                              Thanks Johnny. But I'm not sure if my use case will let this work. It will launch when user clicks in the Portal, getting default name. What I wanted to do is put listener on a grid toolbar filter field, then alter the name at that time.

                              I saw Sean had some code in hook that seemed to check for "running app", that's why I wondered if I might be able to use this technique. But if it only works during the initial launch, that won't help me.

                              This isn't a showstopper for me, just wondered if possible, like using setTitle method on a Window.

                              Comment

                              Working...
                              X