EGL Development User Group

EGL Development User Group

EGL Development User Group

The EGL Development User Group is dedicated to sharing news, knowledge, and insights regarding the EGL language and Business Developer product. Consisting of IBMers, HCL, and users, this community collaborates to advance the EGL ecosystem.

 View Only
  • 1.  Combo and Grid with checkbox

    Posted Fri July 08, 2016 02:39 PM

    Dear,

    I am starting developing RUI applications and I am having some problems that I need some help.

    I am using RBD 9.5.0.1, generating JAVA applications, this occur when I do a "PREVIEW" ou "DEBUG" the application.

    1 - I create a combobox which I need to populate dynamically with the IP addresses from a table, the code is working, but when I clicked on combobox, there no options loaded, but if I do a loop, the options are in the component, as you can see on btnFiltrarPrograma_onClick function

    2 - I created a grid with checkbox, and I would to like that the user choose only one, so if he check one, when he tries to check another, uncheck the previous one, and so on.

    Here the source code.

     

    package handlers;

    // RUI Handler

    import com.ibm.egl.rui.loader.DynamicLoader;
    import com.ibm.egl.rui.loader.HandlerLoadedEvent;
    import com.ibm.egl.rui.mvc.FormManager;
    import com.ibm.egl.rui.widgets.Box;
    import com.ibm.egl.rui.widgets.BoxLib;
    import com.ibm.egl.rui.widgets.DataGrid;
    import com.ibm.egl.rui.widgets.DataGridColumn;
    import com.ibm.egl.rui.widgets.DataGridLib;
    import com.ibm.egl.rui.widgets.Div;
    import com.ibm.egl.rui.widgets.GridLayout;
    import com.ibm.egl.rui.widgets.GridLayoutData;
    import com.ibm.egl.rui.widgets.GridLayoutLib;
    import com.ibm.egl.rui.widgets.TextField;
    import com.ibm.egl.rui.widgets.TextLabel;
    import egl.ui.rui.Event;
    import dojo.widgets.DojoButton;
    import services.ListSpecification;
    import services.StatusRec;
    import services.access.TabEnderPrinterService;
    import services.data.TabEnderPrinter;
    import services.primitivetypes.data.END_IP;
    import widgets.systemFooterWI;
    import widgets.systemHeaderWI;
    import widgets.systemLogoWI;
    import com.ibm.egl.rui.widgets.List;
    import com.ibm.egl.rui.widgets.ListMulti;
    import dojo.widgets.DojoComboBox;
    import com.ibm.egl.rui.widgets.Combo;

    //
    //

    handler ListaTabEnderPrinter type RUIhandler{initialUI =[ui
                ], onConstructionFunction = start, cssFile = "css/EnderPrinterRUI.css", title = "ListaTabEnderPrinter"}

        ui Div{padding = 9, children =[content]};

        contentLista Div{padding = 9, children =[
                        new Box{marginBottom = 11, alignment = BoxLib.ALIGN_LEFT, children =[systemFooterWI, systemLogoWI, systemHeaderWI]},
                        new Box{marginBottom = 11, alignment = BoxLib.ALIGN_LEFT, children =[gridFiltro]},
                        new Box{marginBottom = 11, alignment = BoxLib.ALIGN_LEFT, children =[gridOptions]},
                        new Box{marginBottom = 11, alignment = BoxLib.ALIGN_LEFT, children =[preparaPrinterArray_ui]},
                        new Box{marginBottom = 11, alignment = BoxLib.ALIGN_LEFT, children =[textMsg, textMsgErro]} ] };

        content Div{ columns = 1, backgroundColor = "white", padding = 9, position = "relative" };

        regTabEnderPrinter TabEnderPrinter;
        apontaPrinterService TabEnderPrinterService{@dedicatedService};
        preparaPrinterArray TabEnderPrinter[0];
        arrayTabEnderPrinterIP END_IP[0];
        statusPrinter statusRec;
        intArray int;

        currentPage string = ""; // utilizado em DynamicLoader
        currentTitle string = "";// utilizado em DynamicLoader
        
        preparaPrinterArray_ui DataGrid{layoutData = new GridLayoutData{row = 3, column = 2}, pagesize = 10, // showcheckboxes=true,  
                selectionMode = DataGridlib.SINGLE_SELECTION,
                //selectionMode = DATAGRIDLIB.MULTIPLE_SELECTION,
                selectionListeners=[GridRowClicked],
                columns =[
                        new DataGridColumn{name = "CODIGO_EMPRESA", displayName = "Empresa", width = 70},
                        new DataGridColumn{name = "CODIGO_FILIAL", displayName = "Filial", width = 50},
                        new DataGridColumn{name = "CODIGO_SETOR", displayName = "Setor", width = 50},
                        new DataGridColumn{name = "CODIGO_USUARIO", displayName = "Usuário    ", width = 120},
                        new DataGridColumn{name = "NOME_PROGRAMA", displayName = "Programa", width = 120},
                        new DataGridColumn{name = "END_CICS", displayName = "End. CICS", width = 120},
                        new DataGridColumn{name = "END_IP", displayName = "End. IP", width = 120},
                        new DataGridColumn{name = "END_WIN", displayName = "End. WIN", width = 120}
                ], data = preparaPrinterArray as any[]};

        gridOptions GridLayout{layoutData = new GridLayoutData{row = 4, column = 2}, cellPadding = 4, rows = 1, columns = 4, children =[btnFechar, btnPesquisar, btnAlterar, btnIncluir]};
        btnPesquisar DojoButton{layoutData = new GridLayoutData{row = 1, column = 1}, text = "(F2) Pesquisar", onClick ::= btnPesquisar_onClick};
        btnIncluir DojoButton{layoutData = new GridLayoutData{row = 1, column = 3}, text = "(F5) Incluir", onClick ::= btnIncluir_onClick};
        btnAlterar DojoButton{layoutData = new GridLayoutData{row = 1, column = 4}, text = "(F6) Detalhes", onClick ::= btnDetalhes_onClick};
        textMsg TextLabel{layoutData = new GridLayoutData{row = 5, column = 1, horizontalAlignment = GridLayoutLib.ALIGN_RIGHT}, text = "Mensagem"}; 
        textMsgErro TextField{layoutData = new GridLayoutData{row = 5, column = 2 }, readOnly = true, fontWeight = "bold"};

        gridFiltro GridLayout{layoutData = new GridLayoutData{row = 2, column = 2}, cellPadding = 4, rows = 2, columns = 4, children = [ textSelecionado, cmbFiltro, btnFiltrarIP, btnFiltrarPrograma, textFiltroEnderecoIP, TextLabel, textNomePrograma, textFiltroNomePrograma]};

        textFiltroNomePrograma TextField{layoutData = new GridLayoutData{row = 1, column = 2}};
        textNomePrograma TextLabel{layoutData = new GridLayoutData{row = 1, column = 1}, text = "Nome do Programa"};
        btnFechar DojoButton{layoutData = new GridLayoutData{row = 1, column = 2}, text = "(F3) Fechar"};
        systemHeaderWI systemHeaderWI{layoutData = new GridLayoutData{row = 1, column = 2}};
        systemLogoWI systemLogoWI{layoutData = new GridLayoutData{row = 1, column = 1}};
        systemFooterWI systemFooterWI{layoutData = new GridLayoutData{row = 5, column = 2}};

        regTabEnderPrinter_END_IP_nameLabel TextLabel{layoutData = new GridLayoutData{row = 2, column = 1}, text = "Endereço IP"};

        regTabEnderPrinter_form FormManager{entries = [  ]};
        TextLabel TextLabel{ layoutData = new GridLayoutData{ row = 2, column = 1 }, text = "Endereço IP" };
        textFiltroEnderecoIP TextField{ layoutData = new GridLayoutData{ row = 2, column = 2 }};
        btnFiltrarPrograma DojoButton{ layoutData = new GridLayoutData{ row = 1, column = 3 }, text = "...", onClick ::= btnFiltrarPrograma_onClick };
        btnFiltrarIP DojoButton{ layoutData = new GridLayoutData{ row = 2, column = 3 }, text = "..." };
        cmbFiltro Combo{ layoutData = new GridLayoutData{ row = 1, column = 4 }, values = [], selection = 1, onChange ::= changeFunction };
        textSelecionado TextLabel{ layoutData = new GridLayoutData{ row = 2, column = 4 } };

    function start()
       systemfooterwi.textMensagem.text = "";
       systemheaderwi.textNome_do_Programa.text = "LIS_TAB_END_PRT_02";
       systemheaderwi.textDescricao_do_Programa.text = "Lista Tabela de Endereços de Impressoras";
       content.children = contentLista.children;
       DynamicLoader.loadDoneListeners ::= attach;
    end

    function attach(event HandlerLoadedEvent in)
       content.children = event.initialUI;
       currentPage = event.name;
    end

    function GridRowClicked(grid DataGrid in)
        selectedRow TabEnderPrinter[];
        selectedRow = grid.getSelection() as TabEnderPrinter[];
        numberOfRows int = selectedRow.getSize();
        if(numberOfRows > 0)
            for(i int from 1 to numberOfRows)
                sysLib.writeStdOut("Symbol " + selectedRow[i].NOME_PROGRAMA + " is selected.");
            end
        end
    end

    function btnPesquisar_onClick(event Event in)
        montaListaFiltrada();
    end

    function montaListaFiltrada()
        listEspecRec ListSpecification;
        listEspecRec.initialized = false;
        listEspecRec.blockingFactor = 100; 
        listEspecRec.position = 1;
        listEspecRec.pageCount = 1;
        listEspecRec.rowCount = 3;
        case
            when ((textFiltroNomePrograma.text!="") && (textFiltroEnderecoIP.Text!=""))
                listEspecRec.selectClause = ("SELECT CODIGO_EMPRESA, CODIGO_FILIAL, CODIGO_SETOR, CODIGO_USUARIO, NOME_PROGRAMA, END_CICS, END_IP, END_WIN");
                listEspecRec.fromTablesWhere = ("FROM AUTORIZA.TAB_ENDER_PRINTER WHERE NOME_PROGRAMA LIKE " + "'"  + "%"  + textFiltroNomePrograma.text   + "%' and END_IP LIKE "+ "'"  + "%"  + textFiltroEnderecoIP.text   + "%"  + "'");
                writestdout(listespecrec.selectClause);
                writestdout(listespecrec.fromTablesWhere);
                call apontaPrinterService.GetTabEnderPrinterList(listEspecRec, preparaPrinterArray, statusPrinter)
                    returning to retornoListaFiltradaEspecifSucesso onException retornoListaFiltradaEspecifErro;  
            when (textFiltroNomePrograma.text!="")
                listEspecRec.selectClause = ("SELECT CODIGO_EMPRESA, CODIGO_FILIAL, CODIGO_SETOR, CODIGO_USUARIO, NOME_PROGRAMA, END_CICS, END_IP, END_WIN");
                listEspecRec.fromTablesWhere = ("FROM AUTORIZA.TAB_ENDER_PRINTER WHERE NOME_PROGRAMA LIKE " + "'"  + "%"  + textFiltroNomePrograma.text   + "%"  + "'");
                writestdout(listespecrec.selectClause);
                writestdout(listespecrec.fromTablesWhere);
                call apontaPrinterService.GetTabEnderPrinterList(listEspecRec, preparaPrinterArray, statusPrinter)
                    returning to retornoListaFiltradaEspecifSucesso onException retornoListaFiltradaEspecifErro;  
            when (textFiltroEnderecoIP.Text!="")
                listEspecRec.selectClause = ("SELECT CODIGO_EMPRESA, CODIGO_FILIAL, CODIGO_SETOR, CODIGO_USUARIO, NOME_PROGRAMA, END_CICS, END_IP, END_WIN");
                listEspecRec.fromTablesWhere = ("FROM AUTORIZA.TAB_ENDER_PRINTER WHERE END_IP LIKE " + "'"  + "%"  + textFiltroEnderecoIP.text   + "%"  + "'");
                writestdout(listespecrec.selectClause);
                writestdout(listespecrec.fromTablesWhere);
                call apontaPrinterService.GetTabEnderPrinterList(listEspecRec, preparaPrinterArray, statusPrinter)
                    returning to retornoListaFiltradaEspecifSucesso onException retornoListaFiltradaEspecifErro;  
                  otherwise
                call apontaPrinterService.GetTabEnderPrinterListAll(preparaPrinterArray, statusPrinter)
                    returning to retornoListaCompletaSucesso onexception retornoListaCompletaErro;
            end
            
    end

    function retornoListaFiltradaEspecifSucesso(listSpec ListSpecification in, listOut TabEnderPrinter[] in, status StatusRec in)
        preparaPrinterArray_ui.data = listOut as any[];
        if (status.statusCode == 2)
            syslib.writeStdout("passei na função retornoListaFiltradaSucesso_GetTabEnderPrinterListNome - PESQUISA SEM RESULTADO");
            textMsgErro.text = status.message;
        end;
    end

    function retornoListaFiltradaEspecifErro(exp AnyException in)
        textMsgErro.text = exp.message;
    end

    function retornoListaFiltradaSucesso(NOME_PROGRAMA string in, TabEnderPrinterArray TabEnderPrinter[] in, status StatusRec in)
        preparaPrinterArray_ui.data = tabEnderPrinterArray as any[];
    end

    function retornoListaFiltradaErro(exp AnyException in)
    end

    function retornoListaCompletaSucesso(tabEnderPrinterArray TabEnderPrinter[] in, status StatusRec in)
        preparaPrinterArray_ui.data = tabEnderPrinterArray as any[];
    end
        
    function retornoListaCompletaErro(exp AnyException in)
    end
        
    function retornoIPSucesso(tabEnderPrinterArray TabEnderPrinter[] in, status StatusRec in)
        for (intArray int from 1 to tabEnderPrinterArray.getsize() by 1)
            syslib.writeStdout("tabEnderPrinterArray[intArray].END_IP "+tabEnderPrinterArray[intArray].END_IP);
            arrayTabEnderPrinterIP.appendElement(tabEnderPrinterArray[intArray].END_IP);
        end
        for (intArray int from 1 to arrayTabEnderPrinterIP.getsize() by 1)
            syslib.writestdout("arrayTabEnderPrinterIP[intArray] " + intArray + "  " + arrayTabEnderPrinterIP[intArray] );
        end
        regTabEnderPrinter_form.commit();
        regTabEnderPrinter_form.publish();
    end
        
    function retornoIPErro(exp AnyException in)
    end

    function regTabEnderPrinter_form_Publish(event Event in)
        regTabEnderPrinter_form.commit();
            regTabEnderPrinter_form.publish();
    end

    function btnIncluir_onClick(event Event in)
            DynamicLoader.loadHandler("handlers.ManEnderPrinterRUI");
    end

    function SelecionouLinha(grid DataGrid in) returns (int)
        selectedRow TabEnderPrinter[];
        selectedRow = grid.getSelection() as TabEnderPrinter[];
        numberOfRows int = selectedRow.getSize();
        Return(numberOfRows);
    end

    function btnDetalhes_onClick(event Event in)
        if (SelecionouLinha(preparaPrinterArray_ui)>0)
            DynamicLoader.loadHandler("handlers.ManEnderPrinterRUI");
        else
            textMsgErro.color="RED";
            textMsgErro.text="selecione uma impressora";
        end
    end
        
    function btnFiltrarPrograma_onClick(event Event in)
        call apontaPrinterService.GetTabEnderPrinterPROGListAll(preparaPrinterArray, statusPrinter)
            returning to retornoListaProgDistSucesso onexception retornoListaProgDistErro;
    end

    function retornoListaProgDistSucesso(tabEnderPrinterArray TabEnderPrinter[] in, status StatusRec in)
        for (intArray int from 1 to tabEnderPrinterArray.getsize() by 1)
            syslib.writeStdout(tabEnderPrinterArray[intArray].NOME_PROGRAMA);
            cmbFiltro.values.appendElement(tabEnderPrinterArray[intArray].NOME_PROGRAMA);
        end
            
        for (intArray int from 1 to cmbFiltro.values.getsize() by 1)
            syslib.writeStdout(cmbFiltro.values[intArray]);
        end
            
        regTabEnderPrinter_form.publish();
    end

    function retornoListaProgDistErro(exp AnyException in)
        syslib.writeStdout("passei na função retornoListaProgDistErro");
    end

    Function changeFunction(e Event IN)
            textSelecionado.text = cmbFiltro.values[cmbFiltro.selection];
    end

    end

    neidossantos


  • 2.  Re: Combo and Grid with checkbox

    Posted Fri July 15, 2016 03:08 PM

    Dear All,
    I apreciate any answer!
    Thank very much

    neidossantos


  • 3.  Re: Combo and Grid with checkbox

    Posted Mon July 18, 2016 02:53 AM

    Hi,

    could you post a less complicated example of your problem?

     

    Marcel-D


  • 4.  Re: Combo and Grid with checkbox

    Posted Tue July 19, 2016 08:14 AM

    Dear Marcel-D,
    I extracted the part of combobox load. The load is working, but it is not showing.
    Bellow the code.

     

    package br.com.morlan.prt.handlers;

    // RUI Handler

    import com.ibm.egl.rui.widgets.GridLayout;
    import com.ibm.egl.rui.widgets.GridLayoutData;
    import egl.ui.rui.Event;
    import br.com.morlan.prt.services.StatusRec;
    import br.com.morlan.prt.services.access.TabEnderPrinterService;
    import br.com.morlan.prt.services.data.TabEnderPrinter;
    import dojo.widgets.DojoButton;
    import dojo.widgets.DojoComboBox;

    handler ShowComboBox type RUIhandler {initialUI = [ ui ],onConstructionFunction = start, cssFile="css/PrtControleUI.css", title="ShowComboBox"}
        
        ui GridLayout{ columns = 3, rows = 4, cellPadding = 4, children = [ ComboBox, Button ] };
        Button DojoButton{ layoutData = new GridLayoutData{ row = 2, column = 2 }, text = "Load", onClick ::= Button_onClick };
        ComboBox DojoComboBox{ layoutData = new GridLayoutData{ row = 2, column = 3 }, values = [], value = "" };

        recordTabEnderPrinter TabEnderPrinter;
        pointPrinterService TabEnderPrinterService{@dedicatedService};
        preparePrinterArray TabEnderPrinter[0];
        statusPrinter statusRec;
        
        function start()


        end

        function Button_onClick(event Event in)
            call pointPrinterService.GetTabEnderPrinterListAll(preparePrinterArray, statusPrinter) returning to returnSuccess onException returnFail;

        end    

        function returnSuccess(tabEnderPrinterArray TabEnderPrinter[] in, status StatusRec in)

            for (intArray int from 1 to tabEnderPrinterArray.getsize() by 1)
                syslib.writeStdout(tabEnderPrinterArray[intArray].NOME_PROGRAMA);
                ComboBox.values.appendElement(tabEnderPrinterArray[intArray].NOME_PROGRAMA);
            end
            
            for (intArray int from 1 to ComboBox.values.getsize() by 1)
                syslib.writeStdout(ComboBox.values[intArray]);
            end
            
        end

        function returnFail(exp AnyException in)
        end

    end

    neidossantos


  • 5.  Re: Combo and Grid with checkbox

    Posted Wed July 20, 2016 02:00 AM

    Hi,

     

    please try it like this in the call back:

     

     

            TEMP string[0];  // temp. Array                 if(tabEnderPrinterArray.getsize() > 0)            for(i int from 1 to tabEnderPrinterArray.getsize())                             TEMP.appendElement(tabEnderPrinterArray[i].NOME_PROGRAMA);            end        end        ComboBox.values = TEMP;        ComboBox.value = "";

     

     

    Kind Regards!

    Marcel-D


  • 6.  Re: Combo and Grid with checkbox

    Posted Wed July 20, 2016 07:55 AM

    Marcel-D,

    Thanks a lot !!! It is working now !

    Thanks

    neidossantos