ERROR when selecting a simulation

Asked

Viewed 28 times

0

I have a subscription problem.

I have a screen that recovers cycles that are open according to the course of the user and for each cycle of this already has a simulated saved, ie a relationship.

BEAN:

@Postconstruct

private void init(){
    this.ciclosCurso = CicloDAO.buscaCicloPorCursoDoUsuario(
                codigoCursoUsuario, dataMaxima);
}

The problem I’m facing is this::

When it comes to answering a cycle, if it has 2 cycles it only takes the last one: I know where the problem is I just don’t know how to solve.

Take a look:

No meu dataTable eu tenho: 

                    <p:column headerText="Responder Simulado" style="width: 100px; text-align: center">
                        <p:commandButton id="responderSimulado" icon="ui-icon-check" title="Responder Simulado" update="@this :frmCadastroSimulado:exibePerguntas"
                            actionListener="#{responderSimuladoBean.recuperaSimuladoDeAcordoComCicloSelecionado}">
                            <f:param name="ciclo" value="#{ciclo.codigo}"/>
                        </p:commandButton>
                    </p:column>

In the recovery method:

public void recuperaSimuladoDeAcordoComCicloSelecionado() {
        for (Ciclo ciclo : ciclosCurso) {
            this.simulado = this.simuladoDAO.buscaSimuladoPorCiclo(ciclo
                    .getCodigo());
        }

Just to complement:

select s from Simulado s where s.ciclo.codigo = :idCiclo

In short, I retrieve a simulated code from the cycle. The problem is that in the code excerpt above it retrieves the simulated that I want and then retrieves the other simulated that was found in Postconstruct, however I did not ask to answer him, that is, he finds the simulated with the code that I want and then overwrites.

How do I resolve?

  • What is the scope of your bean?

  • @Weslleytavares is Viewscoped.

  • Have you tried using a SessionScoped? In this case, only for the same test level.

No answers

Browser other questions tagged

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