0

How to create a new zul from a selection

asked 2013-06-04 20:23:20 +0800

posh gravatar image posh
3 2

updated 2013-06-04 20:24:20 +0800

Hi everyone, so, I have artigos.zul that consists on a listbox with some products from database, when I select a row my controller opens a new zul that receives as arguments the detail of the selected row.. The question is, when I use executions.createComponents, to create the detail zul, this new zul is created under artigos.zul.. How can I make it to create the detail zul over the current one(artigos.zul) .. What I did was crate a div that contains artigos.zul, when I make a selection, this div is set to false in .setVisible method.. Is there a better way?

artigos.zul

<zk>

<borderlayout>

    <north vflex="min">
        <div vflex="1" hflex="1" sclass="topo">
            <hbox vflex="1" hflex="1" align="center">
                <hbox hflex="1" vflex="1">
                    <button image="/imagens/return.png" width="50px" height="50px" href="index.zul" />
                </hbox>
                <hbox hflex="1" vflex="1" align="end" pack="end">
                    <button image="/imagens/home.png" width="50px" height="50px" href="index.zul" />
                </hbox>
            </hbox>
        </div>
    </north>

    <center vflex="min">
        <div hflex="1" vflex="1">
            <listbox sizedByContent="true" span="true" id="artigosListbox" apply="artigos.LoadArtigos, artigos.ControllerArtigos" >
                <listhead>
                    <listheader label="Código" />
                    <listheader label="Descrição" />
                </listhead>

                <template name="model">
                    <listitem>
                        <listcell label="${each.codigo }" />
                        <listcell label="${each.descricao }" />
                    </listitem>
                </template>
            </listbox>
        </div>  
    </center>

    <south vflex="min">
        <include src="sul.zul" />
    </south>

</borderlayout> 
</div>

</zk> >

Controller

public class ControllerArtigos extends SelectorComposer<component> {

@Wire
private Listbox artigosListbox;

@Wire
private Div global;

@Listen("onSelect = #artigosListbox")
public void showDetail()
{
    Set<Artigo> seleccao =  ((Selectable<Artigo>) artigosListbox.getModel()).getSelection(); 

    if(seleccao != null && !seleccao.isEmpty())
    {
        Map data = new HashMap();
        Artigo info = seleccao.iterator().next();

        data.put("CODIGO", info.getCodigo().toString());
        data.put("DESCRICAO", info.getDescricao());
        data.put("SRCIMAGEM", info.getCaminho());
        data.put("PRECOIVA", info.getPrecoIva().toString());

        global.setVisible(false);
        Executions.createComponents("artigoDetail.zul", null, data);

    }
}

}

delete flag offensive retag edit

1 Answer

Sort by » oldest newest most voted
0

answered 2013-06-05 05:49:27 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

As you did not shared artigoDetail.zul file code i can imagine you used Window Component there then i will suggest you to use ..

<window apply="org.zkoss.bind.BindComposer" 
        title="Column Manager"
        viewModel="@id('vm') @init('com.MyViewModel')"
        height="50%" width="48%" mode="modal" position="center" popup="true"
        border="normal">

Use mode="modal" in Window Component for more information how to create a modal Window you can check this ZK Modal Window

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: 2013-06-04 20:23:20 +0800

Seen: 13 times

Last updated: Jun 05 '13

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