Message-bundle

Hello,
I have declared a message-bundle in my faces-config.xml :
<message-bundle>resource.messages</message-bundle>But if I want to use this one in my JSP file, I have to declare the following tag :
<f:loadbundle basename="resource.messages" var="bundle" />Isn't it possible to use the bundle declared in the faces-config.xml file without declaring a f:loadbundle tag in my JSP file ?
So, is it possible to declare the message-bundle in the faces-config.xml as :
<message-bundle id="bundle">resource.messages</message-bundle>...and use the #{bundle.key} in the JSP file ?
Could someone help me please ?
Thanks in advance.
bgOnline

I don't think you can automatically load message bundles into a JSP page without defining it with loadBundle.
As for localization, JSF allows you to specify a resource bundle in your faces-config.xml file. This will allow JSF to load the appropriate message bundles defined by the users browser. You still have to include it with loadBundle if you want to access it via JSP. JSF also allows you to mess with these resource bundles programatically.
Here's an example of the entry in your faces-config.xml file.
<faces-config>
     <application>
          <locale-config>
               <default-locale>en</default-locale>
               <supported-locale>de</supported-locale>
          </locale-config>
          <message-bundle>
               com.facesite.resource.MessageResources
          </message-bundle>
     </application>
</faces-config>This will tell JSF that MessageResources.properties is the en (English) locale and to load this by default but it also tells JSF that you have a MessageResources_de.properties file that supports the German language which would be specified by the browser.
Loading it into your JSP.
<f:loadBundle basename="com.facesite.resource.MessageResources"  var="msg"/>The MessageResources.properties file is in the standard java.util.Properties format.

Similar Messages

  • How do I use a bean to determine which message bundle value to use?

    Is there a way to use a bean to determine which message from my message bundle I use? I want to be able to call my bean in JSF/JSP page, have the bean return a String, and use that String to pick a message from my message bundle properties file. Now I can do this:
    <h:outputText value="#{bundle.messageA}" />or this:
    <h:outputText value="#{bean.messageName}" />where I have a method on the bean like this:
    public String getMessageName(){
         if(someTest == true){
              return "messageA";
         } else {
              return "messageB";
    }I want to combine the two so my bean determines which message I pick. I want to do this because I want to keep all the text a user sees in the message bundle file. However, based on the state of the bean, I want to display different messages.
    Thanks in advance,

    Ah this way. So you want that much of nasty if statements in the bean instead? ;)
    Then make use of the fact that you also can access Map values using the brace notation. E.g.
    <h:outputText value="#{bundle[bean.messageKey]}"/>Where getMessageKey() returns the message key, e.g. 'messageA' or 'messageB' and so on.

  • How to specify multiple message bundles in faces-config.xml

    Hi
    I have different properties file which I want to use as message bundle.
    Message.properties
    Help.properties
    When I specify this in faces-config.xml
    <application>
    <message-bundle>/Message</message-bundle>
    <message-bundle>/Help</message-bundle>
    </application>
    and now when I try to use that in my jsp page like this
    <f:loadBundle basename="/Message" var="message"/>
    <f:loadBundle basename="/Help" var="help"/>
    and access any messagestring from those files I can not excess either of them. But when I use only one of them it works fine.
    Am I doing something wrong or I can not do this thing at all??
    Thanks in advance.

    I only specify one properties file in the <application> tag. That one is used for system messages. I have other properties files for labels, and another for just standard app text, so in my faces-config.xml I have something like this:
    <application>
    <message-bundle>message</message-bundle>
    <locale-config>
    <default-locale>en</default-locale>
    </locale-config>
    </application>
    where my message.properties is used for system messages (validation, etc).
    I don't list the other property files there. I have two more that I use, labels_en.properties, and standard_en.properties. Labels are words that have a : at the end or a *: for required fields. Standard are just other words that I use in my application. So on every page that I have, I start out with the following header:
    <html>
    <f:view locale="en_US">
    <head>
    <f:loadBundle basename="label" var="label"/>
    <f:loadBundle basename="standard" var="standard"/>
    <title>
    .....

  • Message Bundling in BPM

    Hi All,
    I am trying to work on this Scenario for Message Bundling in BPM. The Scenario is i try to collect Idocs in BPM and after 3 IDocs from R/3, BPM will merge all the 3 into one message and send this message to a flat file.
    Now the problem is, though it shows Success message in SXMB_MONI, i dont get the output File.It doesnt even show the messages for my scenario in Runtime Workbench.
    Can somebody pl. guide me on this .
    Thanks,
    Ruchi

    Hi,
    I was trying to work on this Scenario for Message Bundling in BPM. The Scenario is i try to collect Idocs in BPM and after 3 IDocs from R/3, BPM will merge all the 3 into one message and send this message to a flat file.
    After checking it inot SXMB_MONI_BPE i could find out the error....
    <i>Bhavesh: Like you said there was an error in Variable assignment.</i>
    But now the problem is , of 3 messages i only get one record in the Output Response file....
    In SXMB_MONI , it shows <i>'Message is being sent'</i> for the other two.
    I checked the PE for that,it doesnt show any error in the Workflow log...but for the first message it shows the complete workflow and for the other two its showing in the processing mode..
    If anybody can guide me more on this..
    Thanks,
    Ruchi

  • Message bundles accessed from JSF and JSP pages

    Hello, everybody!
    I'm developing a localized JSF application. It is working pretty well until now.
    These are my message files:
    mensagens.properties
    mensagens_en_US.propertiesThis is how they're configured in faces-config.xml:
    <application>
        <resource-bundle>
            <base-name>br.urca.www.biblioteca.web.mensagens</base-name>
            <var>msg</var>
        </resource-bundle>
    </application>And this is how I access the messages in a page:
    <h:outputText value="#{msg.titulo}" />Nothing new until now. But now there was a need for me to have a raw jsp page in
    my web application. This page is displaying ok but I also need to access the
    message bundles as I'm able to access in the normal jsp with the JSF components.
    As you should know I can't use something like the above code with an +<h:outputText>+
    to access the messages because this is a JSF component and I'll not be able to use
    JSF components with this raw jsp page.
    So, my question is: how do I access my localized messages from a raw jsp page? I
    suppose there should be a way to do this, but unfortunately I started programming
    to the web world in Java with JSF, not JSP, so I don't know how to do this with
    JSP.
    Thank you very much.
    Marcos

    BalusC wrote:
    Just include [jstl-1.2.jar|https://maven-repository.dev.java.net/repository/jstl/jars/] in your classpath and define the fmt taglib in your JSP. Nothing more is needed.
    Hello, BalusC. Thank you for your help. We're almost there. After I have included the jstl-1.2.jar you provided me I can use the fmt tag and access message bundles from my raw jsp page (even though I had to provide other message bundles instead of the ones that I use in the other jsf pages, but it's better than nothing).
    Now there just on problem to be fixed. The jsp page is not aware when I change the locale of my application. I change this locale in a jsf page.
    I have this component:
    <h:selectOneMenu value="#{pesquisaAcervo.idiomaAplicacao}"
        valueChangeListener="# {pesquisaAcervo.idiomaAplicacaoMudado}" onchange="submit();">
        <f:selectItems value="#{pesquisaAcervo.idiomasAplicacao}" />
    </h:selectOneMenu>that calls this event in my backing bean class:
    public void idiomaAplicacaoMudado(ValueChangeEvent e)
        fIdiomaAplicacao.liberarItens();
        Idioma idioma = Idioma.deString(e.getNewValue().toString());
        // This line is for JSF
        FacesContext.getCurrentInstance().getViewRoot().setLocale(idioma.localidade());
        // This line is for Tiles
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().
            put(org.apache.tiles.locale.impl.DefaultLocaleResolver.LOCALE_KEY, idioma.localidade());
    }So, do I have to include another line in the idiomaAplicacaoMudado event above in order for the jsp page load the correct resource bundle? Or what else do I have to do?
    Thank you.
    Marcos

  • Argh! Message bundle file names are not allowed to have dots???

    It took me several hours to find the reason for this exception:
    java.util.MissingResourceException: Can't find bundle for base name properties\com.domain.prj.huj.MainApp.Messages, locale de_DE
         at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:804)
         at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:773)
         at java.util.ResourceBundle.getBundle(ResourceBundle.java:538)If the message bundle name contains dots (package separators), this exception is thrown! When I remove the dots, it works. But even the javadoc for ResourceBundle.getBundle() says that the baseName parameter is " the base name of the resource bundle, a fully qualified class name ".
    Is it not possible to have the message bundle file names containing dots (i.e. package declarations with class names)?

    Nope. Periods are used to delimit packages in the basename. So given:
    "com.domain.prj.huj.MainApp.Messages",
    ResourceBundle will look for "com/domain/prj/hui/MainApp/Message[_local][.class|.properties]" on the class path (ie, in jars etc).
    I've just had to implement an alternate RB factory to deal with legacy property files which contain periods. If you are starting from scratch, don't put in periods.

  • Message Bundle class not found

    Hello,
    i'm using JDev 10.1.3.3, and creating ADF BC application. When i've created the jspx page, went to it's Page Definition, and in Structure editor tried to add the Message Bundle file to this page - selected the "Generate Resource Bundle" from the context menu - i'm getting error "Class ...app_XXXPageDefMsgBundle not found" .
    Other pages in application got the same error.
    How can i solve this problem?

    And in the same time, Message Bundle classes for Entity Objects (XXXRowImplMsgBundle.java) are generating well, without any errors.

  • Message bundle Please help !

    Hey Im trying to make the message bundle
      <application>
            <message-bundle>webadmin.MyErrors</message-bundle>
        </application>I would like to make another file "MyErrors2 and have it switch based on a variable in the controller.. is that possible?

    You might be able to do it using the fact that ResourceBundles may be actual classes; i.e. they do not have to be properties files.
    But, I am inclined to ask what is the problem you are trying to solve? I suspect you may be down the wrong path. Be broad in your description of the problem.

  • Localized Data Model Message Bundle

    When you use the Validations in the Entity Objects of a data model and you place text for the text, errors, etc...it creates a MsgBundle for that class. Then for other languages you can create additional message bundle (e.g. MsgBundle_it, for italian) files for additional languages.
    My question is how does the data model layer find the locale for the user? So when it issues a data model validation error, how does it know to use the italian version instead of the default, english one?
    Also, I should add that I don't have access to the FacesContext and my Data Model project cannot be dependant on the ViewController object. So I cannot get the locale in the same fashion that I'm doing for my applications (i.e. get translated text for adf faces messages).
    Message was edited by:
    Kerri

    Hi Heri,
    the system behavior is correct. The account in company code consists of three entity types:
    1) COA - Chart of Accounts (Type 3)
    2) ACCOUNT - Account (A-Segment, related to ECC table SKA1, Type 1)
    3) ACCCCDET - Account in Company Code (B-Segment, releated to ECC table SKB1, Type 1).
    3) includes 1) and 2) whereas 2) includes 1). If you grant authorization only for 3) but not for 1) and 2), you cannot do anything.
    Best regards
    Michael

  • Message Bundle for Arabic Text

    Hi folks,
    I am trying to have a Arabic text in the message bundle properties file, however when i try to copy Arabic text, it shows up as junk characters.
    How do i go about resolving the same.
    Thanks.

    Got the solution,
    I was getting the above problem when i was trying to copy the Arabic text in the notepad; however I opened a plain text document in the eclipse and have copied the arabic code in it, and that worked. However we got to do a little change by modifying the properties of the file to have pointing to UTF-8 encoding.
    Thanks.

  • Message bundle always loading default bundle???

    I have propertly created message bundle properties file. But I have problem in situation when I use example:
    <h:commandLink value="#{bundle.sLogout}" styleClass="HeaderLoginText"
    action="#{page.logout}" rendered="#{page.logged}"/>
    in this case my application always first show values from default properties file, example from messages.properties. But this was happend only then I start page for first time, then I change language, example click on button which set viewRoot on some other language, application shows correct values.
    What can be problem?
    Thanks for any sugestion!

    I found a solution,
    I hope there is a better one,
    What i did is a got the source for ADF faces found the XML file where all the msgs are located (MessageBundle.xrts). Then using a tool that comes with the source files XRTSMakeBundle, I compiled the XML file, and it created java files with all the msgs. So I compiled them and replaced the classes in the ADF faces api jar.
    this seems like a long work around, in JSF RI, all you have to do is extend the key in the resource bundle and poof it works, I couldn't get that working here.
    This works, seems like a lot of work for a simple task!!!
    any other solutions out there????
    I am considering not to use ADF faces, i think i will use my faces with jsf-comp client java script, as that was one of the reason i wanted to use ADF faces.

  • Put several message-bundle in faces-config.xml

    Hello,
    I want to put several message bundle in faces-config.xml.
    How can I do that?
    I tried the following but it didn't worked
    <application>
         <locale-config>     
              <default-locale>fr</default-locale>
         </locale-config>
         <message-bundle>
              messages.Messages_fr
         </message-bundle>
         <message-bundle>
              messages.Messages_en
         </message-bundle>
    </application>

    the system will get automatically the right file depending on the Locale object , so you do not have to mention each file in the faces-config.xml
    <locale-config>
    <default-locale>fr</default-locale>
    <supported-locale>en</supported-locale>
    the supported locale is used by JSF when readind the HTTP header and depending on the language, it will choose the right mesages bundle
    The best way to process is to bind the locale property of the tag <f:view locale=#{Bean.locale}> and to change it dynamically (see class Locale in the sun API)

  • Problem with Message bundle using more than one project

    Hi:
    I'm not sure about if i'm doing something wrong or maybe could be a bug in JDeveloper 9.0.2....
    I have three projects: A Project_A with BC4J packages (controlling BC4J entitties, views and AM's. In order words, only controlling the business rules side); a Project_B with a JClient programs using the AM's defined in Project_A and; a Project_C with a JSP_UIX using the AM's defined in Project_A.
    Everything works fine....until i note Message bundle is not working in Project_B and Project_C (not show my customizing message errors), only works fine in Project_A (using the AM tester because i don't control the client side here).
    How can i solve the problem?
    Regards.
    Marco

    I have the same project structure.
    My purpose is to have a different message bundle for JClient app and Struts/ADF app.
    When I register following customized message bundle in the common model project:
    public class CustomBC4JExceptionBundle extends ListResourceBundle {
    private static final Object[][] sMessageStrings = new String[][] {
    { CSMessageBundle.EXC_VAL_ATTR_MANDATORY, "This field is required" },
    protected Object[][] getContents() {
    return sMessageStrings;
    I get the message in both JClient and Struts app.
    But when I register that bundle in the 2 "client" projects and remove this custom bundle from my model project.
    I get the original message in my Struts app and not the message above.
    Question howto set up a different customized bundle for JClient project and Web project based on same model project in same application?
    Thanks
    Fred

  • Assign message bundle jdeveloper oracle adf entity

    how do you assign a message bundle in jdeveloper 10g for an oracle adf entity

    When you open the entity dialog, select a attribute, open the control hints tab and add some labels, formats, tooltips, JDev creates a messagebundle for you in the common package. Same for the viewobject dialog.
    hth, Markus

  • Finding message bundle from custom tag

    I have a JSP page which has a <fmt:setBundle> to set the translations bundle. It also has a tag which I handle using a custom tag handler based on TagSupport. One of the attributes to this tag is a string which I need to look up in the message bundle, so I need to find the right message bundle as set at the top of the JSP page.
    So putting the question succinctly, how, from custom tag handler code, do I find the message bundle the page is using?

    So putting the question succinctly, how, from custom tag handler code, do I find the message bundle the page is using? To answer your question:
    The <fmt:setBundle> tag (according to the documentation:
    Creates an i18n localization context and stores it in the scoped variable or the
    javax.servlet.jsp.jstl.fmt.localizationContext configuration variableSo you can look up that configuration variable, and use its information to obtain the resource bundle name, or the Localization object which wraps the bundle.
    Of course, thats the hard way...
    You see the friendly folks who wrote the JSTL knew that there would be people who would want to do this.
    So they wrote a helper class for us: [javax.servlet.jsp.jstl.fmt.LocaleSupport|http://java.sun.com/products/jsp/jstl/1.1/docs/api/javax/servlet/jsp/jstl/fmt/LocaleSupport.html]
    A better question is actually:
    How do I look up a message in the bundle set by JSTL <fmt:setBundle> when I am in a custom tag handler?The answer is:
    LocaleSupport.getLocalizedMessage(pageContext, key)Its all in their (relatively readable) [JSTL specification|http://java.sun.com/products/jsp/jstl/reference/api/index.html]
    cheers,
    evnafets

Maybe you are looking for

  • IPod touch 2nd Gen 8gb will no longer Sync photos.

    all the posts I could find that were similar had to do with ipods that were jailbroken and on Windows. I have iTunes 10.1, iPhoto 6.0.6. running on OSX 10.6.5 iPod Touch 2nd Gen 8GB OS 4.2.1 The Problem: Since I got 4.0 and later, I have not been abl

  • My computer doesn't recognize my "used" ipod shuffle

    How do I get my computer to recognize my "used" ipod shuffle?

  • Managing IPhoto Library

    Mac Pro HD A is maxed out with 79 gb of pics.  Moved the iPhoto library file to HD B.  Took days to copy.  Trashed the A library file.  When I try to open iPhoto I get: "Check with the developer to make sure iPhoto works with this version of MacOS X.

  • Categories in Address Book

    I am trying to create categories in Address Book. I found this helpful hint in support: http://docs.info.apple.com/article.html?path=AppleScript/2.1/en/as2029.html When I go to the folder where the plug in is supposed to be it is empty Library/Addres

  • Dynamic deeplinking?

    Hi Everyone.                        please Explain about dynamic deeplinking concept and give source.Thanks in advance........