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)]}

Similar Messages

  • 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...

  • 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

  • How to use a resource bundle in viewcontroller project

    How can I create a resource bundle for a viewcontroller project ? Is there any way to add entries to it other than adding manually editing the property file ? so that all the key generated will be unique? How to access a message in the resource bundle in my backing bean so that I can display it in my screen ?
    Thanks
    Suneesh

    Suneesh Raman wrote:
    How to access a message in the resource bundle in my backing bean so that I can display it in my screen ?Take a look at this: http://adfcodebits.blogspot.com/2010/04/bit-5-accessing-resource-bundle-from.html

  • Resource bundle in shared library?

    Is it possible to create a resource bundle in a shared library so you can use the same resource bundle in different application?
    We are creating different ADF application and each of them should use the same resource bundle.
    I tried creating a new project that only contains the resource bundle and then add this to my jspx page:
    <c:set var="res"
             value="#{adfBundle['general.resources.generalBundle]}"/>When i do this, he can't find any entries. When i change the project properties and configure to use a single bundle for the entire project, this works.
    How can i share a bundle so each application does not need to create or copy/paste the bundle?
    Is it possible to deploy the bundle as a shared library? Even if their is nothing else, not even a single java class?
    Edited by: Yannick.O on Jul 28, 2010 10:45 AM

    Try to create a JAR with the resource file in it (under /META-INF) and add it as a library in your project.
    If it does not work, try to create a faces-config.xml file inside that directory that declares the resource file.
    I think it gets merged at runtime with the config of your application and resource bundle should be available.

  • 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 use common resource bundle across all the development components ?

    Hi,
    I am working on SAP NetWeaver Developer Studio - JAVA
    How to use common resource bundle across all the development components ?
    Description :
    I have a requirement of creating a resource bundle (resource.properties) and use that common resource bundle in all the development components.
    Can we create a  development component (war and ear both) and create only resource.properties in this development component( DC ) and create the dependency of the same DC  in all the other DCs ?
    Thanks,
    Neha

    Hello Neha 
    This question is more NWDS related.
    You may have a better chance of someone answering the thread under
    SAP Netweaver -> SAP NetWeaver Development Infrastructure (NWDI, formerly known as JDI) forum
    Thanks
    Kenny

  • 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

  • Getting String using ResourceBundle and XLIF resource bundle.

    Hello,
    I am using Jdev. 11.1.1.2.0. I am trying to use XLIFF resource bundle in the Model project and trying to get string from the bundle using following code. I am getting MissingResourceException. if I use Property Bundle, it works fine.
    public String getMessage(String code)
    return ResourceBundle.getBundle("model.ModelBundle").getString("MESSAGE1");
    Any help to make it work with XLIFF resource bundle will be appreciated.
    Thanks,
    Amit
    Edited by: Amit Patel on Apr 1, 2010 10:23 AM

    To get the values from the resource bundle, you use the <fmt:message> tag
    <fmt:message bundle="${appbundle}" key="lbl.accountnum"/>

  • Error resolving resource bundle "strings"

    Hi
    I'm trying to use Flex 3 to compile the Flex 2 PhotoViewer
    sample project, and encountered this error: 'Unable to resolve
    resource bundle "strings" for locale "en_US".'
    I found the Flex 2 TechNote which suggested to add
    "-use-network=false -library-path+=locale/{locale}
    -source-path+=locale/{locale} -locale=en_US" as compiler options.
    So I tried adding the above options into the build.bat files
    I can find at:
    a) C:\Program Files\Adobe\Flex Builder
    3\sdks\3.1.0\samples\explorer
    b) C:\Program Files\Adobe\Flex Builder
    3\sdks\3.1.0\templates\automation-runtimeloading-files
    but still the error persists.
    Can anyone please advise where I should change the compiler
    options? Thanks!
    Regards
    freshflex

    << Do not post the same question across a number of forums >>

  • 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
    }

  • resource-bundle tag of portlet.xml

    Hi.
    I'd like to use resource bundle. Therefore I add following tags inside <portlet> tag of portlet.xml and create 'testprofile.properties' file.
    <resource-bundle>testprofile</resource-bundle>
    But when I start tomcat, the error occured like following.
    2004-08-05 12:01:45,437 ERROR [main]
    java.lang.NullPointerException
    at java.io.Reader.<init>(Reader.java:61)
    at java.io.InputStreamReader.<init>(InputStreamReader.java:80)
    at java.util.Properties.load(Properties.java:189)
    at java.util.PropertyResourceBundle.<init>(PropertyResourceBundle.java:96)
    at com.plumtree.portlet.util.PortletInfo.addPropertyBundles(PortletInfo.java:425)
    at com.plumtree.portlet.servlet.PortletServlet.digestPortletXml(PortletServlet.java:527)
    at com.plumtree.portlet.servlet.PortletServlet.initDigester(PortletServlet.java:651)
    at com.plumtree.portlet.servlet.PortletServlet.init(PortletServlet.java:60)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:935)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:823)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex ...
    So I modified portlet.xml like following and try to start tomcat again.
    <resource-bundle>testprofile.properties</resource-bundle>
    Tomcat can be started successfully.
    But when I display the portlet, error occured.
    java.util.MissingResourceException: Can't find resource for bundle com.plumtree.portlet.util.PortletResourceBundle, key LogLevel at java.util.ResourceBundle.getObject(ResourceBundle.java:314) at java.util.ResourceBundle.getString(ResourceBundle.java:274) at portlet.TWNewMailPortlet.init(TWNewMailPortlet.java:45) at com.plumtree.portlet.servlet.BaseServlet.init(BaseServlet.java:522) at com.plumtree.portlet.servlet.PortletServlet.service(PortletServlet.java:136)
    The properties file 'testprofile.properties' is not loaded successfully, maybe.
    Do you know how to specify or use ResouceBundle in using Plumtree JSR168?
    The tips of source code is following
    In Portlet class which extends GenericPortlet
    public void init(PortletConfig config) throws PortletException {  super.init(config);  PortletLogger.init("Test", getPortletContext());  ResourceBundle rb = getResourceBundle(Locale.getDefault());  for (Enumeration e = rb.getKeys(); e.hasMoreElements(); ) {   String str = (String)e.nextElement();   System.out.println(str);  } String level = rb.getString("LogLevel"); PortletLogger.setLevel(level); }

    Are you naming your resource bundles something like:
    1. messages_en.properties (for English)
    2. messages_de.properties (for German)
    and so on.
    Also, do you include these properties files in your final deployment package, because if they're not there then the messages won't be displayed.

  • Unable to refer to custom resource bundle in WPC content rendered with xslt

    Hi,
    I need to use the resource bundle messages inside WPC content.
    When rendered by standard xsl templates the  call to XSLTHelper class is done to retrieve message from the standard SAP resource bundle com.sap.nw.wpc.bundles.core.properties, like this:
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                         xmlns:wpc="com.sap.nw.wpc.km.service.editor.hslt.XsltHelperCore">
    <xsl:value-of select="wpc:getString([key defined in sap bundle], string(/document/@locale))"/>
    The problem is that helper class doesn't provide any API to use custom bundles.
    I tried to create xslt helper (including config in KM), but that didn't succeed neither. It would return with error NoClassDefFound.
    Could you please help on configuring xslt helper and registering it with xslt rendering engine for Web Page Composer? I could not find any how-to guides on xslt helpers for WPC.
    Thanks in advance.
    Ruslan

    Hi
    Did you find a solution?
    Christof

  • How to use XLIFF file as resource bundle in Java code

    We use xliff as resource bundle for our ADF application. it is has been no problem to have localized message displayed on UI. how ever, I'm wonderring how to use Java code to access xliff as resource bundle which similar to access properties resource bundle. for example:
    Locale myLocale = new Locale("es", "ES");
    ResourceBundle bundle = ResourceBundle.getBundle("HelloResourceBundle", myLocale);
    System.out.println(bundle.getString("Hello"));is it posible to create "HelloResourceBundle" in xliff format?
    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;
    }

Maybe you are looking for

  • No longer able to view the device in iTunes client

    All of a sudden, when syncing my iPod Nano, I can no longer click on the device name on the left hand pane to enter the view where I can control and change options while syncing. It still syncs, but when I click on the device name, nothing happens. T

  • How to make use EP advanced concepts

    hi friends,         I have a few doubts in EP? My client is already implemented EP for their business. Now my client is trying to implement SOA.. In this point of view... How we can show that the new advntages of EP. like VC.. CAF Guided procedures..

  • Photo gallery thumbnails quality

    Hi guys Please see this link: http://stsstone.businesscatalyst.com/gallery-by-stone-beige-limestone The thumbnails render in low quality. How can I fix that? Thanks Micha

  • Google sheets for blackberry Q10

    Hey, does blackberry Q10 have Google sheet App? Thank you,

  • Could not load application module in Server

    Hi, I'm getting this java exception when trying to load a standard HR Page in Oracle e-Business Suite: oracle.apps.fnd.framework.OAException: Could not load application module 'oracle.apps.per.selfservice.appraisals.server.AppraisalsHomeAM'.      at