Localize error messages thrown by a backing validation bean

My validation BEAN is as follows:
package oracle.fod.validator;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
import javax.faces.application.FacesMessage;
public class FileNameValidator {
public FileNameValidator() {
public void inputText_validator(FacesContext facesContext,
UIComponent uIComponent, Object object) {
FacesMessage fm = new FacesMessage();
fm.setDetail("Test");
ValidatorException ve = new ValidatorException(fm);
throw ve;
How can I externalize (potentially grabbing a value from a resource bundle) within the validation method?
I have resource bundles already configured for my static content and would like to reuse these if possible for error messages.

Hi Hamoncules,
You can try the following:
       public static String getLocalisedMessage(String messageKey){
                ResourceBundle bundle= ResourceBundle.getBundle("fully-qualified-name-of-the-resource-bundle-file",
                                                        ((UIViewRoot)FacesContext.getCurrentInstance().getViewRoot()).getLocale());
                            //Here 'fully-qualified-name-of-the-resource-bundle-file' can be com.company.product.module.ui.errorMessages
                            //which means the errorMessages .properties file is kept at the location
                           //com/company/product/module/ui directory under classpath,which ususally is under web-inf/classes;
                           //infact you can use multiple resource bundles by taking in  the bundle name as an argument to this method
                String message=null;
                if(bundle!=null){
                     try{
                            bundle.getString(messageKey);
                      }catch(MissingResourceException mre){
                           Logger.getLogger(this.class.getName()).log("Could not find message for the given key : " +messageKey, Level.FINE );
                 }else{
                          Logger.getLogger(this.class.getName()).log("Could not find resource bundle : " +
                                                  'fully-qualified-name-of-the-resource-bundle-file' , Level.SEVERE );
       //You can call this method from any of your backing beans by passing in the key of the message to get a localised valueRegards,
Samba

Similar Messages

  • Programatically change the error message thrown by ADF Method validator

    Can I change an error message being displayed by an ADF Method Validator?
    The message of the method validator can be specified declaratively using the Wizard. But is there anyway I can programatically change it inside the body of the method validator?
    Inside a method validator i will check for about 5 conditions and each condition will have a separate error message to reflect the error correctly. I can't use a single message declared by the wizard.
    regards,
    Anton

    Hi,
    I think you should look at the follow links, hope they can
    help you
    http://blogs.technet.com/b/nexthop/archive/2013/02/19/using-iis-arr-as-a-reverse-proxy-for-lync-server-2013.aspx
    #Troubleshooting a 404.13 issue using IIS and Failed Request Tracing logs
    http://blogs.msdn.com/b/amb/archive/2012/10/10/troubleshooting-a-404-13-issue-using-iis-and-failed-request-tracing-logs.aspx

  • I have OSX 10.7 Lion I set up a separate email account for my wife.  Now when she tries to enter a website we get the following error message:  Java Script: Not Null validator already loaded.  The website never opens and it is difficult to get out of:

    I have OSX 10.7 Lion.  I set up a separate email account for my wife.  All of a sudden when she tries to enter and website from email we get the following error message.  JavaScript;  The notnull validator has already been loaded.  From there we can't seem to go any where.  When you hit OK it just keeps appearing and the only way to get out of it is to quit Safai.  If you try and got directly to Safari you get the same error message and can't go any further.  Please help.

    What you are experiencing is 100% related to Malware.
    Sometimes a problem with Firefox may be a result of malware installed on your computer, that you may not be aware of.
    You can try these free programs to scan for malware, which work with your existing antivirus software:
    * [http://www.microsoft.com/security/scanner/default.aspx Microsoft Safety Scanner]
    * [http://www.malwarebytes.org/products/malwarebytes_free/ MalwareBytes' Anti-Malware]
    * [http://support.kaspersky.com/faq/?qid=208283363 TDSSKiller - AntiRootkit Utility]
    * [http://www.surfright.nl/en/hitmanpro/ Hitman Pro]
    * [http://www.eset.com/us/online-scanner/ ESET Online Scanner]
    [http://windows.microsoft.com/MSE Microsoft Security Essentials] is a good permanent antivirus for Windows 7/Vista/XP if you don't already have one.
    Further information can be found in the [[Troubleshoot Firefox issues caused by malware]] article.
    Did this fix your problems? Please report back to us!

  • TS1368 Error message tells me to reset password.  After resetting password I get confirmation email that new password is set.   As soon as I try to access App Store I get error message that password is not valid.

    Error message tells me to reset password.  After resetting password I get confirmation email that new password is set.   As soon as I try to access App Store I get error message that password is not valid.

    Try logging out of your account on the iPad by tapping on your id in Settings > Store and then log back in and see if it then works.

  • HT1766 At the end of a synch I am getting the following error message "iTunes could not back up the iPod because the backup could not be saved on the computer".  Any ideas on how to resolve?

    At the end of a synch I am getting the following error message "iTunes could not back up the iPod because the backup could not be saved on the computer".  Any ideas on how to resolve?

    See:
    iOS: Troubleshooting backup issues in iTunes
    Try going to iTunes>Preferences>Devices and delete the existing backup so iTunes creates an entire new one vice changing the existing one.

  • Error message when trying to back up iPhone in iTunes

    I am running the latest version of iTunes (12.1.2.27) on Windows. I have a iPhone 5s running iOS 8.3. When I connect my iPhone to my PC and select "Back up Now" under "Manually Backup and Restore" in iTunes it will start the backup but then come back and show the error message "iTunes could not back up the iPhone because an error occurred". It doesn't specify what that error is. I tried rebooting my PC and restarting my iPhone and reconnecting, but I am unable to backup my iPhone and keep getting the same error message. I suspect this might be an issue with with either iTunes 12.1.2.27 or iOS 8.3 as it started to happen after I updated both of them.  Anyone have any ideas?

    You can try going to iTunes with your device connected, select your device, then click view, show duplicate items

  • I am getting error message "iTunes could not back up the iPhone because the backup was corrupt or not compatible with the iPhone".  I have deleted the backup and restarted my computer, but continue to get this error message.  What do I need to do now?

    I have recently updated my phone and am attempting to sync it.  I got the error message "iTunes could not back up the iPhone because the backup was corrupt or not compatible with the iPhone".  I deleted the backup, restarted my computer, and even restored the iPhone, but continue to get the same error message.  What do I need to do now?

    iTunes places the iPhone backup in the following location. Navigate there & delete everything in the backup folder, but not the folder itself. You will have to turn on "Show All Hidden Files & Folders" to see it:
    Mac:~/Library/Application Support/MobileSync/Backup/
    Windows XP:\Documents and Settings\(username)\Application Data\Apple Computer\MobileSync\Backup\
    Windows Vista and Windows 7:\Users\(username)\AppData\Roaming\Apple Computer\MobileSync\Backup\

  • When I try and download app updates via wi-fi to my Ipad I get an error message "Your account is not valid for use in the Australian Store. You must switch to the US store before purchasing."  I am in the US how do I switch?

    When I try and download app updates via wi-fi to my Ipad I get an error message "Your account is not valid for use in the Australian store. Your must switch t the US store before purchasing. I am currently in the US on wi-fi. How do I switch

    Change App Store
    1. Tap "Settings"
    2. Tap "iTunes & App Stores"
    3. Tap on your Apple ID
    4.Tap "View Apple ID"
    5. Enter your user name and password.
    6. Tap "Country/Region."
    7. Tap "Change Country/Region"
    8. Select the country/region where you are located.
    9. Tap "Done".
    Note: If the change doesn't take effect, sign out of account and sign in again.

  • I want to backup my phone before upgrading to ios5 but I get an error message itunes could not back up the iphone because a session could not be started with the iphone. Please help me..

    I want to backup my phone before upgrading to ios5 but I get an error message: itunes could not back up the iphone because a session could not be started with the iphone. I want to go to ios5, but I do not want to lose everything. I've gone to my device under preferences and I have no backup currently.
    I have a Verizon Iphone 4 and a PC.
    Please help me..

    Hi Judy,
    Im using windows 7 and im not a computer wizard, i've tried the method by using the instruction for Win7 but it does not work, same problem still exist.
    Could uninstall itunes and reinstall it back on my pc fix my problem, please advise...... Many Thanks!
    VBR,
    ray

  • Private Browsing function is suddenly not working. Error message :"The URL is not valid and cannot be loaded." How can I repair?

    Private Browsing function is suddenly not working. Error message :"The URL is not valid and cannot be loaded."
    How can I fix it?

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes

  • I am getting this error message, " The URL is not valid and cannot be loaded" when I try to go to Firefox home. I have uninstalled add-ons, uninstaleed and reinstalled a fresh new firefox which did not help

    I am getting the following error message, " The URL is not valid and cannot be loaded" when I try to go to firefox home. I uninstalled add-ons , uninstalled Firefox and then installed a fresh version. Still have the problem.
    Thanks for the help

    That issue can be caused by a corrupted or incomplete Visual C++ installation (multiple versions can be installed side-by-side; SxS) that is missing some runtime components (Redistributable Packages) that Firefox depends on (problem with an embedded manifest file that specifies a specific runtime version).
    You need to install the missing components (e.g. VisualC++ 2005 Redistrbutable).
    * https://www.microsoft.com/download/en/details.aspx?id=5638
    *[[/questions/908165]] The URL is not valid and cannot be loaded
    *[https://bugzilla.mozilla.org/show_bug.cgi?id=713167 bug 713167] - Microsoft.VC80.CRT SideBySide errors, browsercomps.dll

  • HT201210 error message: itunes could not back up the iphone "..." because the backup session failed.  I don't know what to do to fix this problem?

    I keep receiving the error message: itunes could not back up the iphone "....." because the backup session failed.  Can anyone advise me on what I can try doing to fix this problem?

    This Apple article talks about backup issues -> iOS: Troubleshooting backup issues in iTunes
    Are you able to backup if you move the previous backup from the location below to the desktop?
    Windows XP: \Documents and Settings\(username)\Application Data\Apple Computer\MobileSync\Backup\
    Windows Vista and Windows 7: \Users\(username)\AppData\Roaming\Apple Computer\MobileSync\Backup\

  • I deleted the backup on itunes, synced again and got the error message: itunes could not back up the iphone because the backup was corrupt or not compatible with the iphone

    I am using iphone 3GS, after syncing for few times and got the errors. I deleted the backup from Edit-> Preferences-> Devices. Then I synced again,  there was an error message: itunes could not back up the iphone because the backup was corrupt or not compatible with the iphone. What can I do? I have no backup anymore on ituens.

    babesharon
    I closed iTunes & manually deleted the file which was still stored locally even though it didn't display in Preferences.  I have vista so I went to
    C:\Users\{user name}\AppData\Roaming\Apple Computer\MobileSync and deleted everything in the Backup folder (though I left the folder as is).  If you have a different OS search the apple website for the backup location.
    I reopened iTunes & Synced with out a problem.  I also got the update to install.
    Good luck.

  • I tried to update my iPhone4's, but get the following error message:   iTunes could not back up the iphone "iPhoneName" because the backup was corrupt or not compatible with the iphone. Delete the backup for this iphone, then try again.

    I tried to update my iPhone4's, but get the following error message:   iTunes could not back up the iphone "iPhoneName" because the backup was corrupt or not compatible with the iphone. Delete the backup for this iphone, then try again.

    The solution will be found here, select your computer type and software.
    http://support.apple.com/kb/TS2529

  • Error Message: iTunes could not back up the iPhone because an error occurred

    Error Message: iTunes could not back up the iPhone because an error occurred.
    The thing is - I have no idea what error have I encountered!
    Usually, I would assume the previous backup file is corrupted and I will proceed to delete the old backups. I did the same this time round, and it's still unable to sync. Now I have no more backup files!
    I have tried -
    1. Deleting old backup files.
    2. Restarting iPhone 4S & iMAC.
    3. Remove
    I am using iOS 5.1 on iPhone 4S, and iTunes 10.6.1 on Mac OSX Lion. My phone is not jail-broken in the first place.
    Does anyone face the same problem?
    I need to back up my files!!!

    Unfortunately, "because and error occured" doesn't give you much to go on.  Some general things I would try if you haven't already:
    Use Disk Utility on your mac to repair disk permissions, then reboot and try backing up again.
    Use Finder to go to ~/Library/Application Support/MobileSync/, then control-click on the Backup folder and select Get Info, then check Sharing & Permissions at the bottom and make sure your username has read & write priviledges
    Try closing all apps, then reset your phone: double-tap the home button, tap and hold the apps at the bottom until they wiggle, tap the minus sign on all apps to close them.  Then reset your phone: hold the on/off and home buttons until you see the Apple logo (ignore the off slider that appears first), and release
    Try a different usb to dock connector cable; ensure that your case isn't interfering with a good connection to the dock connector at the bottom of your phone; clean the dock connector at the bottom of your phone (e.g., with a dry toothbrush); troubleshoot your usb connection (http://support.apple.com/kb/TS1286)
    I know this looks like a laundry list, but unfortunately it's hard to isolate the problem without a clear error message.  If the problem persists, you might try posting in the iMac or iTunes forums for other ideas.

Maybe you are looking for