Skip to main content
1-Visitor
November 15, 2012
Question

How to connect XUI and ACL

  • November 15, 2012
  • 4 replies
  • 1131 views
Hi!

I was wondering if there's a way in order to call an ACL file from a XUI
button. I was thinking that maybe it could be possible through source
command, however I have tried and nothing happens =( So, please if
anybody knows a way to solve this issue I really appreciate your help;
also I'm trying to execute this task through javascript and Acl.eval I'm
just thinking that maybe I'm wrong with that, so thanks again for your
support.

Best Regards,
Paulette

    4 replies

    18-Opal
    November 15, 2012
    Hi Paulette--

    There are a couple of ways you can do this:

    1) In your XUI file, inside the button object, use script code to invoke the ACL function via the AOM Acl.eval() method, something like this:

    <button label="Click" me&quot;=">
    <script ev:event="DOMActivate" type="text/javascript">Acl.eval("response('Hello from ACL!')");</script>
    </button>

    2) When you load the XUI to create and show the dialog, use dlgitem_add_callback() to attach an ACL function to the control, something like this:

    XUI:
    <button label="Click" me&quot;=" id="clickmebtn"/">

    ACL:

    function hi_from_acl(win, dlgitem, eventtype, eventsubtype, detail) {
    if (eventtype == "ITEM_CHANGED") {
    response("Hi from ACL (via dlgitem callback)");
    }
    }

    function showDlg() {
    local xuidoc = doc_open("myxuidlg.xml");
    local win = window_create("xui",0x10,xuidoc);
    dlgitem_add_callback(win, "clickmebtn", hi_from_acl);
    window_show(win,1);
    }

    Hope that helps.

    --Clay

    Clay Helberg
    Senior Consultant
    TerraXML

    1-Visitor
    November 15, 2012
    Paulette,

    The xui button element has an attribute named command. You can call ACL
    functions or commands from there. I would put whatever ACL code you have
    in the file you're trying to call in a function and either call it
    directly from that command attribute, or alias the function and call it
    from the command attribute. The file that contains the function and the
    file where you alias the function needs to be loaded before the XUI file
    so that your customizations are available when the user presses the XUI
    button. You can do that by placing those ACL files in your <custom>/init
    directory.
    Here's some untested code snippets:

    [ACL file in <custom>/init directory]
    package cool_stuff_package
    function cool_stuff() {
    # do your cool stuff here
    }
    alias CoolStuff { cool_stuff_package::cool_stuff() }

    [XUI file]
    ....
    <button command="CoolStuff" id="cool_stuff_btn"></button>
    ....

    Hope that helps,



    Brian Jensen
    bjensen@bluelid.com



    pzorrilla1-VisitorAuthor
    1-Visitor
    November 15, 2012

    I have been trying this, but I can not see any response from Arbortext. I have been working on the second way, I implemented the basic example you provided me, there are other types of event? My XUI window is showed, but I suppose some fashion my method can not be called. Do I have to implement my ACL method in the same file i have coded the function to show my XUI window?



    As always I really appreciate your time and support.


    Regards,


    Paulette



    In Reply to Clay Helberg:


    Hi Paulette--

    There are a couple of ways you can do this:

    1) In your XUI file, inside the button object, use script code to invoke the ACL function via the AOM Acl.eval() method, something like this:

    <button label="Click" me&quot;=">
    <script ev:event="DOMActivate" type="text/javascript">Acl.eval("response('Hello from ACL!')");</script>
    </button>

    2) When you load the XUI to create and show the dialog, use dlgitem_add_callback() to attach an ACL function to the control, something like this:

    XUI:
    <button label="Click" me&quot;=" id="clickmebtn"/">

    ACL:

    function hi_from_acl(win, dlgitem, eventtype, eventsubtype, detail) {
    if (eventtype == "ITEM_CHANGED") {
    response("Hi from ACL (via dlgitem callback)");
    }
    }

    function showDlg() {
    local xuidoc = doc_open("myxuidlg.xml");
    local win = window_create("xui",0x10,xuidoc);
    dlgitem_add_callback(win, "clickmebtn", hi_from_acl);
    window_show(win,1);
    }

    Hope that helps.

    --Clay

    Clay Helberg
    Senior Consultant
    TerraXML

    18-Opal
    November 15, 2012
    Hi Paulette--



    No, you don't have to define the ACL function in the same file as the
    one that creates the dialog. However, if the two functions belong to
    different packages, you will need to qualify the function name by adding
    the package when you add the callback. For example, suppose you have
    defined the function you want to trigger in a package called
    custom_functions. Then you would want to add the callback using
    something like this:



    dlgitem_add_callback(win, "clickmebtn", custom_functions::hi_from_acl);



    If you're not using package names, and the code is not getting invoked,
    then there may be something else going on.



    It might help if you can post the button definition in your XUI file,
    and the script code where you define the ACL function you want to call
    and the dlgitem_add_callback() you are using to add it to the dialog.



    --Clay





    Clay Helberg

    Senior Consultant

    TerraXML