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 /

Similar Messages

  • How to link the resource bundle in JSF implemented in  eclipse?

    Kindly help me out

    This is how I called the resource bundle in JSF
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
    <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <f:view>
    <f:loadBundle basename="constantsUIProp" var="prop"/>
    <h:form>
    <h:inputText maxlength="#{prop.AREA_CODE_MAX}"></h:inputText>
    </h:form>
    </f:view>
    </body>
    </html>
    when i tend to build, it shows an error like+ Resource bundle cannot be found on the classpath+
    I have saved the resource bundle in WebContent/Web-Inf/classes/constantsUIProp

  • How to configure resource bundle in facescontext.xml in JSF

    I have to take each label from the resource bundle in my web application, so how to configure resource bundle in JSF and how to use it, so please help me.....

    Follow the below mentioned steps ::
    1) make a properties file say mymessages.properties alongwith your java files. Put content like
    click=Click Me !!!
    #where click is the key and Click Me !!! is the actual value that needs to be displayed
    2) Add in faces-config.xml like this ::
    <application>
              <message-bundle>mymessages.mymessages</message-bundle>
         </application>     
    3) Use in your jsp page like this ::
    <f:view>
    <f:loadBundle basename="mymessages/mymessages" var="msg"/>
    hello :: <h:commandButton value="#{msg.click}" onclick="callJavaMethod()"></h:commandButton>
    </f:view>

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

  • JSF resource bundle class not found,

    When I put the resource bundle class in session-ejb.jar, it works fine. But when I moved the resource bundle class into web module web.war, JBoss AS complained: the resource bundle class were not found.
    In the web module, I put the bundle class under:
    /WEB-INFO/classes
    war file:
    /WEB-INF/classes/resource/Messages
    JSP file:
    <f:loadBundle basename="resource.Messages" var="bundle"/>
    Thanks for help.

    has anyone made the following example work in JBOSS?
    http://www.coreservlets.com/JSF-Tutorial/code/jsf-messages.zip
    I got error message:
    resouce bundle not found.
    The resource properties files are under WEB-INF/classes.
    Where to put resource bundle files?
    Can any one please shed some light? Thank you very much.

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

  • Allowing EL expression in a resource bundles

    Mojarra 2.1.7-jbossorg-1 (20120227-1401)
    JBoss 7.1.1
    EL expressions in a resource bundle are currently not evaluated. That is, an an example, I have the following in the requiredMessage attribute of a JSF input control:
    requiredMessage="Status for #{someBean.documentMap[claimDocument.id].description} is required."I would like to move this to a messages.properties file like so:
    required.claimDocumentStatus=Status for #{someBean.documentMap[claimDocument.id].description} is required... so that the requiredMessage attribute becomes:
    requiredMessage="#{msg['required.claimDocumentStatus']}"Now the output for h:message(s) is
    Status for #{someBean.documentMap[claimDocument.id].description} is required.As I have found out, JSF resource bundles does not resolve EL expressions:
    http://stackoverflow.com/questions/6547136/el-variable-in-jsf-resourcebundle
    What I am trying to do is to allow such resolution / resolving to take place for JSF resource bundles. Now there is a class called "javax.el.ResourceBundleELResolver". I was wondering what it would take to extend this class to allow such a thing to take place. There does not seem to be a way to override it or to specify a custom resolver via faces-config.xml.
    Any thoughts ?
    Edited by: jmsjr on 14-Jan-2013 21:53

    jmsjr wrote:
    gimbal2 wrote:
    IMO this requirement, if it is possible to implement, is only going to lead to a hard to maintain application. But I guess that's something you have to experience before you believe it.
    You can't use EL directly in a resource bundle out of the box, but it is possible to parametrize them anyway, did you know that? Perhaps that is already good enough for you.
    http://murygin.wordpress.com/2010/04/23/parameter-substitution-in-resource-bundles/
    http://stackoverflow.com/questions/5697189/pass-parameters-to-messages-from-resource-bundle-to-components-other-than-hou
    Yes, I am aware of parameterising the resource bundles. However, these require you to use f:param .. and the last time I tried, these parameters were not available / visible at the requiredMessage attribute. I'll try it again anyway.As I have re-discovered, you cannot parameterise the requiredMessage attribute.
    http://stackoverflow.com/questions/9280915/how-to-parameterize-requiredmessage-attribute-in-composite-component
    The other alternative I am looking at, for the cases where the requiredMessage needs to be parameterised, or needs to have dynamic content, is to call a backing method for the requiredMessage attribute, from which I can then do whatever I need, even use EL expressions. I was thinking of this as a last resort.
    On the other hand, when one uses the validator attribute, usually one ends up adding one or multiple FacesMessage in code within the method being called, where the string of the message already comes from a resource bundle. I was trying to have a delineation whereby:
    1) requiredMessage should only use resource bundles, no backing bean method called.
    2) FacesMessages added via the method called by the validator attribute is OK

  • BUG-JDev 11G 5407-Project level resource bundle usage messes the page

    When you define a resource bundle on the project properties and if you are using templates the page is not properly rendered in the design view but it runs fine.
    What happens is , JDev adds a JSTL set tag just before the *<af:pageTemplate>* tag and this confuses the designer. To workaround I defined the bundle variable in faces-config, it worked fine for the existing texts but when you add a new text to the page JDev keeps adding this set tag at the beginning of the page and you need delete it each time.
    It looks like a bug to me ..
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:dvt="http://xmlns.oracle.com/dss/adf/faces"
              xmlns:mcc="http://com.micros.adf.controls"
              xmlns:c="http://java.sun.com/jsp/jstl/core">
    <c:set var="abcdmainBundle"
             value="#{adfBundle['com.abcd.view.zzzz.messages.AbcdMain']}"/>
      <af:pageTemplate viewId="/tmpl/abcdMainFgTmpl.jspx" id="pt1">
        <f:facet name="main">
     

    Hi,
    we have the same issue and therefore do not use the feature of the property inspector.
    Instead we open the *.properties file in jdev and edit it manually.
    There is bug 7537379 around this c:set tag which MAY BE fixed in the next release (11.1.1.2.0) but I don't know if this bug also covers exactly your problem.
    regards
    Peter

  • Utf-8 from resource bundle?

    I've been looking at many resources and see this is a common problem but still haven't found solution to desplaying unicode data.
    Page starts with <%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %> and has <meta http-equiv="content-type" content="text/html; charset=utf-8"> in the html head tag.
    Output from all database derived unicode characters look fine. However, output from resource bundle is garbled. i.e. "Espa�ol" comes back as "Espa&#195;&#177;ol".
    Using Tomcat 5 where I set URIEncoding="UTF-8" in the Connector tag.
    Also have a catch all filter setting.
    request.setCharacterEncoding("utf-8");
    response.setCharacterEncoding("utf-8");
    and I've duplicated the settings in the jsf file.
    I'd really appreciate any ideas what I'm doing wrong or what more I need to add?

    ResourceBundle Properties uses java.util.properties. If you look closely in
    http://java.sun.com/j2se/1.3/docs/api/java/util/Properties.html
    you can see it is not using UTF-8, but only ISO 8859-1.
    There is no easy solution for this problem.
    If you are using JSE 5.0 you can view sun newletter
    http://java.sun.com/developer/JDCTechTips/2005/tt1018.html
    Hope it helps.

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

  • Resource Bundle var unknown in task flow

    Hello everyone,
    I'm using a resource bundle in my web-app. This is the entry in the faces-config.xml file:
    <resource-bundle>
          <base-name>oracle.bundles.CustomUIBundle</base-name>
          <var>bundle</var>
    </resource-bundle>
    When I use the EL expression in my jsf fragments like #{bundle['key']} I have no error or warning messages, but when I use it in a train stop label in a Task Flow with train I have the following error and warning messages:
    Error: EL token "bundle" is unknown
    Warning: Reference "bundle" not found
    The labels are correctly shown at runtime, but this error make me unconfortable during the developing because I cannot know immediately if a "real" error is present.
    Thanks in advance.
    Manuel

    Timo,
    sorry for my forgetfulness: JDev 11.1.2.3.0.
    I know that it works fine at runtime but is a bit frustrating to see that big red cross on the task flow views even though the code is correct. That's all.
    Anyway, thanks for your help.
    Manuel

  • Locale Resource Bundle Best Practice

    Hi
    I have a Flex application that loads it's locale resource bundle from a service.
    So when the httpservice loads the bundle it populates an instance of a class "I18NBundle" that contains all the bundle properties. For instance you could do:
    i18nBundle.hello_message and it would return "Hello"
    I'm currently using Cairngorm for this project so this i18nBundle instance it's on the model locator.
    What I'm seeing and that I don't like is that for a component be able to get the bundle it must access to the model locator and then to the i18nBundle.
    Instead of that what I would like is that each component doesn't rely on this for getting the bundle.
    I guess I could create a "bundle" property on each component class and then pass it the reference to the bundle when it is instanciated. It seems it could be messy and a difficult task to initialize this property in some cases for instance on a datagrid cell renderer.
    Other could be transforming the I18NBundle class into a singleton and then when the service response it's recieved the singleton it's initialized. Since all application components should/must access the same locale bundle I guess this could be a better option.
    What do you think about this?
    Do you think there is some a better way to achieve this with Flex?
    Any opinion or recommendation would be appreciatted.
    (I don't wish to use the Adobe Flex proposal of having the properties file on the Flex project and the compiling them into swf.)
    thanks in advance.
    Polaco.
    ps: If you think I haven't expressed myself correctly please let me know and I will rewrite it.

    I have managed to extend IResourceBundle and added it to ResourceManager.
    The only problem now is that my bundle does not represent a language and it doesn't need a name either.
    Since the localization part is done on the webapplication and then the apporpiate bundle returned in the request's response.
    So it's locale attribute value is "".
    And it's name is "".
    I can display a property correctly if I use the following code:
    (resourceManager.getResourceBundle('','')).content.helloMessage
    but I doesn't work if I try to retrieve it like:
    resourceManager.getString("", "helloMessage");
    any ideas ?
    thanks

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

  • Resource bundle naming issue across platforms

    Sorry, but there's no issue anymore. After a complete restart of the windows server it now accepts lowercase "da".
    We're using resource bundles to internationalize our app for English and Danish users. The default resource bundle is named "ViewControllerBundle" and the Danish bundle is named "ViewControllerBundle_DA" (on windows at least).
    Our problem occurs, when we deploy the application on different platforms. At the moment we have Weblogic 10.3.5 running on Linux and on Windows. Our development environment (JDeveloper 11.1.2) is running on Windows.
    When we deploy the application on Weblogic/Linux we need to rename the Danish resource bundle to lowercase "da", like "ViewControllerBundle_da".
    When we deploy on Windows or runs the application from JDeveloper we need to name the Danish resource bundle with uppercase "DA", like "ViewControllerBundle_DA".
    If we don't rename the bundles we're not able to display danish labels etc.
    I would like to know, whether we are naming the bundle the right way or whether it is possible to avoid this manual renaming before deploy. We would like to use the same EAR file for all the servers, if possible.
    From faces-config:
    <locale-config>
    <default-locale>da_DK</default-locale>
    <supported-locale>da_DK</supported-locale>
    <supported-locale>en_GB</supported-locale>
    </locale-config>
    Edited by: wmjaboj on 2011-08-30 02:45

    b) In some parts on our website, we need to show data, depending on an attribute in a user's profile. So, for instance, if the user is not an administrator, the address shouldn't be shown when his profile is shown to a regular user. Is there an elegant way to solve this? I'm a Struts programmer (first JSF project) and normally you do <c:if test="${}">, but that's not possible in JSF :-).You can certainly use JSTL in JSF. You need at least JSF 1.2 at a JSP 2.1 environment and JSTL 1.2. Google for "unified EL" in Sun.com. But if you want to use a JSF-only solution, then make use of the 'rendered' attribute which is supported by every JSF HTML component and a few JSF core components. It accepts a boolean expression and when it evaluates to true, then the component will be rendered in the view.
    E.g.<h:panelGroup rendered="#{user.admin}">
        <h:outputText value="I am an admin." />
    </h:panelGroup>where the User bean look likepublic class User {
        public boolean isAdmin() {
            return admin;
    }Here are some more EL examples which you can use in the 'rendered' attribute:<h:someComponent rendered="#{myBean.booleanValue}" />
    <h:someComponent rendered="#{!myBean.booleanValue}" />
    <h:someComponent rendered="#{myBean.intValue > 10}" />
    <h:someComponent rendered="#{myBean.objectValue == null}" />
    <h:someComponent rendered="#{myBean.stringValue != 'someValue'}" />
    <h:someComponent rendered="#{!empty myBean.collectionValue}" />
    <h:someComponent rendered="#{!myBean.booleanValue && myBean.intValue != 0}" />
    <h:someComponent rendered="#{myBean.stringValue == 'oneValue' || myBean.stringValue == 'anotherValue'}" />

  • 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