组件不显示 validation/error 消息只是一个图标

Component doesn't show the validation/error message just an icon

我有一个带有验证器的自动完成功能。如果验证器失败,则不会显示错误消息。它仅显示在工具提示中。

<h:panelGroup styleClass="form-group">
                            <div class="col-md-3">                                  
                                    <p:outputLabel value="#{labels['product_console_ins_management_company']}"
                                        for="managementCompany" />
                                    <p:panel rendered="#{empty saveProduct.initShowId}" >
                                    <div class="form-control">
                                        <p:autoComplete id="managementCompany"
                                            required="true"
                                            requiredMessage="#{labels['product_console_ins_management_company_validation']}"
                                            value="#{saveProduct.product.company}"
                                            var="b" itemLabel="#{b.description}" itemValue="#{b}"
                                            completeMethod="#{saveProductConsoleController.completeInstrumentFactory}"
                                            process="@this" scrollHeight="300" forceSelection="true"
                                            converter="components.SimpleTypeBeanCollectionArrayConverter">
                                            <f:validator validatorId="managementCompanyValidator"/>
                                            <f:attribute name="boundList"
                                                value="#{domainData.instrumentFactoryList}" />                                              
                                        </p:autoComplete>
                                </div>
                                        </p:panel>
                                        <br />
                                    <p:outputLabel
                                        rendered="#{ not empty saveProduct.initShowId}"
                                        value="#{saveProduct.product.company.description}" />
                                    <p:message for="managementCompany" display="icon" />                                    
                            </div>
                        </h:panelGroup>

Screenshot of the problem

正是 告诉它做的,实际上你的问题与验证器或 p:autocomplete.

来自PrimeFaces documentation(阅读,使用,很有用)

Display Mode

Message component has three different display modes;

  • text : Only message text is displayed.
  • icon : Only message severity is displayed and message text is visible as a tooltip.
  • both (default) : Both icon and text are displayed.

这也可以在PrimeFaces showcase for the message(s) component

中看到

因此,如果您想要不同的行为,请选择不同的值('text' 或 'both')