【发布时间】:2017-06-01 14:28:18
【问题描述】:
我的表单上有重复的值。我正在使用<ui:repeat> 标签。
我的代码:
<h:panelGroup id="alvs">
<ui:repeat value="#{encuestaController.newEncuesta.preguntas}" var="preg">
<h:outputLabel for="preg" value="add question:" style="font-weight:blue" />
<p:inputText id="preg" value="#{preg.pregunta}" />
<h:outputLabel for="value2" value="The question is option:" style="font-weight:bold" />
<p:selectBooleanButton id="value2" value="#{preg.opcional}" onLabel="Si" offLabel="No" onIcon="ui-icon-check" offIcon="ui-icon-close" style="width:60px">
<p:ajax update="f1:growl2"/>
</p:selectBooleanButton>
<h3 style="margin-top:2px">Question Type</h3>
<p:selectOneMenu value="#{preg.tipo}">
<f:selectItem itemValue="1" itemLabel="one option" />
<f:selectItem itemValue="2" itemLabel="many option" />
</p:selectOneMenu>
<h:panelGroup id="aux">
<ui:repeat value="#{preguntaController.newPregunta.opciones}" var="opc">
<h:panelGroup id="pn11" rendered="#{preg.tipo eq 1}">
uno<p:inputText value="#{opc.descripcion}"/>
</h:panelGroup>
<h:panelGroup id="pn12" rendered="#{preg.tipo eq 2}" >
dos<p:inputText value="#{opc.descripcion}"/>
</h:panelGroup>
</ui:repeat>
</h:panelGroup>
</ui:repeat>
</h:panelGroup>
<p:commandButton class="btn-floating btn-large waves-effect waves-light red" actionListener="#{preguntaController.addOcion}" update="f1:growl2" value="Add" >
<f:ajax execute="pn11 pn12" render="alvs" />
</p:commandButton>
问题是当我想用<p:commandButton/>在问题(pregunta)中添加一个新选项(opciones)时
这为上一个问题添加了与新问题相同的选项。
也许,错误是ajax? <f:ajax execute="pn11 pn12" render="alvs" />
帮帮我!!!
【问题讨论】:
-
Veo que estás usando Materialize, así que te advierto que tengas cuidado con el funcionamiento de los components puesto que al hacer un
, el elemento pierde sus características de Javascript 数据来自 Materialize。 Una vez hagas los "render" tienes que llamar a las funciones de Materialize para reactivar components。 Es un consejo empírico.