Accessing resource bundles through javascript
Is there a way that I can localize the text in the following javascript snippet?
function confirmDelete(event)
if (confirm('*Are you sure you want to delete this record?*'))
event.cancel();
var source = event.getSource();
AdfCustomEvent.queue(source, "deleteGuestMessage", {}, false);
return true;
else
return false;
Thanks in advance!
Well, I figured it out myself.
One way is to pass in a property of the translatable string through the <af:clientAttribute> tag.
Once you pass that in, you can get the property and use is, e.g.
var deleteMessage = event.getSource().getProperty("deleteMessage");
if (confirm(deleteMessage))
Happy Coding!
Similar Messages
-
Access Resource Bundle Data Programmatically
JDeveloper 11g 11.1.1.2.0
We've encountered a scenario where we also want to set messages being thrown from our java objects (Impl classes or Beans) to use messages from the resource bundle as data to be thrown.
Is there a utility or a class that can easily give us access to the xliff document which will allow us to just get by id?You can access the resource bundle in the Model as shown below:
import java.util.Locale;
import java.util.ResourceBundle;
ResourceBundle params =
ResourceBundle.getBundle("com.bundle.location", Locale.getDefault());
String value = params.getString("someKey");
... -
Accessing resource bundle in h:inputText
Hi,
I am trying to dynamically populate the label attribute of <h:inputText tag;
<h:inputText id="fullNameField" value="#{newUserFormBean.fullName}"
label="#{resourceBundle.fullName}">
<f:validateLength minimum="3" maximum="64"/>
</h:inputText>When I validate this field i want to populate the error message with the value of label attribute from resource bundle. But it isn't showing up anything, but if i hard code the value of the label field, it displays that value. How do i resolve it?
Thanks.
Edited by: Mujju101 on Aug 29, 2010 10:26 PM
Edited by: Mujju101 on Aug 29, 2010 10:26 PMYes it does show up when i use
<h:outputLabel value="#{resourceBundle.label_fullName}:" styleClass="label" />or either:
<h:outputText value="#{resourceBundle.label_fullName}:" styleClass="label" /> It errs only when used in <h:inputTextEdited by: Mujju101 on Aug 30, 2010 1:17 AM
Edited by: Mujju101 on Aug 30, 2010 1:18 AM -
Accessing java objects through javascript
anybody know a how to get an image from java to javascript... example you get an image from a scanner through java... and then want to use it in javascript
anybody know a how to get an image from java to
javascript... example you get an image from a scanner
through java... and then want to use it in javascripthttp://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/java_js.html -
Message catalogs vs. straight resource bundles
Hello,
I'm just starting to investigate someof WebLogic's internationalization features,
and I'm trying to decide what the benefits would be for using the i18n features
instead of straight Java resource bundles.
Basically, I'm looking for a way to externalize all of our error messages, exceptions,
and GUI elements (like text labels). This will be a Struts application, using
Struts validation. Internationalization itself is a goal, but it is not the driving
factor for externalizing all of our message strings.
I'm seeing to benefits to using the WebLogic i18n functionality. First, all of
the "resource strings" are specified in an XML document that can be validated
and is possibly easier to maintain. Second, accessing these strings becomes a
call to individual methods of a automatically generated TextFormatter class, thereby
freeing client code from having to directly access resource bundles.
Are there any other benefits to using this? I'm just wondering if these benefits
are really worth it, or if it's overkill.
Thanks for the help.
- Jeffhttp://forum.java.sun.com/thread.jspa?threadID=677420&messageID=9483204
go through this link... -
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
SuneeshSuneesh 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 -
How to use resource bundles?
I have a requirement to translate the test that appears on the custom buttons of my portal application. I know resource bundles are part of .properties file that are delivered in Classes floder. But i am not sure how should i make use of this in translating the button text. It would be grate if someone knows it. I will be very helpfull.
Regards,
AmeyaHi Ameya,
[This link|http://help.sap.com/saphelp_nw04/helpdata/en/74/641640b7b6dd5fe10000000a155106/frameset.htm] will provide you information on how to implement Portal Content Translation.
[This link|http://help.sap.com/saphelp_nw04/helpdata/en/62/8b1d40bb37e569e10000000a155106/frameset.htm] will explain how to create and access Resource Bundles (read the entire chapter).
Hope it helps,
Roy
Edited by: Roy Cohen on Nov 26, 2008 3:21 PM -
Resource Bundle issue in ATG 10 migration
Hi,
Migrating from ATG 2007.1 to 10 & getting issues with resource bundle for Merchandizing pages in BCC.Page is loading the StoreMerchandisingIcons.swf from the WAR module.Additionally the page is throwing error #404 for StoreMerchandisingIcons_en.swf & StoreMerchandisingIcons_en_US.swf (which is not available in the WAR)
This URL is loading fine
http://localhost:8180/store-merchandising/StoreMerchandisingIcons.swf
404 for these URLs
http://localhost:8180/store-merchandising/StoreMerchandisingIcons_en.swf
http://localhost:8180/store-merchandising/StoreMerchandisingIcons_en_US.swf
Configured the resource bundle & default locale in the StoreConfiguration but still I am getting this error.Am I missing anything?
Debugged through FireBug , not getting any error in the page or Jboss console
Thanks in advance!
ManiHi,
Application.getResourceBundle(FacesContext, String) retrieves the named ResourceBundle from faces-config.xml and is indeed a good way to access a bundle from an application.
Now, however, you're trying to access a Model layer bundle which is itself an aberration imho. I already mentioned that in numerous posts in the past, but I won't ever think that specifying localized information in the model layer is a good design. At best I could accept it for default value, but localized message it in no way a business logic concern, it's pretty much a pure presentation one. The model layer should return error code/keys and parameters and it should be the responsibility of the view layer to translate it in an understandable version for the target client (human or automated). Can't you use a view layer bundle?
Regards,
~ Simon -
GTC Page Not loading - Error with Resource Bundles
I am using following OIM Software:
OIM 9.1.0.2
Linux x86
While accessing the GTC Manage Page, I am getting the Search button, Once I click the Search for all GTCs, It is throwing me error with "Contact Sysstem Administrator"
During the investigation, I found that I am getting the following error when I access the xlWebApp through Web:
===============
INFO,16 Aug 2010 11:58:35,171,[XELLERATE.WEBAPP],Property global.resultSet.Form~Information.Description.create~generic~connector not found in en locale bundle.
INFO,16 Aug 2010 11:58:35,171,[XELLERATE.WEBAPP],Property global.resultSet.Form~Information.Description.manage~generic~connector not found in en locale bundle.
INFO,16 Aug 2010 11:58:35,172,[XELLERATE.WEBAPP],Property global.resultSet.Form~Information.Description.Reset~self~password~menu~item not found in en locale bundle.
INFO,16 Aug 2010 11:58:35,172,[XELLERATE.WEBAPP],retrieving object from cache key = xlCustomClienten
INFO,16 Aug 2010 11:58:35,172,[XELLERATE.WEBAPP],Property global.resultSet.Form~Information.Description.Change~self~password~menu~item.Change~Self~Password~menu~item not found in en locale bundle.
INFO,16 Aug 2010 11:58:35,172,[XELLERATE.WEBAPP],Property global.resultSet.Form~Information.Description.Create~generic~connector.Create~Generic~Technology~Connector~menu~item not found in en locale bundle.
INFO,16 Aug 2010 11:58:35,172,[XELLERATE.WEBAPP],Property global.resultSet.Form~Information.Description.Manage~generic~connector.Manage~Generic~Technology~Connector~menu~item not found in en locale bundle.
===============
I added the following in customResources_en.properties
global.resultSet.Form~Information.Description.create~generic~connector=create generic connector
global.resultSet.Form~Information.Description.manage~generic~connector=manage generic connector
global.resultSet.Form~Information.Description.Reset~self~password~menu~item=Reset self password menu item
global.resultSet.Form~Information.Description.Change~self~password~menu~item.Change~Self~Password~menu~item=Change Self Password menu item
global.resultSet.Form~Information.Description.Create~generic~connector.Create~Generic~Technology~Connector~menu~item=Create Generic Technology Connector menu item
global.resultSet.Form~Information.Description.Manage~generic~connector.Manage~Generic~Technology~Connector~menu~item=Manage Generic Technology Connector menu item
I am trying so many options with these two files, however the error is not changing at all. Also, do I need to add this to customDefaultResources.properties?
Any suggestions?
Thanks in advance. I will assign Points.
Regards
Vijay ChinnasamyLCMan wrote:
Carolyn Samit wrote:
Did you read my response to you??
Yes. However, I don't believe it's an enycryption issue. It's something to do with javascript.
Regardless of what the issue is, the only (temporary) fix seems to be to use Firefox. However, I would have to agree with what Carolyn Samit said. Carolyn is a very active member here and knows a lot of things. -
Hi,
I'm getting a resource bundle error but i'm not quite sure what it means:
Can't find resource for base name PackageName.ClassName, locale en
What exactly is the "locale"? The class compiles but once i use it in my jsp i get this error.
Thanks, in advance"This step shows how the Locale, the properties files, and the ResourceBundle are related. To create the ResourceBundle, invoke the getBundlemethod, specifying the base name and Locale:
ResourceBundle labels =
ResourceBundle.getBundle("LabelsBundle", currentLocale);
The getBundle method first looks for a class file that matches the base name and the Locale. If it can't find a class file, it then checks for properties files. In the PropertiesDemo program we're backing the ResourceBundle with properties files instead of class files. When the getBundle method locates the correct properties file, it returns a PropertyResourceBundle object containing the key-value pairs from the properties file."
If it can not find either a class or properties file it will through the exception that you are seeing. Check your directory structure in the jar file and make sure it is correct for what you are trying to access. -
File not found, Missing resource bundle
Hi
I have a problem in accessing files (XML and Resource bundles) in Java projects. I used to access these files in WD Java. The same piece of code does not work here.
e.g. When I create a new file object by providing the path name I get a file not found exception. The file exists in my package and I call it this way:
File f = new File("file.txt"); then in an input stream but it doesnt work. However in a J2EE project the same code works.
Similarly the resouce bundle never seems to work even if I give the fully classified class name for the property file. I can access property files in WD Java with ease. I understand that the root path changes and hence the problem. How should I solve it? Is there an elegant way which makes it work in all cases? Please throw some light on the root path for these projects. Thank you.
regards
LNV
Edited by: vln on Jan 16, 2008 9:34 AMYou should be using
<b>this.getClass().getResourceAsStream(filePath)</b>
which will return you an InputStream.
Check the JDK documentation for the respective methods in java.lang.Class and java.lang.ClassLoader.
HTH!
\-- Vladimir -
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. -
Error in Loading Resource Bundle in JSP
Hi
I have one Resource Bundle which working well in my JSP page
i declared as below
<f:loadBundle basename="com.ApplicationLabels" var="lblbundle"/>
Ok then i want to add another new resource bundle and i put it below the first loadBundle tag
<f:loadBundle basename="com.newLabels" var="newbundle"/>
But when i access my JSP page it keeps giving me
Exception Details: javax.faces.el.PropertyNotFoundException
Error testing property 'test' in bean of type null
Possible Source of Error:
Class Name: com.sun.faces.el.PropertyResolverImpl
File Name: PropertyResolverImpl.java
Method Name: getType
Line Number: 342
What are the things i need to configure after i creatting properties file for my Application Messages in JSP page
any idea about this exception?
Thanks.Hi Voodi,
in the record i have many columns that refered to date, i have: Valid-from, Valid-To H, created on, Valid From, Valid To- i don't know where is the specified column to check the required format, in PSA in the data package 19 i have 13755 Records posted and i have checked many records to control these columns but i don't find something that demonstrate me a difference between the format, i don't know why the error signalated is only 6701...but you think is only a problem of format it's not not somthing that i have to signalated to the person who works on R/3 if there is something to correct in the datasource?
Thanks
Bilal -
I have a funny problem with Resource Bundles:
In the property editor for a Hyperlink object I replaced the text property with the following: #{messages1.MyKey}
I have defined an action on the hyperlink as follows:
public String MyHyperlinkId_action ()
String HyperlinkText = (String)MyHyperlinkId.getText();
String HyperlinkID = MyHyperlinkId.getId();
return null;
getText() returns null since I use the Bundle to set the text. getId() returns the correct Id. If I hardcode the text in the property editor getText() returns that text correctly.
Any idea, what the problem could be??
Many thanks
TomDid you modify the hyperlink text property manually or through the property binding wizard. It could be a spelling mistake. Also make sure MyKey is defined in your resource bundle.
-
Problem with refresh resource bundle...
Hi Iam refreshing the resource bundle. Iam using the following code:
hsModelServiceProvider.getInstance().setFallbackBindingContainerEL("");
JhsModelService jhsService = JhsModelServiceProvider.getInstance().getJhsModelService();
System.out.print("UserId is :"+userId);
jhsService.getTransaction().executeCommand("begin APP_USER_CTXT_mgr.set_user('"+userId+"');end;");
System.out.print("after execute command");;
// refresh resource bundle
MethodBinding refreshBundles = FacesContext.getCurrentInstance().getApplication().createMethodBinding("#{nls.refreshBundles}",new Class[] { ActionEvent.class});
refreshBundles.invoke(FacesContext.getCurrentInstance(),new Object[] {null});
Iam gettin the following error Upon executing
ERROR (MessageFactory) -Failed to refresh bundle oracle.jheadstart.exception.JhsUserMessages due to null
Please help me..
Thanx in Advance!Hi Steven,
I want to personalise the ADF Application depending the userpreference. I got a tutorial which uses JHeadstart(through refreshing the resource bundle) for the same, but I did not understand that clearly as I said Iam new to this. Can you please give me any sources which speak about the personalisation functionality in detail?
Thanq
Maybe you are looking for
-
How can I change the date old photos were taken when I only know the year?
I've scanned lots of old photos and I want to change the date to reflect when they were taken. In some cases I only know the year and I don't want inaccurate information to be assigned by the software. How can I do this?
-
HP Officejet Pro 8600...laptop cant find printer to set up wireless printing
I just purchased an HP officejet Pro 8600 and successfully synched it to a laptop in my office for wireless printing without a problem. Immediately after that, I attempted to connect the printer to another laptop in the office and the 2nd laptop cann
-
Hi, I am trying to create rebate based on customer ..agreement type 0003. First I created rebate agreement number and condition record for the customer I created Sales order ...when I was trying billing ..I got the error in account determination. Fo
-
Help needed in configuring ADS
Hi I finished installing the Adobe Documeny service (of NW2004s) in a 32 bit win 2003 server with both Java+ABAP stack. As described in the ADS Configring Guide, I wanted to check Basic Authentication and when I try the link http://<Servername>:50100
-
Sending Mail with HUF / JPY currency in Workflow
Hi Friends , I have the below requirement . I have to send PO for approval throug Workflow . I am using " SO_NEW_DOCUMENT_SEND_API1" inside one method to send mail through Workflow . My Requirement - For JPY / HUF currency PO , Price of PO has to b