0

programmatically generate and bind component

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

desenvolvimento6bab gravatar image desenvolvimento6bab
1

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

  @Command
@NotifyChange({"publicacaoAutorList"})
public void maisAutor() {
  //  publicacaoAutorList.add(new EduPublicacaoAutor(selectedPublicacao));
   publicacaoAutorList.add(new EduPublicacaoAutor(selectedLivro));
}

 @Command
public void buscaAutor() {
    List<Criterion> restricoes = new ArrayList<Criterion>();
    EduPessoa pessoa = new EduPessoa();
    restricoes.clear();
    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.clear();
        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.clear();
            restricoes.add(Restrictions.eq("autor", autor));
            publicacaoAutor.setAutor(autor);
         //   publicacaoAutor.setIdPublicacao(selectedLivro);
         //   publicacaoAutorList.add(publicacaoAutor);
            Messagebox.show(autor.getLtInstituicao());
        }
    }
}
delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

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

Follow
1 follower

RSS

Stats

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

Seen: 24 times

Last updated: Sep 30 '16

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