HR

Hello dear Community,

in my report I have a combo box where I can select a zoom factor for the graphics. It works well in this direction.

Now I would like to set the combo box to one of the options depending on another input. And that doesn't work.

According to the help in ARIS, the following function should do exactly what I want:

Report class Dialog
void setDlgSelection (String sDlgItem, int nSelectedIndex) - Sets selection for lists, combo boxes and tables.

Alternatively I found the following function:

Report class SingleSelectElement
boolean setSelection (int nSelectedIndex) - sets the selected index (single selection)

 

Unfortunately, however, both functions do not deliver the desired result. Either the report runs without errors, but without the desired result, or I get an error message.

The command lines between the two "///" are the variants I tried and the comment behind them is the result. However, only one variant was activated at a time. The others were commented out.

The error messages are listed under the source code.

 

Can anyone tell me why this doesn't work for me and what mistake I made? How can I set the combo box correctly? I can't imagine that shouldn't work with combo boxes. This works for all other input objects.

 

Many thanks to all of you who take care of this and support me.

---

And here the addressed source code:

var aGrSize = new Array();  // Table of zoom factors

function DIA_configSubDialog()
{
    ...
    aGrSize = ["automatisch", "individuell", "100%", " 70%", " 30%"];
    this.getPages = function()
    {
        ...
        oOptions.CheckBox(30, 90, 280, 15, "Change size", "GrSize");
        oOptions.ComboBox(100, 110, 110, 20*aGrSize.length, aGrSize, "GrSelW");
        ...
        return [oOptions];
    }

    this.OptCod_changed = function(sNewSel)
    {
        var aPages = new Array();

        aPages[0]  = this.dialog.getPage(0);
        ...
        aPages[0].getDialogElement("GrSize").setChecked(lPrGrSiz);
        ...
        aPages[0].getDialogElement("GrSelW").setEnabled(true); // That works

        ///

        aPages[0].getDialogElement("GrSelW").setSelection(nSelection);               // Gives no error, but no reaction at the dialog window
        this.dialog.getPage(0).getDialogElement("GrSelW").setSelection(nSelection);  // Gives also no error, but does not work
        aPages[0].setDlgSelection("GrSelW", nSelection);                             // Gives an error (1)
        this.dialog.setDlgSelection("GrSelW", nSelection);                           // Gives an error (2)
        Dialogs.setDlgSelection("GrSelW", nSelection);                               // Gives an error (3)
        oOptions.setDlgSelection("GrSelW", nSelection);                              // Gives an error (4)

        ///

        ...
    }

}

(1) Dialog function call failed:org.mozilla.javascript.EcmaError: TypeError: Cannot find function setDlgSelection in object DialogPag.

(2) Dialog function call failed:org.mozilla.javascript.EcmaError: TypeError: Cannot find function setDlgSelection in object UserDialo.

(3) Dialog function call failed:org.mozilla.javascript.EcmaError: TypeError: Cannot find function setDlgSelection in object Dialogs.

(4) Dialog function call failed:org.mozilla.javascript.EcmaError: TypeError: Cannot find function setDlgSelection in object com.aris.modeling.server.bl.logic.webreprot.dialog.AServerDialogBuilde.

 

by Robert Goldenbaum
Badge for 'Question Solver' achievement
Posted on Mon, 06/04/2018 - 10:39

Hi,

hm, I think that the Combo-Box is perhaps an older thing ?   I always use "DropListBox" for the drop down selections and this works good...

        oDialogTemplate_Global.DropListBox(230, 124, 220, 70, g_tOptions.asBaseNames, "BaseName");

 

        if (g_tOptions.sSelectedBaseName != ""){

            for(i = 0; i < g_tOptions.asBaseNames.length; i++){

                if (g_tOptions.asBaseNames[i].equals(g_tOptions.sSelectedBaseName)){

                    this.dialog.getPage(lNum_Global).getDialogElement("BaseName").setSelection(i);

                    break;

                }

            }

        }

 

BR Robert

0
by Holger Reidemeister Author
Posted on Mon, 06/04/2018 - 13:22

In reply to by rgoldenbaum

Hello Robert,

Thank you very much for your effort. Now I replaced all the ComboBoxes with DropListBoxes. And the results and the errors are the same.

OK, I didn't use the for-loop, because I know the index of the array. But that shouldn't make a difference.

Have you got another idea?

Regards

Holger

0
by Kay Fischbach
Posted on Mon, 06/04/2018 - 11:47

Hi Holger,

may I ask that you check the second variant (where you tried to implement the second method you found) one more time?

Report class SingleSelectElement

boolean setSelection (int nSelectedIndex) - sets the selected index (single selection)

worked perfectly fine for me when I tested it.

Example:

function myDialog(){

this.getPages = function()

    {

        var iDialogTemplate1 = Dialogs.createNewDialogTemplate(600, 300, "First page");

        

        iDialogTemplate1.ComboBox(15,15,400,180,["Test1","Test2","Test3"],"CB1", 0);

        iDialogTemplate1.PushButton(15, 30, 80, 30, "Test", "PB1");

        return [iDialogTemplate1];

    }

this.PB1_pressed = function(){

        this.dialog.getPage(0).getDialogElement("CB1").setSelection(2);

    }

}

Dialogs.showDialog(new myDialog(), Constants.DIALOG_TYPE_WIZARD, "Single page dialog");

Result for me: Pressing the "Test" button switches the selection of the Combobox above the "Test" button from Test1 to Test3, as intended and wished

Edit: Maybe you can help me out here too: How do I get this code syntax highlighting to work? Whenever I surround my code with the preBlaBlaBla in smaller than - greater than symbols, it just prints it as text next to my code, without interpreting it. The text format of my comment is set to Filtered HTML, not Plain text.

0
by Holger Reidemeister Author
Posted on Mon, 06/04/2018 - 14:26

In reply to by Kay Fischbach

Hello Kay,

Also thank you very much for your effort. I've checked all the 6 variants with ComboBox and with DropListBox.

My variant 2 is (like you wrote):

this.dialog.getPage(0).getDialogElement("GrSelW").setSelection(nSelection);

My Config-function looks like that:

function DIA_configDialog()
{
    var lResult;
    
    // set selection to global options
    lResult = Dialogs.showDialog(new DIA_configSubDialog(), Constants.DIALOG_TYPE_WIZARD, "Options");
    if (lResult != -1)
    {
        return false;
    }
    return true;
}

The line

Dialogs.showDialog(new DIA_configSubDialog(), Constants.DIALOG_TYPE_WIZARD, "Options");

looks also like yours.

In the function DIA_configSubDialog() all the elements of the page are defined.

Unfortunately it does not work like described. On this way there is no error but the ComboBox/DropListBox-option does not change. All the other elements (CheckBoxes, TextBoxes) are changed like I would.

_______

To your question: "How do I get this code syntax highlighting to work?"

On the top of the textbox you find a drop-down-list. Usually it shows "Normal" when you start your input. Switch that to "Formatted" and you will get the style I used for source code. Sometimes the previous line or the following line will also be switched to "Formatted". Then write the undesired formatted text over or under this line and delete it from the formatted area.

Regards

Holger

0
by Kay Fischbach
Posted on Mon, 06/04/2018 - 15:13

In reply to by hreidemeister

Just to be on the same page here: Which ARIS version are you using? We're on ARIS 10.3 and the setSelection(index) method works as intended.

Ok, different approach. Just like @Robert Goldenbaum in another comment here in this thread, I'm starting to doubt that your nSelection is correct. Because when I try to use the setSelection method with an index that is out of bounds, (for whatever reason) I do not get an exception thrown, instead the report simply continues (just like you described, without doing actually anything).

Here is what you can do to verify nSelection is ok:

Add two empty textboxes to your getPages function (should be in the same row, but at different colums)

iDialogTemplate1.Text(15, 235, 80, 25, "", "TX1");
iDialogTemplate1.Text(100, 235, 80, 25, "", "TX2");

then add this line to your this.init function

this.dialog.getPage(0).getDialogElement("TX2").setText(this.dialog.getPage(0).getDialogElement("CB1").getItems().length);

Note:

  • CB1 is the identifier of my combobox. Might want to change this to make it work for you.

and lastly in your "changed" method use

this.dialog.getPage(0).getDialogElement("TX1").setText(nSelection+1);

 Note:

  • For debugging purposes, you don't have to include a method in the "changed" method that actually does change the selection. You just want to read what the textboxes say
  • we use the +1 with nSelection because we compare the actual length of the list of available options (e.g. 1 or 2 or 3) with the zero based index number that setSelection would accept (e.g. 0 or 1 or 2).

Now run the report and trigger the event.

If the left number (TX1) exceeds the right number (TX2), you're trying to tell it to select a list element that does not exist (aka out of bounds). If that's the case, evaluate where nSelection was falsely calculated/set, and fix your report there.

 

 

0
by Holger Reidemeister Author
Posted on Tue, 06/05/2018 - 12:45

In reply to by Kay Fischbach

Hello, Kay,

sorry, I forgot to mention the ARIS version. We are working with version 9.8.

I am sure that nSelection contains the right value. Since it is only determined shortly before with a switch-case statement and only the values 0 to 4 are set here, an "out of range" cannot occur. The source code can be found in my answer to @Robert Goldenbaum .

In addition, I have already checked all relevant variables. I wrote them into a log file with a unique index for every protocol line and checked them.

Regardless of this, I have integrated your code lines into my script. But also here the correctness of nSelection was confirmed to me. (Array length of the ComboBox is 5, nSelection e.g. 1)

But this is also interesting in this context:

In the "this.init" function, setSelection works correctly:

aPages[0].getDialogElement("GrSelW").setSelection(3);

In the "this.OptCod_changed" function, setSelection does not work regardless of the nSelection variable:

aPages[0].getDialogElement("GrSelW").setSelection(3);

As I said, only the ComboBox (or DropListBox) shows this strange behavior. All other dialog elements do what they should.

Do you have any other ideas?

Best Regards

Holger

0
by Robert Goldenbaum
Badge for 'Question Solver' achievement
Posted on Mon, 06/04/2018 - 13:40

Hm, well, if I do just a small report, it works in the initialization...   where do you define  "nSelection" ?

My example:

main()

function main(){

    DIA_configDialog()

}

function DIA_configDialog(){

    

    // show the dialog itself

    var lResult = Dialogs.showDialog(new DIA_configSubDialog(), Constants.DIALOG_TYPE_ACTION , "Test");

    if (lResult != -1)

        return false;

    

    return true;

}

function DIA_configSubDialog()

{

var aGrSize = ["automatisch", "individuell", "100%", " 70%", " 30%"];

    this.getPages = function()

    {

        var oOptions = Dialogs.createNewDialogTemplate(0, 0, 0, 0, "Test");

        oOptions.CheckBox(30, 90, 280, 15, "Change size", "GrSize");

        oOptions.ComboBox(100, 110, 110, 20*aGrSize.length, aGrSize, "GrSelW");

        return [oOptions];

    }

    

    this.init = function(aPages){

        aPages[0].getDialogElement("GrSelW").setSelection(3);

    }

    

}

0
by Holger Reidemeister Author
Posted on Mon, 06/04/2018 - 15:04

In reply to by rgoldenbaum

Hello Robert,

now I took your code into a new report and it works. But you had put the setSelection into the this.init-function.

So I added the function this.GrSize_selChanged and set the selection in dependence to the CheckBox. And then I get an error. Here the added code:

    this.GrSize_selChanged = function(nNewSel)
    {
        if (nNewSel == 0)
        {
            this.dialog.getPages(0).getDialogElement("GrSelW").setSelection(1);
        }
        else
        {
            this.dialog.getPages(0).getDialogElement("GrSelW").setSelection(2);
        }        
    }

 

nSelection ist defined just before setting the selection:

 

        switch (aPrGrSiz[_WKD])                                              // Werte festlegen für WKD
        {
            case  -1: nSelection = 0; sSelection = ""; lSelection = false; break;
            case 100: nSelection = 2; sSelection = ""; lSelection = false; break;
            case  70: nSelection = 3; sSelection = ""; lSelection = false; break;
            case  30: nSelection = 4; sSelection = ""; lSelection = false; break;
            default:  nSelection = 1; sSelection = aPrGrSiz[_WKD].toString(); lSelection = true;
        }

I've checked it with an entry into a protocol-file and all variables are correct.

Is there any difference between the init- and the *_selChanged or *_Changed functions? In the init function it works. But there it is not useful for me.

Regards

Holger

0
by Robert Goldenbaum
Badge for 'Question Solver' achievement
Posted on Tue, 06/05/2018 - 13:30

In reply to by hreidemeister

Hm, normally, there shouldn't be any differences between those callings...  You could try to move the nSelection to a global variable and check if this works...

If not, you can also upload the complete script (well, at least the dialog) here and I can have a look at it...

0
by Holger Reidemeister Author
Posted on Wed, 06/06/2018 - 07:33

In reply to by rgoldenbaum

Hello, Robert,

I had defined the variable nSelection globally before, but that didn't help either. Now I have also defined the array aPages globally. But even this did not lead to the goal.



I will now prepare a report only with the dialog and the necessary functions. So, that the dialog itself basicly runs. Then I will send it to you.



First of all, thank you very much for your help.

Best Regards

Holger

0
by Robert Goldenbaum
Badge for 'Question Solver' achievement
Posted on Wed, 06/06/2018 - 14:56

Hm hm, quite interesting...  I have tried to add another button where I set the dropdown and it works. I then tried to call this button from the sub routine, nothing...

Sorry, but I cannot find the problem...

 

0

Featured achievement

Rookie
Say hello to the ARIS Community! Personalize your community experience by following forums or tags, liking a post or uploading a profile picture.
Recent Unlocks

Leaderboard

|
icon-arrow-down icon-arrow-cerulean-left icon-arrow-cerulean-right icon-arrow-down icon-arrow-left icon-arrow-right icon-arrow icon-back icon-close icon-comments icon-correct-answer icon-tick icon-download icon-facebook icon-flag icon-google-plus icon-hamburger icon-in icon-info icon-instagram icon-login-true icon-login icon-mail-notification icon-mail icon-mortarboard icon-newsletter icon-notification icon-pinterest icon-plus icon-rss icon-search icon-share icon-shield icon-snapchat icon-star icon-tutorials icon-twitter icon-universities icon-videos icon-views icon-whatsapp icon-xing icon-youtube icon-jobs icon-heart icon-heart2 aris-express bpm-glossary help-intro help-design Process_Mining_Icon help-publishing help-administration help-dashboarding help-archive help-risk icon-knowledge icon-question icon-events icon-message icon-more icon-pencil forum-icon icon-lock