JSF page displaying object reference value

3

Good evening.

I have a page in JSF called simulate.xhtml where I implement a filter to generate the simulation and I'm also trying to display results of the database that have already been filtered on that same page , but as a result I get these results:

[com.sisEnade.tcc.modelo.Questao@20, com.sisEnade.tcc.modelo.Questao@21, com.sisEnade.tcc.modelo.Questao@22]

I tried to implement in a dataTable more whenever I click on Generate Simulate I get a notFound, it's as if the dataTable needed to reload soon after clicking the button. Can you help me with this detail too?

I'm trying to display it as follows to test:

JSF page:

    <ui:define name="titulo">Gerar Simulado</ui:define>

    <ui:define name="corpo">

        <h1>Filtro para gerar Simulado</h1>
        <h:form id="frmCadastro">
            <br></br>

            <h:panelGrid columns="2">

                <p:outputLabel value="Curso" for="curso" style="font-weight:bold" />
                <p:selectOneMenu id="curso"
                    value="#{gerarSimuladoBean.cursoSelecionado}"
                    converter="cursoConverter" required="true"
                    requiredMessage="Preencha o curso">
                    <f:selectItem itemLabel="Selecione..." />
                    <f:attribute name="collectionType" value="java.util.ArrayList" />
                    <f:selectItems value="#{cadastroQuestaoBean.cursos}" var="curso"
                        itemLabel="#{curso.nome}" itemValue="#{curso}" />
                </p:selectOneMenu>
            </h:panelGrid>


            <h:panelGrid id="gridComplexidade" columns="2">
                <p:outputLabel value="Complexidade da Questão" for="complexidade"
                    style="font-weight:bold" />
                <p:selectOneMenu id="complexidade"
                    value="#{gerarSimuladoBean.complexidadeSelecionada}"
                    required="true"
                    requiredMessage="Por favor, preencha a complexidade.">
                    <f:selectItem itemLabel="Selecione..." />
                    <f:selectItem itemLabel="1" itemValue="1" />
                    <f:selectItem itemLabel="2" itemValue="2" />
                    <f:selectItem itemLabel="3" itemValue="3" />
                    <f:selectItem itemLabel="4" itemValue="4" />
                    <f:selectItem itemLabel="5" itemValue="5" />
                </p:selectOneMenu>
            </h:panelGrid>

            <h:panelGrid id="gridNumeroQuestoes" columns="2">
                <p:outputLabel value="Número de questoes" for="numeroDeQuestoes"
                    style="font-weight:bold" />
                <p:selectOneMenu id="numeroDeQuestoes"
                    value="#{gerarSimuladoBean.numeroDeQuestoesSimulado}"
                    required="true"
                    requiredMessage="Por favor, preencha o numero de questoes.">
                    <f:selectItem itemLabel="Selecione..." />
                    <f:selectItem itemLabel="3" itemValue="3" />
                    <f:selectItem itemLabel="5" itemValue="5" />
                    <f:selectItem itemLabel="10" itemValue="10" />
                    <f:selectItem itemLabel="20" itemValue="20" />
                    <f:selectItem itemLabel="40" itemValue="40" />
                </p:selectOneMenu>
            </h:panelGrid>

            <p:commandButton value="Gerar Simulado"
                action="#{gerarSimuladoBean.gerarSimulado}" icon="ui-icon-search"
                iconPos="right" update="frmCadastro">
            </p:commandButton>
            <br></br>
            <br></br>
            <br></br>
            <br></br>
            <p:panelGrid id="teste">
                <h:outputText value="#{gerarSimuladoBean.questoes}">
                </h:outputText>
            </p:panelGrid>
        </h:form>
    </ui:define>
</ui:composition>

Excerpt where the object addresses are displayed:

<p:panelGrid id="teste">
                    <h:outputText value="#{gerarSimuladoBean.questoes}">
                    </h:outputText>
</p:panelGrid>
    
asked by anonymous 14.10.2015 / 06:47

1 answer

6

This value appears because you are prompted to print the list object here:

<h:outputText value="#{gerarSimuladoBean.questoes}">

If the value passed to the <h:outputText> tag is not a String , the toString() method of the object will be called to get the textual representation of it.

The problem would not occur with the <dataTable> component because it would account for displaying each item in the list properly, but for it to work you really need to instruct the table to update itself when you click the button.

The update should already have occurred because you used the update attribute on the button.

I did not quite understand what you meant by "notFound". If the method of the button actually exists such an error should not occur. Caution if you are doing some redirection to a non-existent location, but this should not happen, since updating the components in PrimeFaces is done via Ajax.

This is all the help I can get from the information available.

    
14.10.2015 / 07:35