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).
只需要删除<%%>条件并使用它
rendered="#{PreguntasBean.valor =='3'}"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.