on 01-26-2010 12:56 PM
hi all,
how to work with properties file?. how to write it?. wr to save the properties file in web dynpro java?. and how to access it.
regards,
shreeharsha
Hi
1. Create one notepad file and save it as .properties file.
2. write the key and values there as follow:-
a=1.2345
b=2.3456
etc.
3. Then save it and put the file in your project at the following location
---src
-
configuration
-
a.properties
4. now in the code where you want to use it write the following
String[] Values = null;
try {
IWDConfiguration config =
WDConfiguration.getConfigurationByName(
wdComponentAPI
.getDeployableObjectPart()
.getDeployableObject(),
"<name of the file>");
Values = config.getStringEntries(<Key>);
} catch (Exception e) {
}
Now values contain the value of the porperty having specified key
Thanks,
Sarbjeet singh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi sarbjeet,
my problem is i have a project that came with the netweaver installation. its nothing but simple quiz like project. in the project its displaying the question and answer after the button press. actually its displaying the questions from the properties file Questions and its stored under the 'src' folder. can u please tell me how to do this.....
regards,
shreeharsha
Hello
well you can fetch the questions from the properties file by using the code that i have pasted above.
Suppose you have a text view where you want to display your question then bind that text view to one context attribute of type string.
Suppose name of the context attribute is que1 then in the action or event handler where you want to display the question
write the code
String[] Values = null;
try {
IWDConfiguration config =
WDConfiguration.getConfigurationByName(
wdComponentAPI
.getDeployableObjectPart()
.getDeployableObject(),
"<name of the file>");
Values = config.getStringEntries(<Key for Question 1>);
wdcontext.currentcontextelement.setQue1(Values[0]); //this will set the question 1 in the context attribute.
} catch (Exception e) {
}
Please let me know if you still have some problem in fetching the values.
regards,
Sarbjeet
Hi,
IWDConfiguration config =WDConfiguration.getConfigurationByName - i am getting error in this line
"IWDConfiguration can not resolved" and "WDConfiguration can not be resolved"
wdContext.currentContextElement.setProperty(Values[0]); - here in this line
"wdContext.currentContextElement can not resolved"
this is my Property.properties file look like
Q0 = What is a views?
Q1 = What is a view set?
Q2 = What is a view area?
Q3 = What is a window?
Q4 = What is a view composition?
Q5 = How do you embed views into other views?
Q6 = What is a component interface view?
SIZE = 7
Hi,
Values = config.getStringEntries(Q0);
error "Q0 can not resolved"
this is my Property.properties file look like
Q0 = What is a views?
Q1 = What is a view set?
Q2 = What is a view area?
Q3 = What is a window?
Q4 = What is a view composition?
Q5 = How do you embed views into other views?
Q6 = What is a component interface view?
SIZE = 7
i have saved the properties file under the src->package folder and src->configuration->applicatons folder
String[] Values = null;
try {
IWDConfiguration config = WDConfiguration.getConfigurationByName(wdComponentAPI.getDeployableObjectPart().getDeployableObject(),"Property.properties");
Values = config.getStringEntries("Q0");
wdContext.currentContextElement().setProperty(Values[0]); //this will set the question 1 in the context attribute.
} catch (Exception e) {
}
Hi
Where is your properties file stored?
Could you tell me the path for it?
And is its name Property?
And do one more thing
In the catch part print the exception write the following
catch (Exception e) {
wdComponentAPI.getMessageManager().reportException(e.getMessage(), false);
}
Sarbjeet Singh
Hi
Where is your properties file stored?
Could you tell me the path for it?
And is its name Property?
And do one more thing
In the catch part print the exception write the following
catch (Exception e) {
wdComponentAPI.getMessageManager().reportException(e.getMessage(), false);
}
Sarbjeet Singh
Hi
1. Add one attribute in the context of type integer say Number
and add the following code in Wddodinint
wdContext.currentContextElement().setNumber(1);
2. Then add write the code in the action like this
String[] Values = null;
int num = wdContext.currentContextElement().getNumber();
String str = "Q"+num;
try {
IWDConfiguration config =
WDConfiguration.getConfigurationByName(
wdComponentAPI
.getDeployableObjectPart()
.getDeployableObject(),
"a");
Values = config.getStringEntries(str);
} catch (Exception e) {
}
if(num < 7)
{wdContext.currentContextElement().setNumber(num +1);
wdContext.currentContextElement().setQuestion(Values[0]);
}
else
{
wdContext.currentContextElement().setQuestion("The END");
}
Thanks
Sarb
Hi Sarbjeet,
Is it possible that in future if we need to change the values (here question's in properties file), to change them without redeploying the code ?
is there any way config / visual admin tool where we can edit this propety file and avoid code redeployment and testing in dev-test-prod environments ?
Thanks !!!
Hi,
The quiz application is a standard help tutorial available for Web Dynpro for Java.
It is readily available with coding and documentation on the help.sap.com.
You can find it here: [Quiz Application|http://help.sap.com/saphelp_nw70/helpdata/en/5d/f42fef2eec724597a03b6bcc670c2c/content.htm]
Regards,
Alka.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello shreeharshaudupa,
For internationalization, you need to work on .xlf files, these files you can find under Navigator prespective -->respective project --> repective pacakge, where you mentioned while creating the IVIew.
You shouldn't work on .properties file, because even though you make some changes in that .properties file, those changes will disapper when the DC is build. so you have to work with .xlf files of the iviews
For refernece go through below threads
/people/prashant.patalay/blog/2006/12/20/internationalization--i18n-of-webdynpro-java-application
Regards
Maha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.