JSF error messages

has anybody successful using JSF error messages. Im using JSF portlet framework to display error msgs using h:messages tag. Im able to display validation/conversion errors with h:message tag.
Im unable to display general messages that are result of an application exception. Has anybody ever done that?
Help would be appreciated.
Thanks
-Sri

If I understand you correctly ...
FacesContext context = FacesContext.getCurrentInstance();
FacesMessage message = new FacesMessage("New Message");
context.addMessage(null, message);

Similar Messages

  • JSF: Error Message are not getting cleared

    Hi,
    I am facing some problem with error messages in JSF.
    Here is what I am doing
    1. User submits a form, server validates and sends back the error to the client error message added to Faces Context.
    2. User checks the messages, changes the input and submits. assuming everything is correct now.
    3. On server, it validates and writes data to response for download using the following code.
    FacesContext faces = FacesContext.getCurrentInstance();
        HttpServletResponse response = (HttpServletResponse)faces.getExternalContext().getResponse();
        DownloadResponse.sendDownload( response, is, fileName );
        faces.responseComplete();
      }4. It shows the download popup to download the file. The problem here is that error message are not getting cleared off. User can still see the error message on the screen.
    It seems I am missing something in JSF req-response life cycle. Anyone please point out the mistake.

    SudhirMongia wrote:
    4. It shows the download popup to download the file. The problem here is that error message are not getting cleared off. User can still see the error message on the screen. Wrong. The problem is that the view is not rerendered, which makes sense because you are not sending view content to the browser but your file.
    Your real question probably is: how do I cause a file download and still rerender the view afterwards to show the results? To that I myself do not have the answer unfortunately, but I have seen that question come by a few times already, so doing some searches in these forums may yield you an answer.

  • JSF error message - retain ?

    HI all,
    i am using jsf <h:messages />. its getting cleared, if i click a commandlink which shows a popup div. That popup div is rendered in a bean.
    How to retain the error messages after getting the response.
    Samething happened when i change a select option which processes in valueChangeListener. After Changes made in Select option (getting the response) how to retain the error message ?
    Help me. Thanks in advance.
    Srinivas.R

    Thanks for ur replies.
    i am using tomahawk div (t:div) to show a
    small popup div when the user clicks a link. for
    changing Serial id (for my application) which calls
    backing bean for rendering & perform action
    regarding.
    Also when the Country select option changed, i
    am populating relavant state list in another select
    component, its internally calling backing bean. this
    also clears the error messages.
    How to retain the error messages without changing
    this business.At this point you are pretty much outside the regular functionality provided by JSF. I still think the best approach will be to eliminate the reloading of the page. You could accomplish this via AJAX. There are a few libraries out there for using AJAX with JSF; ajax4jsf for sure and I think JBoss Seam, RichFaces, ICEFaces, Trinidad and I'm sure I missed some.

  • JSF Error Message Parameters

    Hi ,
    I am displaying a customized error message by passing parameters . In the reources bundle , I have
    javax.faces.component.UIInput.REQUIRED={0} is required
    JSP has
    <h:inputText styleClass="inputText" id="firstName" value="#{bean.firstName}"
    required="true"></h:inputText>
    <h:message styleClass="error_text" id="message1" for="firstName"> </h:message>
    This is outputting "{0} is required" whereas I would expect to display "FirstName is required".

    Default javax.faces.component.UIInput.REQUIRED has no parameters. Default 'required' validator (inside the UIInput) does not replace any parameters, just because it is designed to use message that has no parameters.
    If you redefine the javax.faces.component.UIInput.REQUIRED and add any parameters to there it does not make any sense because the default validator still does not replace anything (as designed).
    So, if you want to have a parameter replaced you have to write your own custom validator.
    As an alternative, you can use the approach shown at:
    http://www.oracle.com/technology/pub/articles/masterj2ee/j2ee_wk7.html
    Sergey: jsfTutorials.net

  • JSF error message: Automatic prompting for file download

    This is a weird problem. I have a JSF application wherin I popup a new window on a submit button.
    The window opens a test.jsf page that redirects the output to a servlet1.
    Servlet then based on some parameters does a sendRedirectI() to different servlets out of context.
    Now the issue is that when the output is redirected to out of context servlet, that returns a file download.
    If in IE browser, if one does not do a setting of "Automatic prompting for file download", this window that I had opened on submit buttton vanishes in a jiffy. If the IE setting is done, it shows the file download correctly.
    I would want to show the user some kind of message by which he/she understands that this IE setting has to be done.
    I have tried several ways:
    1. Javascript: window.onbeforeunload on the test.jsf so that when the window unloads i can show some message. But since test.jsf forwards to servlet1, the html page generated does not show my script.
    2. I also tried checking if some windows registry can help me understand the setting.
    3. I tried writing in response object the javascript and then redirecting it to servlet out of context. But I guess sendRedirect() does a new request, so this did not help.
    Can anyone help? I am not sure if I am able to explain my problem correctly.
    Yani

    Here is the result.I used your code and it worked fine with IE setting Enabled. But when I tried to access the download servlet after opening a new window, it doesnt download the file.

  • JSF Error Message not displaying/popping up in clickToEdit table

    I have an entity object validation rule which displays a message when the validation fails. I have set the Validation Failure Severity as an Informational Warning. I do want to user to continue if he is happy to do so. Everything works fine when testing in the model project.
    Now, in the ViewController project when I add the View Object to a page as a af:table component the Warning message only comes up if the tables Behavior/EditingMode property is equal to editAll AND if the inputText Behavior/AutoSubmit property is false. It actually seems like this is the only time the validation is performed…
    If I change the tables Behavior/EditingMode property to be clickToEdit the warning message does not come up anymore?
    If I change the inputText Behavior/AutoSubmit property equal to true, then the warning messagewill not come up in ether of the editAll or clickToEdit table. A orange border will be displayed in the editAll table, but no message?
    What is the difference, and how can I get the warning message to be displayed when the table is clickToEdit table?
    I am using JDeveloper 11.1.1.3 PS2
    Thanks

    Hi
    Just to mention. It seems this issue was a bug in 11.1.1.3, and it is fixed in 11.1.1.4...
    I still don't know how to get around the problem in 11.1.1.3, but atleast it is working in the latest version.

  • Customising Error Messages in JHeadstart

    Hi All,
    I would like to customise some ADF JSF error message. I've got the error - JBO-25013: Too many objects match the primary key oracle.jbo.Key[ASGARD CBD ]. but would like to replace it with "Row already exists with same Cmp Id,Cmp Tran Type".
    I've followed the steps outlined in http://download-west.oracle.com/docs/html/B25947_01/bcadvgen008.htm#sm0462 and after recompilation and reganeration, the old error message still appears. Can you guys please help me with it? Thank you and have a nice day.
    Kind Regards,
    John

    Hi,
    Thank you for your reply but I'm a bit confused here.
    First, when you say 'open your JHS-Application definition generator' do you actually mean JHS Application Definition Editor (JADE)?
    Under the service node? I cannot see any 'service node' anywhere inside JADE. But I can see 'NLS Resource Bundle *' with the value of 'PAM0840_From_Designer.view.ApplicationResources'.
    Go to the above path? What above path do you mean?
    Uncheck OVERRIDE NLS entries? Do you mean uncheck the 'Override NLS Resource Bundle Entries?*' inside JADE under the 'Internationalization' section?
    Thank you for your advice.
    Kind Regards,
    John

  • ADF-BC/JSF How to display acustom error message from a backing bean

    Hi all
    Can anybody provide an example of how to manipulate the list of error messages from a JSF backing bean.
    In my code I use a different navigation case and this directs the user to the page displaying the error message but I am sure that there must be a more elegant way.
    Thanks in advance
    Thanassis

    Thanks Kris
    I think you 've put me on the right track here, it's just that in my case what I really want to do is prevent my users from editing records not belonging to their own group. This is done via a selectOne table component and then the backing bean code tests if the value #{row.UserGroup} matches the #{bindings.LoggedOnUserGroup.inputValue}. If the values are equal then the beans returns the navigation case to the edit page. Otherwise it returns the navigation case for the "cannot edit" page.
    So what I am thinking is to return null and somehow raise the right kind of exception in order to display the error in the af:messages tag.
    Thanassis

  • Validation error message in JSF 1.2

    I am testing my Web application inside Tomcat 6.0.2 and using JSF 1.2. I was surprised to see that validation error messages do not only display the custom error message, but also the id tag and a "Validation Error: " text. For instance, if an input text component has the required property set to true and the user does not fill in value, the following error message will be displayed on page submiision: "hello:test: Validation Error: Value is required." instead of just "Value is required.". I am wondering if there is a way to silence the id tag and the "Validation Error: " text. hello:test id tag reflects the fact that the form has an id of "hello" and the input text component an id equal to "test".

    Hello
    I'm quite new to this technology. Would like to know how can we replace the 'annoying component id' with label while generationg validation/conversion error message.
    E.g:
    'for:compID' some error message
    must be formated as
    'compLabel' some error message
    I happened to know that this feature is supported in JSF 1.2 impl. But didn't work for me with Sun RI.Can any body give me some sample code snippet for the same
    Thanks
    Jobinesh

  • Error message when trying to excute jsf examples or my own code

    Hi, Any help would be deeply appreciated. I am trying to run code I've written to test jsf on WSAD and am getting the following runtime error when I deploy to the test environment. I get this error message even when I try to run the examples supplied with the EA3 version of JSF (when I import the source into my java source folder and compile (rather than using the precompiled imported classes).
    [4/25/03 11:09:29:170 EDT] 5d874f9b WebGroup E SRVE0026E: [Servlet Error]-[Cannot find FacesContext]: javax.servlet.jsp.JspException: Cannot find FacesContext
         at javax.faces.webapp.FacesTag.doStartTag(FacesTag.java:209)
         at org.apache.jsp._Input._jspService(_Input.java:147)
         at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
    <CUT REMAINDER OF ERROR MESSAGE>
    Thanks in advance for your help,
    sanjay

    Hi,
    I also received a message like you. In my case I forgot to redirect the
    user to a address which contains /faces/ part. Like that
    http://localhost:8080/ims/faces/newinventory.jsp
    Also You have to check your web.xml file. These lines have to be there.
    - <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    - <!-- Faces Servlet Mapping
    -->
    - <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    Omer

  • Custom error messages impossible with jsf ea4??

    Hello,
    Does jsf allow custom error messages for built-in validators?
    I was told by a member of the jsf team that what is described in the tutorial applies only to future versions of jsf.
    Is this a bug? If it isn't and if it is indeed possible to have your own error messages for built-in validators, I would be grateful for someone of the jsf team to help me.
    I have already posted some messages asking for help but I never got any answer.
    Julien

    If a validator wants to add an error message to the current page, it has to call FacesContext.addMessage() with a javax.faces.application.Message argument. The design intent is that you can look up localized messages (defined in the config file) via MessageResources -- that's the part that does not work right now.
    In the interim, though, you can construct your own Message instances by leveraging the MessageImpl class:
    context.addMessage
    (new MessageImpl(Message.SEVERITY_ERROR,
    "You goofed",
    "Here are the gory details..."));
    or look up the message strings from a resource bundle.
    Craig

  • Trying to display an error message on my JSF page

    Hi,
    I'm very new to JSF and hopefully this will be easy to answer. I'm trying to display an error message when a user fails to login correctly. I have this on my login page:
    <h:message for="userid" id="inputError"></h:message>
    and in the login bean that handles the login, I invoke this method when the login fails, passing in the appropriate error string
         private void setError(String error) {
              FacesContext ctx = FacesContext.getCurrentInstance();
              FacesMessage fm = new FacesMessage();
              fm.setSeverity(FacesMessage.SEVERITY_ERROR);
              fm.setSummary(error);
              fm.setDetail("ERROR: " + error);          
              ctx.addMessage("userid", fm);
    But the error is not displaying upon a failed login and so I'm wondering if there is something more I need to do. Your help is appreciated, - Dave

    To get the "real" client id use
    ctx.addMessage(myComponent.getClientId(ctx), fm);and bind the userid input text to your backbean
    view code:
    <input binding="#{bean.myComponent}" ...backbean code:
    private UIInput myComponent;
    // getter/setter
    public UIInput getMyComponent() { return this.myComponent; }
    public void setMyComponent(UIInput myComponent) {
        this.myComponent = myComponent;
    }I hope this helps...

  • Problem overriding default JSF conversion error messages

    Hello !
    I have a problem to override default JSF conversation error message. I have an inputText which is binded to BigDecimal attribute, so when I enter a character in that field I get this error message: "- Conversion failed."
    I think I need to register the message bundle in my faces config, and put the key of this error message to my properties file.. am I right ?
    Can somebody help me with this ? Which key I need to put into the properties file ?
    Miljan

    Get [Sun's Java EE tutorial |https://www.sun.com/offers/details/JavaEETutorial.xml?cid=20090723ZA_TACO_JVEE_0004] and read the relevant section so you don't have to guess what you need to do.

  • How to erase error message in jsf with facelets

    hi,
    I am using jsf 1.2 with facelets. we provided on required validation for menu in a page .if i click submit button with out giving required value, then corresponding message is showing.but after giving that required value that error message is not erasing from that page.
    but in my requirement when ever i gave that required value immedialty i want to erase that messge.
    In the following codec i click on submit button without selecting Bank , then it will display error message like Select Bank .after that i selected bank but that message is not removing.
    so could any body suggest me where i did mistake and how to do for that requirement..... please hint me
    mypage.xhtml
    <h:selectOneMenu  id="dropDownBanksName"  value="#{cardPrintBean.bankId}"
                                         required="true"  requiredMessage=" * Select Bank " title="select bank"
                                         valueChangeListener="#{cardPrintBean.valueChange}">
                                            <f:selectItems value="#{cardPrintBean.banks}" noSelectionLabel="Please select"/>
                                       </h:selectOneMenu>          
                                       <h:message for="dropDownBanksName" errorStyle="color:red" />can any one please help me........
    thanks in advance

    gbabu wrote:
    I think by using javascript with DOM we can put alert's boxes .Uh, think?
    I wasn't talking about alerts. Alerts also have nothing to do with DOM.
    but how to erase that error message of JSF in XHTML pageI already answered that. If you just want plain code, you're here at the wrong place.
    Better learn Javascript and HTML DOM. w3schools has nice tutorials about that.
    [http://www.w3schools.com/JS/default.asp]
    [http://www.w3schools.com/HTMLDOM/default.asp]

  • JSF 1.1 Error Messages

    is there any way to sort the facesmessages appended to the facesContext ?

    Hello
    I'm quite new to this technology. Would like to know how can we replace the 'annoying component id' with label while generationg validation/conversion error message.
    E.g:
    'for:compID' some error message
    must be formated as
    'compLabel' some error message
    I happened to know that this feature is supported in JSF 1.2 impl. But didn't work for me with Sun RI.Can any body give me some sample code snippet for the same
    Thanks
    Jobinesh

Maybe you are looking for