简体   繁体   English

PrimeFaces如何重置背景色

[英]PrimeFaces how to reset background color

I have a reset button on my xhtml and basically when the field is empty it will prompt a message and the field background will turn to red. 我在xhtml上有一个重置按钮,基本上,当该字段为空时,它将提示消息,并且字段背景将变为红色。

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">

    <div id="cId" class="panel-body-width panel-input-body-width">
        <div>
            <div id="snDIV" class="row row-in-fieldset-div">
                <div class="col-md-4">
                    <p:outputLabel id="myLabel" value="myNumber" />
                </div>
                <div class="col-semicolon col-md-1">
                    <p:outputLabel value=":" />
                </div>
                <div class="col-md-3 row-in-fieldset-cp">
                    <p:inputText id="myNumber"
                        value="#{userBean.myNumberInput}"
                        required="#{userBean.isRequired}"
                        requiredMessage="Input should not be empty" >
                        <p:ajax event="blur" update="myNumber myNumberMsg" />
                    </p:inputText>
                </div>
            </div>
            <div class="col-md-3 row-in-fieldset-msg">
                <p:message id="myNumberMsg" for="myNumber" />
            </div>
            </div>
        </div>
    </div>
    <br />
    <div class="panel-footer">
        <p:commandButton id="reset" value="Reset"
            actionListener="#{userBean.reset}" process="@this"
            update="myNumber myNumberMsg" >
        </p:commandButton>
    </div>
</ui:composition>

Problem is, once i hit reset, the value does change to default and the error message disappears but the background color of the field is still red and does not change back to white. 问题是,一旦我按了复位键,该值的确会更改为默认值,并且错误消息消失,但该字段的背景颜色仍然是红色,并且不会变回白色。 Anyone has an idea as to why? 有人知道为什么吗?

I did try using the update=":form" but doesn't seem to work and my page won't load. 我确实尝试过使用update =“:form”,但似乎无法正常工作,并且无法加载我的页面。

您应该看一下resetInput组件: http : //www.primefaces.org/showcase/ui/misc/resetInput.xhtml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM