我如何更改"selectOneMenu"的值?无需重新启动"inputText"? [英] How I can change the value of "selectOneMenu" without restart the "inputText"?

查看:86
本文介绍了我如何更改"selectOneMenu"的值?无需重新启动"inputText"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下一个代码:

<h:form id="form" >
    <h:panelGrid >
        <p:inputText placeholder="Name" value="#{controladorGestionGrados.otherValue}" />
        <p:selectOneMenu value="#{controladorGestionGrados.value}" >
            <f:selectItem itemValue="A" itemLabel="A" />
            <f:selectItem itemValue="B" itemLabel="B" />
            <f:selectItem itemValue="C" itemLabel="C" />
            <p:ajax update=":form"  />
        </p:selectOneMenu>
        <p:outputLabel id="someText"
                       value="Some text" 
                       rendered="#{controladorGestionGrados.value eq 'C'}" />
    </h:panelGrid>
</h:form>

首先:我在inputText中写了任何东西.第二:我选择选项C.

First: I write anything in the inputText. Second: I select option C.

此后,显示outputLabel某些文本",但将重置inputText.

After, the outputLabel "Some text" is displayed, but the inputText is reseted.

如何在不重新启动"inputText"的情况下更改"selectOneMenu"的值?

How I can change the value of "selectOneMenu" without restart the "inputText"?

我尝试过:

<p:ajax update="someText"  />

但是实际上inputText不会重置,但是outLabel不会显示.

But effectively the inputText don't reset, but outLabel don't show.

推荐答案

包装您的< p:outputLabel>

<p:outputLabel id="someText" value="Some text" rendered="#{controladorGestionGrados.value eq 'C'}" />

带支架< p:outputPanel>

喜欢这个:

<p:outputPanel id="someTextPanel">
<p:outputLabel id="someTextLabel" value="Some text" rendered="#{controladorGestionGrados.value eq 'C'}" />
</p:outputPanel>

并使用

<p:ajax update="someTextPanel" />

所以整个代码应该是这样的:

So entire code should be something like this :

<h:form id="form" >
    <h:panelGrid >
        <p:inputText placeholder="Name" value="#{controladorGestionGrados.otherValue}" />
        <p:selectOneMenu value="#{controladorGestionGrados.value}" >
            <f:selectItem itemValue="A" itemLabel="A" />
            <f:selectItem itemValue="B" itemLabel="B" />
            <f:selectItem itemValue="C" itemLabel="C" />            
            <p:ajax update="someTextPanel" />
          </p:selectOneMenu>
       <p:outputPanel id="someTextPanel">
    <p:outputLabel id="someTextLabel" value="Some text" rendered="#{controladorGestionGrados.value eq 'C'}" />
    </p:outputPanel>
    </h:panelGrid>
</h:form>

这篇关于我如何更改"selectOneMenu"的值?无需重新启动"inputText"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆