jsf - context.addMessage not working for a fileupload component -


i want display message in uploadlistner of fileupload component.how ever not displaying message @ all.below code snippet using.

     facescontext context = facescontext.getcurrentinstance();         facesmessage msg = new facesmessage(                 facesmessage.severity_error,                 "please remove special charecters file name.        ",                 "");         context.addmessage(null, msg); 

i tried same thing in p:commandbutton , working correctly. xhtml part of snippet.

you need declare <h:messages>, <p:messages> or <p:growl> component in view in order display messages. given you're using null client id in facescontext#addmessage(), intend display global message, in case add globalonly="true" attribute aforementioned message components filter global messages only.

further, if you're sending ajax request, should not forget ajax-update message component specifing client id of message component in update attribute of <p:fileupload>.

e.g.

<p:fileupload ... update="messages" /> ... <h:messages globalonly="true" /> 

or, if you're using primefaces equivalent, use autoupdate="true" instead:

<p:fileupload ... /> ... <p:messages globalonly="true" autoupdate="true" /> 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -