Passing resource bundle key to outputText i18n

I have a dataTable with an outputText, the dataTable variable has a property which returns a resource bundle key. The following is what I am doing:
<h:dataTable
     id="menu"
     value="#{myBean.rowItems}"
     var="row">
     <h:column>
          <h:outputLink value="#{row.link}">
               <h:outputText value="#{bundle ['row.messageKey']}" />
          </h:outputLink>
     </h:column>     
</h:dataTable>Of course, this doesn't work, because it looks for 'row.messageKey' in the resource bundle, instead I want it to resolve the row.messageKey expression and then look up the result in the resource bundle.
What syntax must I use to acheive this?

It was so obvious.....
<h:outputText value="#{msg [row.messageKey]}" />Sorry for the noise...

Similar Messages

  • Concat Strings to create a Resource Bundle KEY

    Hello, I`m having a little problem. I need, at the same point o a JSF page to show 2 different messages depending on a String variable value inside a Bean.
    Then I was thinking if a could have the 2 different keys for the 2 different messages written in the bundle file, but the first part of the key would be the same, then the second would be equal to the String variable in the bean, so I would need to do a concatenation to get the correct KEY and then retrieve the correct message. Is that possible? If so, how could I do that?
    So far, I have tried: But none worked
    #{messages[''+'']}
    #{messages[''] + messages['']}

    The + is an arithmetic operator, not string-concatenation -- if you apply it to strings, the EL will attempt to coerce them to numeric values in order to apply the '+'.
    There are some string manipulation functions in the JSTL standard function library. "str-concat" is not one of them, but there is a "replace" function.
    Assuming your resource bundle is called 'messages' and the key suffix is in a bean called 'keysuffix', you could try something like this:
    #{message[fn:replace('blah.blah.SUFFIX', 'SUFFIX', keysuffix)]}

  • Sometimes can't find resource bundle key Tomcat1.3

    I have run into this problem twice now. It appears to happen after I call an update jsp and then forward after the update to another page. The update page does not have any resource bundle information, the calling page does and the page I forward (<jsp:forward page="mgrusereditor.jsp?frmMessage=U" />) to does. It only happens in specific instances and is the exception. A few of the keys show, then it cannot find the next one and generates an error. In the latest instance, about ten keys work and the eleventh does not work.
    There are about 400+ keys now and it will grow to over 1000 keys by the time this project is finished.
    The error is consistent in terms of where it happens and which key is not found. If I eliminate this key reference, sometimes the next key may have the probelm as in the current problem, sometimes a key a few down has the problem.
    The update jsp has a number of conditionals which forward differently, depending on the status of two variables. I have checked the condiditonals thinking that I may be not getting out of the page after the forward, but it appears that every forward, is the end of the executed code for the update page - although I am running a new test on the logic to ensure this (I have walked through it manually, counted the brackets, removed pieces of it, now I will try a more exhaustive test of the logic).
    Any ideas.

    I'm no JSP expert...but could this be related to page buffer size? If you increase the buffer size, what happens?
    You might want to post this over on the JavaServer Pages forum as well.
    Trying to be helpful despite lack of knowledge,
    John O'Conner

  • Jheadstart oes not generate NLS key in resource bundle for Static domains

    Hello
    according to jhsdevguide1013 on section 6.5.2 about "Translation of static domains" when I check "Generate NLS-enabled prompts and tabs" and run application generator , Jheadstart oes not generate NLS key in resource bundle for Static domains.
    Does anybody can help us for this problem?

    Thank you for reporting this, I have logged it as a bug.
    As a workaround, you can customize the Generator Template default/item/staticDomainOptions.vm
    See http://blogs.oracle.com/jheadstart/2006/11/30#a108 for an example how to let a template generate extra resource bundle keys.
    Hope this helps,
    Sandra Muller
    JHeadstart Team
    Oracle Consulting

  • Problem with resource bundle messages written inside script of jsf included

    Hi,
    I have a main jsf page with the name Details.jsp.In this page I included Contacts jsf page.I am using resouce bundle for my application.I written all the output text tags with this resouce bundle keys.And I written the Details main page javascript alerts with this resource bundle correctly.But the problem is,I am having script alrts in my included jsf apge i.e. in Contacts page.When I write the script alerts with the resource bundle keys,it is not displaying properly.
    ---------------------------------------------------------------------Details.jsp--------------------------------------
    <f:loadBundle basename="Details_en" var="msg"/>
    <f:view>
    <head>
    <script>
    function saveFn()
    var d=document.getElementById('dform:dinputtext').value;
    if(d=='')
    alert('<h:outputText value="#{msg.requiredValidationMsgkey}"/>');
    return false;
    if(emailValidation()==false)
    return false;
    </script>
    </head>
    <body>
    <h:form id="dform">
    <h:outputText value="#{msg.nameHeader}"/>
    <h:inputText value="#{Bean.name}" id="dinputtext"/>
    <jsp:include page="/Contacts.jsp"/>
    <h:commandButton value="Save" onclick="if(saveFn()==false) return false;" action="#{Bean.saveAction}"/>
    </h:form>
    </body>
    </f:view>
    -------------------------------------------------Contacts.jsp----------------------------------------
    <script>
    function emailValidation()
    var em= document.getElementById('dform:cSubView:cemailtext').value;
    if(em=='')
    alert('<h:outputText value="#{msg.emailValidationMsgKey}"/>');
    return false;
    </script>
    <f:subview id="cSubView">
    <h:inputText value="#{CBean.email}" id="cemailtext" />
    </f:subview>
    The alert message in SaveFn is getting appeared coorectly.But in the function emailValidation is not geting dispalyed correctly.It is appearing as normat output text in the page,but not as an alert.

    Thanks for the reply.
    But I want to do some validations using javascript not only the required validation.
    In my application 5 text fields and one command button are there .Depending upon combination of 2 or 3 text field values, I have to get the values when I pressed command button.
    If I use the h:messages for validators,the conversion error is occurring when the text field takes wrong data.So it is going to give incorrect results when I press the command button.Thats why I am using javascript.
    When user enters wrong data,I want to do validation using javascript and I want to display the alert message using resource bundle.

  • How to load the resource bundle message on confirmation popup

    hi every one
    i am using java script confirmation message on my delete button.
    this is my sample for that one
    <h:commandButton action="#{createCurrency.removeCurrency}"
             onclick="if (!confirm('Are you sure to delete this value?')) return false" value="#{messages.Delete}"/>    i need to load the "Are you sure to delete this value?" from resource bundle.
    is there any way to load above message from resource bundle.
    thiagu.m

    If you're using JSF 1.2, you can add the bundle config in your faces-config.xml file like this:
    <resource-bundle>
       <base-name>mypackage.i18n.MessageResources</base-name> // i18n is shorthand for internationalization
       <var>msg</var>
    </resource-bundle>     
    <locale-config>           
       <default-locale>en</default-locale>  // or whatever locale you preferred 
       <supported-locale>...</supported-locale> // other locale defined here if you need them
    </locale-config>Then create a property file called "MessageResources_en.properties. In this file, you can define something like:
    {code}
    MSG_CONFIRM=Do you wish to delete this value?
    // add other messages here. Syntax is: key=value
    {code}
    Then reference the bundle's message in your form as per normal:
    {code}
    !confirm(#{msg.MSG_CONFIRM}))
    {code}
    I haven't tried the above codes but it should help you get started.
    Edited by: icepax on 13/11/2009 19:44

  • How to enumerate keys in Resource Bundle?

    Is there any way to enumerate all the keys (but not the values) of resource bundle?

    If rb is a ResourceBundle, you can enumerate the keys and values in its 'content' property with the following code:
    for (var key:String in rb.content)
        var value:* = rb.content[key];
    Gordon Smith
    Adobe Flex SDK Team

  • Passing param to resource bundle in jsf

    I have a commandButton with a label which I have defined in a resource bundle. How can I pass parameter to the text in resource bundle. I searched on Google to find that use <h:outputFormat> but how can I use it with the af:commandButton? Or is there any other way?

    Hi,
    Maybe this will help you :-
    http://www.ultrashock.com/forums/actionscript/as3-adding-parameter-to-eventlistener-104729 .html
    http://www.orlandmedia.com/blog/actionscript-3/passing-parameters-to-a-mouseevent-listener /

  • I18n - Resource Bundle Bugs ??

    I have a string in a resource bundle containing HTML tags such as <BR> etc.
    The string is displayed in a static text component. The escape property of this component is set. Nevertheless all HTML tags are displayed as text!
    Is this a bug??
    Tom

    Got it! Escape must NOT be checked to let the browser
    correctly display it.
    TomCan you elaborate and give example of your resoruce bundle
    related to this posting, and so we can see if the resource
    bundle handling or features might be improved or providing addtional
    information on how to use them ?
    Thanks

  • How to put a javascript  variable containg the i18n key  in the i18n tag

    I have a list of values in a List box.when the user selects a praticular value.,i need to show the java script localized alert message for the selected value.
    how can i pass the javascript variable to i18n tag.
    For ex:
    function test(){
    var selectedvalue='name';
    var localizedstring='<i18n:message key="+selectedvalue+"/>';--This is not working
    alert('<i18n:message key="+selectedvalue+"/>');
    the alert message is a blank string,even though i have the key in my resource bundle.
    Also..if i give directly pass the key value to i18n string it works. like..
    var localizedstring='<i18n:message key="+name+"/>';--This is  working
    *(am passing the variable value)*

    The following should be able to pass ans.
    <script language="Javascript">
    function check_answer(ans) {
    if (testing.result.value==ans ){
    window.alert("You have got 10 marks.");
    </script>
    <body>
    <form name="testing"...>
    <%
    ResultSet rs = stmt.executeQuery("select * from level where...");
    while(rs.next())
    out.println("<tr>");
    out.println("<td>" + rs.getString("question") + "</td>");
    ans = rs.getString("answer");
    out.println("</tr>");
    out.println("<input type='text' name='result'>);
    out.println("<input type='button' value='Enter' onclick='check_answer('<%= ans%>')'>");
    %>jag

  • Resource bundle in content repository

    Hi,
    We have a weblogic portal application. Client wants the flexibility to be able to change the text (labels, paragraphs) without any help from IT i.e no releases or redeployment should be required.
    For static pages htmls have been moved to content repository and that helps.
    However for multilingual jsp labels, headers etc. should we add the resource bundle files(.properties files) to content repository?
    Please suggest. We are using netui tags in UI.

    What are you using to show the message i18n or JSTL? i18n tag libraries have a timed technique of reload. ResourceBundles cant be reloaded (directly). search for a snippet on the web which shows how to reload ResourceBundles.
    should we add the resource bundle files(.properties files) to content repository?So long as you have a way to push the files to all managed servers , store it wherever you want.
    While this is an idealistic scenario of business can update all content consider what happens when a business user changes the key by mistake, makes a formatting error etc that can potentially break your page.

  • How to merge two resource bundle values ?

    Hi All,
    JDev ver : 11.1.1.7
    I want to merge two resource bundle values.. How to do it ?
    like this #{expr ? str1 : str1 + str2}
    I tried like the one below and used some jstl fuctions... but no use not worked.. got some parse exception, compilation exception,etc..
      <af:outputText value="#{ row.accountName eq 'AccountName9' ? resource['LBL_WELC'] : resource['LBL_WELC'] + resource['LBL_HOME'] }"/>
    Let me know how to do this ?
    Regards,
    Gopi

    The above outputtext is an example, I may use diff bundle keys like below,
    <af:outputText value="#{ row.accountName eq 'AccountName9' ? resource['LBL_TEST'] : resource['LBL_KEY1'] + resource['LBL_KEY2'] }"/>
    The principle is the same
    <af:outputText value="#{ row.accountName eq 'AccountName9' ? resource['LBL_TEST'] : '' }#{ row.accountName eq 'AccountName9' ? '' : resource['LBL_KEY1'] }#{ row.accountName eq 'AccountName9' ? '' : resource['LBL_KEY2'] }"/>
    Dario

  • Using resource bundler with a specific encoding type

    Hi All,
    Using resource bundler class in Java one can pass the key and get the appropriate string value for that in appropriate language. These strings can be stored in a class (BuldlerList) or in some file.
    My doubt is can I specify the encoding type of the string while passing the key ?
    This might be needed in a case like follows. Say I have a Java Swing application for which I want to get the labels in appropriate language. The application is Windows based. The methods in resource buldler class while getting the string value for a key uses platform's default encoding type. So if I store my file containing all the resource bundler in UTF-8 I can't read them properly from an Windows 2000 system having Japanese as the locale. The constraint is that you can never make Windows default platform encoding as UTF-8 (or something equivalent for Unicode). In that case one cannot developed a truly internationalised application in this frame work.
    Any comments/suggestion/input will be highly appreciated.
    Thanks,
    Sourav

    I dunno 'bout the bundles BUT u can possiblly use XML
    instead.
    u can have a attribute type that specifies the encoding
    type for the content. This will be a totally application
    specific approach BUT it will work.. that much I am sure
    of. IF u read this attribute in your application first and
    then read the value, in that pre-specified encoding, ur
    problem could be solved.
    Just like resource bundles, XML files will be stored in
    local machines only. The only thing is u need a
    JAXP API for processing them.
    aXe!

  • How to use xliff as resource bundle ?

    I used to do Java i18n as following base on resource bundle in properties file format:
    Locale myLocale = new Locale("es", "ES");
    ResourceBundle bundle = ResourceBundle.getBundle("HelloResourceBundle", myLocale);
    System.out.println(bundle.getString("Hello"));I realized that there is new bundle called xliff like:
    <trans-unit id="Hello">
    <source>Hello how are you</source>
    <note>This is message to say hello</note>
    </trans-unit>Does java resource bundle support xliff file similar to properties file? if not, could anybody give an example how to handle xliff file?
    Thanks

    Following code worked for me:
    import oracle.javatools.resourcebundle.BundleFactory;
    import java.util.ResourceBundle;
    * This method retrieves localized strings from a given XLIF resource bundle.
    * @param bundleName The XLIF bundle from which the localized string is to be retrieved.
    * @param key The key of the localized string.
    * @return The localized string retrieved from the given XLIF bundle.
    public static String getXlifLocalizedString(String bundleName, String key) {
    if (StringUtils.isEmpty(key)) {
    return key;
    if (StringUtils.isEmpty(bundleName)) {
    return "[" + key + "]";
    String localizedString = null;
    ResourceBundle resourceBundle = null;
    try {
    resourceBundle = BundleFactory.getBundle(bundleName);
    localizedString = resourceBundle.getString(key);
    } catch (Exception e) {
    LOG.log(Level.SEVERE, "Problem in loading XLIF resource bundle: " + bundleName, e);
    return "[" + key + "]";
    return localizedString;
    }

  • How to compare and edit Resource bundle file using java programe

    Hi All
    I have two resource bundle with key, value and some comments. I need to write a java code to compare both of the values of the keys and if the values are different then i want to replace the second value with the first value.
    Its a programe which will udpate the second file with the first file values.
    I tried using Properties class but it didnt worked because when i am saving the file using store method it removes all the comments and the order of text also got disturbed.
    How I need to do this any help appriciated.
    Please elt me know if someone needs more info.
    Thanks in advance.

    Let's assume the ini file is a mapping type storage (key=value) so lets use Properties object. (works with java 1.4 & up)
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.Properties;
    public class Test {
         private static Properties props;
         public static void main(String[] args) throws IOException {
              File file = new File("test.ini");//This is out ini file
              props = new Properties();//Create the properties object
              read(file);//Read the ini file
              //Once we've populated the Properties object. set/add a property using the setProperty() method.
              props.setProperty("testing", "value");
              write(file);//Write to ini file
         public static void read(File file) throws IOException {
              FileInputStream fis = new FileInputStream(file);//Create a FileInputStream
              props.load(fis);//load the ini to the Properties file
              fis.close();//close
         public static void write(File file) throws IOException {
              FileOutputStream fos = new FileOutputStream(file);//Create a FileOutputStream
              props.store(fos, "");//write the Properties object values to our ini file
              fos.close();//close
    }

Maybe you are looking for

  • How do I copy Photos from iPhone to PC?

    This sounds like a very simple question. And with my digital cameras, and old phones, this is just a case of connecting the device to the PC. and copying the files from the device to my harddrive. But with my iPhone this seems very confusing and awkw

  • Using DataSource in RAD 7.5

    Hello, I used to work with RAD 7 and WAS 6.0 and call a DataSource from my servlet by using a reference I created earlier from RAD itselt. Now I'm working on RAD 7.5 and WAS 7.0 and I tried to create a reference to the same DS, but there is no field

  • Cutomizing incorrectly maintained

    Dear All, While creating an Service entry Sheet, the System is showing a message " Customizing incorrectly Maintained" Message no. SE729. I have checked all the configuration related to P.org & Client for the SES. The system is generating the Correct

  • MacBook "operating sound" - what's normal?

    Has anyone else found the MacBook to have a louder "operating sound" than the iBook? My MacBook, when awake and just sitting idle, makes a soft whirring sound (like rushing air) that while not unpleasant, is quite noticeable. The sound comes from the

  • Dreamweaver cc won't start up

    Dreamweaver cc (not 2014) won't start up, it still working yesterday and i have no idea what happen to it. And btw does graphic card relate to this problem? Because i switch my monitor's vga to dvi.