• ReUse of control on a page

    By Ulrich Krause 1 decade ago

    I have 4 items on an XPage that keep application path information. each item has a button beside it to open the Dialog and select an application from the dialog.

    I cannot figure out, how to have only one control at the top of my page and let each button open the dialog and return the path information to the corresponding 'returnFieldFilePath'

    Any sample on how to achieve this?

    • Answer: ReUse of control on a page

      By Lars Buntrock 1 decade ago

      Hallo Ulrich!

      Bin gerade in Spanien im Urlaub, daher kann ich leider nicht konkret antworten.

      Da ja die drei Felder fuer die Rueckgabewerte auch Computed sein koennen, muesste es ja moeglich sein, ueber eine Scope-Variable zu pruefen, welche Button du genutzt hast, um den Dialog zu offnen und entsprechend festzulegen, welche Rueckgabefelder du brauchst.

      Wie gesagt, aktuell waere die Antwort jetzt theoretisch. Nach meinem Urlaub koennte ich das mal verifizieren.

      Evtl. hilft dir aber ja schon der Ansatz.

      Sorry, wenn ich die aktuell nicht mehr sagen kann.

      Lars

      • Tried with scoped variable

        By Ulrich Krause 1 decade ago

        but could not get it to work. it is sure possible to do so, but for the moment a bit too time consuming to find out how. So I use a workaround:



        I now write the value to a temp element and then paste it into the correct field with



        getComponent("HRDBPath").setValue(getComponent("temp").getValue());

    • My solution

      By Vitor Pereira 1 decade ago

      Ulrich, I have exactly the same scenario.

      What I did was change the control to compute the return field names  from scope vars and then have each of the buttons set the same scope vars with the appropriate values.

      • Correction

        By Vitor Pereira 1 decade ago

        Sorry,I didn't actually change the control. After adding it to an XPage, in the custom properties I just compute the return fields from the scope vars.

        • Jumped to conclusion. It's not working.

          By Vitor Pereira 1 decade ago

          Sorry guys. My briefs tests lead me to wrong conclusions. I can't get it to work with scoped vars or by manipulating the custom properties.

          I introduced some debug code in the SSJS library and all seems fine except the fields will not update. I'll do some more work on this as soon as I have some free time.

      • Your solution

        By Lars Buntrock 1 decade ago

        Thank you for your solution description. Is it possible that you send me your changes? I would check your changes and possibly integrate them into the control. Or take a description of the solution in the download.

    • Finally made it work

      By Vitor Pereira 1 decade ago

      The changes I made were:

      In the button that displays the dialog box put this in the client side of the onclick event:

      returnFieldServerID = "#{id:dbServer2}";
      returnFieldFilePathID = "#{id:dbFilePath2}";
      returnFieldTitleID = "#{id:dbTitle2}";

      And this on the server side:

      sessionScope.put('returnFieldTitle', 'dbTitle2');
      sessionScope.put('returnFieldFilePath', 'dbFilePath2');
      sessionScope.put('returnFieldServer', 'dbServer2');

      In the xcDBOpenDlgJSS server side script library I changed the following, commented is the original line:

      //refresh target field: server
      function refreshTargetFieldServer() {    
      //    var serverName = compositeData.returnFieldServer;
          var serverName = sessionScope.returnFieldServer;
      //    var dbFilePath = compositeData.returnFieldFilePath;    
          var dbFilePath = sessionScope.returnFieldFilePath;

      ....

      //refresh target field: file path
      function refreshTargetFieldFilePath() {
      //    var serverName = compositeData.returnFieldServer;
          var serverName = sessionScope.returnFieldServer;
      //    var dbFilePath = compositeData.returnFieldFilePath;    
          var dbFilePath = sessionScope.returnFieldFilePath;

       

      ....

      //refresh target field: database title
      function refreshTargetFieldDbTitle() {
          
      //    var dbTitle = compositeData.returnFieldTitle;
          var dbTitle = sessionScope.returnFieldTitle;

      • THANX!!!

        By Lars Buntrock 1 decade ago

        Hi Vitor!

        Thank you very much for your explanations. I will check it and put it into the control! Hope I got it this week!

        Lars