Ui:repeat - taking Description from the bank

Asked

Viewed 298 times

0

Hi. I would like to know ,how to organize my ui:repeat...

why on the page it displays : Change of Schedule and the checkbox field, Nightwork and the checkbox field

summing up I wish I could organize it ...the code it takes from a list ,and that these descriptions are inserted in the description table in the database,eg:time change and etc...

how do I display on the organized page, type how many messages I want horizontally, how many vertically .. pq the datatable has already done the test and does not take

I want to leave some vertical and horizontal, and put the checkbox field first, inserir a descrição da imagem aqui

<ui:repeat  value="#{cadastroFuncionarioBean.listaQuestoes}"  var="questao">
                                <p:outputLabel  value="#{questao.descricao}"  for="questao"/>
                                <p:selectBooleanCheckbox id="questao"/>
                            </ui:repeat>

1 answer

0


Well... I don’t know if I understood your difficulty correctly, but I tried to run a simulation. I think placing checkboxes horizontally and vertically as your needs get a little difficult without using a datatable. I believe the solution lies in the entity Questão (if I understand correctly your problem). See how the model looked below:

Upshot: inserir a descrição da imagem aqui

In XHTML:

<p:dataTable value="#{controlador.listaQuestoes}" var="q" styleClass="width: 40%;">
    <p:column headerText="Ativa">
        <p:selectBooleanCheckbox id="questao" value="#{q.ativa}">
            <p:ajax />
        </p:selectBooleanCheckbox>
    </p:column>
    <p:column headerText="Descrição">
        <p:outputLabel value="#{q.descricao}"  for="questao"/>
    </p:column>
    <p:column headerText="Questões Relacionadas">
        <c:if test="#{not q.relacionadas.isEmpty()}">
            <ui:repeat value="#{q.relacionadas}" var="r">
                <h:panelGroup style="padding: 10px;">
                    <p:selectBooleanCheckbox id="relacionda" value="#{r.ativa}">
                        <p:ajax />
                    </p:selectBooleanCheckbox>
                    <p:outputLabel value="#{r.descricao}" for="relacionda"/>
                </h:panelGroup>
            </ui:repeat>
        </c:if>
    </p:column>
</p:dataTable>

No Bean:

private List<Questao> listaQuestoes = new ArrayList<Questao>();

public List<Questao> getListaQuestoes() {
    if (this.listaQuestoes.isEmpty()) {
        this.inicializarQuestoes();
    }
    return this.listaQuestoes;
}

public void setListaQuestoes(List<Questao> listaQuestoes) {

    this.listaQuestoes = listaQuestoes;
}

public void inicializarQuestoes() {
    Questao q = null;
    this.listaQuestoes.clear();
    q = new Questao("Mudança de horário");
    q.getRelacionadas().add(new Questao("Horário Integral"));
    q.getRelacionadas().add(new Questao("Horário Parcial"));
    this.listaQuestoes.add(q);
    q = new Questao("Trabalho noturno");
    this.listaQuestoes.add(q);
    q = new Questao("Trabalho em horário extraordinário");
    this.listaQuestoes.add(q);
    q = new Questao("Desconto em salário");
    q.getRelacionadas().add(new Questao("Desconto X"));
    q.getRelacionadas().add(new Questao("Desconto Y"));
    q.getRelacionadas().add(new Questao("Desconto Z"));
    this.listaQuestoes.add(q);
}

Entity Questao:

public class Questao {

    private String descricao;

    private boolean ativa;

    private List<Questao> relacionadas = new ArrayList<Questao>();

    public Questao(String descricao) {
        this.descricao = descricao;
        this.ativa = false;
    }

    public String getDescricao() {

        return this.descricao;
    }

    public void setDescricao(String descricao) {

        this.descricao = descricao;
    }

    public boolean isAtiva() {

        return this.ativa;
    }

    public void setAtiva(boolean ativa) {

        this.ativa = ativa;
    }

    public List<Questao> getRelacionadas() {

        return this.relacionadas;
    }

    public void setRelacionadas(List<Questao> relacionadas) {

        this.relacionadas = relacionadas;
    }

}
  • it was the same way Marcus.. had researched and really with datatable it would work.Obriigado ! -

  • I am glad that you were able to solve it. If the answer has helped, I will be glad to signal as resolved, as it helps in the points. Thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.