programmatically generate and bind component

asked 2016-09-29 17:24:05 +0800

desenvolvimento6bab gravatar image desenvolvimento6bab

So, I want to click on the div which activates maisAutor method and add a new component. But the problem is that I want to bind each textfield with a separated search that I will use in the place of the ??????? at restricoes.add(Restrictions.eq("nuCpf", ???????));

<grid id="listboxAutores" model="@bind(vm.publicacaoAutorList)" sclass="list">
                    <column hflex="min">
                        <div onClick="@command('maisAutor')" style="float: right;" sclass="button">
                                <label class="icon-button fa fa-plus-square"></label>
                <template name="model">
                    <row visible="@bind(!each.stRegistro.equals('excluido'))">
                            <hbox hflex="1">
                                <textbox onChange="@command('buscaAutor')" value="@load(each.autor.pessoa.nuCpf)" hflex="1"/>
                            <hbox hflex="1">
                                <label value="@load(each.autor.pessoa.nmPessoa)" hflex="1"/>
                            <button onClick="@command('removeAutor',remove=each)" sclass="fa fa-trash" width="36px"/>

public void maisAutor() {
  //  publicacaoAutorList.add(new EduPublicacaoAutor(selectedPublicacao));
   publicacaoAutorList.add(new EduPublicacaoAutor(selectedLivro));

public void buscaAutor() {
    List<Criterion> restricoes = new ArrayList<Criterion>();
    EduPessoa pessoa = new EduPessoa();
    restricoes.add(Restrictions.eq("nuCpf", ???????));
    pessoaList = pessoaListService.getList(restricoes);

    if(pessoaList.size() > 0) {
    pessoa = pessoaList.get(0);
    if (pessoa != null) {
        EduAutor autor = new EduAutor();
        restricoes.add(Restrictions.eq("pessoa", pessoa));
        autorList = autorListService.getList(restricoes);

        if(autorList.size() >0) {
        autor = autorList.get(0);
        //  autorList.add(selectedAutor); 
        if (autor != null) {
            EduPublicacaoAutor publicacaoAutor = new EduPublicacaoAutor();
            restricoes.add(Restrictions.eq("autor", autor));
         //   publicacaoAutor.setIdPublicacao(selectedLivro);
         //   publicacaoAutorList.add(publicacaoAutor);
delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-09-30 14:44:06 +0800

SoumiaOulkasse gravatar image SoumiaOulkasse
3 1

As I understand you want to bind the value of each textbox, so the value that you need in place of '????' must be passed as a parameter of the methode 'buscaAutor' so in zul file you should use this syntaxe onChange="@command('buscaAutor',param=self.value)"

and in the controller the methode should be like this:

@Command public void buscaAutor(@BindingParam("param") String param) { List<criterion> restricoes = new ArrayList<criterion>(); EduPessoa pessoa = new EduPessoa(); restricoes.clear(); restricoes.add(Restrictions.eq("nuCpf", param)); . . . ........

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

1 follower



Asked: 2016-09-29 17:24:05 +0800

Seen: 25 times

Last updated: Sep 30 '16

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