0

How display variable structure in .zul?

asked 2015-09-29 18:55:55 +0800

lramellavotta gravatar image lramellavotta flag of Italy
200 1 8

I have this struct

private class Permessi
{
    String Nome_videata;
    String Descrizione;
    Map<String, Boolean> Lista_tab;
}

Lista_tab have variable length like this example:

Videata1, Videata1Description, TAB1, TRUE, TAB2, FALSE
Videata2, Videata2Description, TAB1, FALSE

How can I display this struct in listbox object?

thanks

delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted
1

answered 2015-09-29 20:29:17 +0800

Darksu gravatar image Darksu
1991 1 4

Hello lramellavotta,

I would use a rowRenderer in order to retrieve the data and construct the listbox as i desire.

Please refer to the following example:

http://www.zkoss.org/zkdemo/grid/dynamic_renderer

Best Regards,

Darksu

link publish delete flag offensive edit
0

answered 2015-10-18 12:45:44 +0800

lramellavotta gravatar image lramellavotta flag of Italy
200 1 8

Hi, I have a little problem to display the data...

    @Wire("#lbPermessi")
    Listbox lbPermessi;

My zul

<tabbox id="Tabbox">
        <tabs id="Tabs">
            <tab id="elenco"    label="Elenco"      onSelect="@command('tbElencoSel')" />
            <tab id="dettaglio" label="Dettaglio"   onSelect="@command('tbDettaglioSel')" />
            <tab id="eventi"    label="Eventi"      onSelect="@command('tbEventiSel')" />
            <tab id="log"       label="Log"         onSelect="@command('tbLogSel')" />
            <tab id="permessi"  label="Permessi"    onSelect="@command('tbPermessiSel')" />
<tabpanel id="tbPermessi">

                <listbox id="lbPermessi" mold="paging" sizedByContent="true" height="500px"
                    span="true" autopaging="true" 
                    visible="@load(not empty vm.selected)">
                    <listhead>
                        <listheader label="Videata" width="80px"/>
                        <listheader label="Descrizione" width="140px"/>
                    </listhead>
                </listbox>
            </tabpanel>

My java code

    public class PermessiVideo
    {
       String Nome_videata;
       String Descrizione;
       Map<String, Map<String, Boolean>> Tabs = new LinkedHashMap<String, Map<String, Boolean>>();
    }

    List<PermessiVideo> lstPermessiVideo;

This struct to deploy the permission of any Form and his tab.

image description

@Command
public void tbPermessiSel() 
{


BindUtils.postNotifyChange(null,null,Adm_utenti.this,"lstPermessiVideo");
}

public void doHeader()

{ Listhead lh = lbPermessi.getListhead(); for(int i=0;i<nummaxtabs;i++) {="" lh.appendchild(new="" listheader("tab",null,"80px"));="" lh.appendchild(new="" listheader("p",null,"30px"));="" }<="" p="">

    lbPermessi.setModel(new ListModelList<PermessiVideo>(lstPermessiVideo));
    lbPermessi.setItemRenderer(new myRender());

}

private class myRender implements ListitemRenderer<PermessiVideo>
{

    @Override
    public void render(Listitem item, PermessiVideo pv, int index) throws Exception 
    {
        System.out.print(pv.Nome_videata+"("+pv.Descrizione+") ->");
        new Listcell(pv.Nome_videata).setParent(item);
        new Listcell(pv.Descrizione).setParent(item);
        for(Entry<String, Map<String, Boolean>> entry : pv.Tabs.entrySet()) 
        {
            Map<String, Boolean> Tabs = entry.getValue();   
            for(Entry<String, Boolean> lstTab : Tabs.entrySet())
            {
                new Listcell(lstTab.getKey().toString());
                new Listcell(lstTab.getValue().toString());
                System.out.print(lstTab.getKey().toString()+" "+lstTab.getValue().toString()+" | ");
            }
        }
        System.out.println("");
    }

The System.out is corrected but the zul not load the tabs.... image description

Any idea?

Luca

link publish delete flag offensive edit
0

answered 2015-10-18 13:18:23 +0800

lramellavotta gravatar image lramellavotta flag of Italy
200 1 8

Solved.... The zul expects a boolean (I hope...)

This code solved the problem:

        @Override
    public void render(Listitem item, PermessiVideo pv, int index) throws Exception 
    {
        System.out.print(pv.Nome_videata+"("+pv.Descrizione+") ->");
        new Listcell(pv.Nome_videata).setParent(item);
        new Listcell(pv.Descrizione).setParent(item);
        for(Entry<String, Map<String, Boolean>> entry : pv.Tabs.entrySet()) 
        {
            Map<String, Boolean> Tabs = entry.getValue();   
            for(Entry<String, Boolean> lstTab : Tabs.entrySet())
            {
                //
                // Descrizione TAB
                //
                Listcell cellTab = new Listcell();

                cellTab.appendChild(new Label(lstTab.getKey().toString()));
                item.appendChild(cellTab);

                //
                // Permesso TAB
                //
                Checkbox ckb = new Checkbox();
                cellTab = new Listcell();

                ckb.setValue(lstTab.getValue().toString());
                cellTab.appendChild(ckb);
                item.appendChild(cellTab);
                System.out.print(lstTab.getKey().toString()+" "+lstTab.getValue().toString()+" | ");

            }
        }
        System.out.println("");
    }
link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2015-09-29 18:55:55 +0800

Seen: 50 times

Last updated: Oct 18 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More