There are some unhandled FacesMessages, this means not every FacesMessage had a chance to be rendered

前端 未结 1 1299
萌比男神i
萌比男神i 2020-12-19 17:58

I have a JSF 2.1 + PrimeFaces 3.3 page:


  

  

        
1条回答
  •  离开以前
    2020-12-19 18:28

    How do I show them in the page?

    You need to specify a valid client ID. The client ID is not the same as component ID. The client ID is whatever you see in the JSF-generated HTML output. Also, the client ID should be the one of the input component, not of the message component.

    So, given a

    
        
        
    
    

    the input component has the client ID particular:name1 (rightclick page in browser and do View Source to see it yourself). So, the message should be attached on exactly this client ID.

    context.addMessage("particular:name1", message);
    

    And, a second question, if I submit the form with three empty input fields, it shows "required input error message" in each associated with the . How do I show them in the ?

    The is not the valid component for that, you should use .

    
    

    The globalOnly="true" attribute means that only messages with a null client ID will be shown. So, you should just add exactly such a message.

    context.addMessage(null, message);
    

    See also:

    • How to use JSF h:messages better?
    • When and how is clientID generated in JSF?

    Unrelated to the concrete problem, the non-global messages ("Invalid name") which you're trying to add there should actually be done by a fullworthy validator. See also How to perform validation in JSF, how to create a custom validator in JSF for a concrete example.

    0 讨论(0)
提交回复
热议问题