Question

I want to delete al jsf components in a jsf and repaint it when i change value in a combo box and don't know how to do it. I need it because i have some java ifs whose paint diferent components in the page.

This is the code:

<%
    FacesContext facesContext = FacesContext.getCurrentInstance();

    PreguntasBean preguntasBean = (PreguntasBean) facesContext
            .getApplication()
            .createValueBinding("#{PreguntasBean}")
            .getValue(facesContext);
    preguntasBean.buscaTipoPregunta();

%>
        <h:outputText value="Selecciona un tipo de pregunta" />
        <h:selectOneMenu 
            id="tipoSeleccionado" value="#{PreguntasBean.tipos}" valueChangeListener="#{PreguntasBean.muestraPregunta}" onchange="submit()">
            <f:selectItems value="#{PreguntasBean.tiposValue}" />
        </h:selectOneMenu>


        <h:outputText value="Enunciado " />
        <h:inputText value="#{PreguntasBean.preguntaParaGuardar.enunciado}" />

        <%if(preguntasBean.getValor().equals("1") || preguntasBean.getValor().equals("2") || preguntasBean.getValor().equals("3")){ %>

            <%if(preguntasBean.getValor().equals("2")){ %>
                    <h:outputText value="Opcion 1" />
                    <h:inputText value="" />
                    <h:outputText value="Opcion 2" />
                    <h:inputText value="" />
            <%} %>
            <h:outputText value="Sentencia" />
            <h:inputText value="#{PreguntasBean.sentencia}" />
            <%if(preguntasBean.getValor().equals("3")){ %>
                <h:outputText value="Texto fin" />
                <h:inputText value="" />
            <%} %>
            <h:commandButton value="Añadir sentencia" action="#{PreguntasBean.addSentencia}"/>
            <h:dataTable border="1" var="tablaSentencias" value="#{PreguntasBean.listaSentencias}" binding ="#{PreguntasBean.tabla}">
                <h:column>
                    <f:facet name="header">
                        <h:outputText value="Sentencias" />
                    </f:facet>
                        <h:outputText value="#{tablaSentencias.sentencia}" />
                </h:column>
                <h:column>
                    <f:facet name="header">
                        <h:outputText value="Acción" />
                    </f:facet>
                    <h:commandButton value="Borrar" action="#{PreguntasBean.borraSentencia}" />
                </h:column>
            </h:dataTable>
        <%} %>

So when i change the selectOneMenu I want to delete all outputtexts, inputs, datatables... (not the VO, only jsf tags).

Was it helpful?

Solution

Only need to delete <% %> conditionals and use this

rendered="#{PreguntasBean.valor =='3'}"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top