Ui: repeat - getting the description in the bank

0

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

Because on the page, it displays: Schedule Change and the checkbox field,                               Night Work and the checkbox field

In summary I wanted to be able to organize it ... the code it takes from a list, and that these descriptions are inserted in the description table in the database, eg: change of time and etc ...

How do I display on the page organized, type how many messages I want horizontally, how many vertically ..pq the dataTable already did the test and does not catch

I want to leave some vertically and horizontally, and put the checkbox field first, follow it as it displays on my page

<ui:repeat  value="#{cadastroFuncionarioBean.listaQuestoes}"  var="questao">
                                <p:outputLabel  value="#{questao.descricao}"  for="questao"/>
                                <p:selectBooleanCheckbox id="questao"/>
                            </ui:repeat>
    
asked by anonymous 05.12.2016 / 14:47

1 answer

0

Well ... I do not know if I understood your difficulty correctly, but I tried to make a simulation. I think that placing checkboxes horizontally and vertically according to your needs gets a bit difficult without using a datatable. I believe the solution is in the Questão entity (if I understood your problem correctly). Here's how the model looks:

Result:

InXHTML:

<p:dataTablevalue="#{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;
    }

}
    
05.12.2016 / 21:11