on 05-10-2006 11:25 AM
Hi,
I am new to WebDynpro,
I have developed the quiz application which is given in the help contents of NWDS,
But I am facing a probem,
I have added two resource bundle files for Questions and Answers:
But inspite of giving the path of files and all that,
I am not getting the Questions or Answers text in my application,
Please suggest,
Thanks in advance,
Deepak
Hi Deepak,
Where are resource bundles files and what is the code wich loads the data?
Best regards, Maksim Rashchynski.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
<b>Location of the files:</b>
src/packages folder at com.sap.dk.resources.Questions
com.sap.dk.resources.Answers
<b>Code that handles the files:</b> {Sorry for the length}
public void wdDoInit()
{
//@@begin wdDoInit()
// ===== STEP 1: Load resource bundles for questions and answers ==========
// Get the questions-answer resource handlers for the current session locale
// using the factory class WDResourceHandler.
IWDResourceHandler resourceHandlerForQuestions =
WDResourceHandler.createResourceHandlerForCurrentSession();
IWDResourceHandler resourceHandlerForAnswers =
WDResourceHandler.createResourceHandlerForCurrentSession();
// Load the resource bundle "Questions.properties" located
// in the package "com.sap.dk.resources.Questions"
// for locale set in the resource handler.
resourceHandlerForQuestions.loadResourceBundle(
"com.sap.dk.resources.Questions",this.getClass().getClassLoader());
resourceHandlerForAnswers.loadResourceBundle(
"com.sap.dk.resources.Answers",this.getClass().getClassLoader());
// get the number of question-answer-pairs contained in the resource bundle
int size = Integer.valueOf(resourceHandlerForQuestions.getString("SIZE")).intValue();
//===== STEP 2: Create context node elements of the type QuizData =========
// begin populating context node QuizData
Collection questions = new ArrayList();
for (int i = 0; i < size; i++) {
// instantiate the new context node element of type QuizData
IPublicDK_Quiz.IQuizDataElement quizDataElement = wdContext.createQuizDataElement();
// set contained context value attributes
quizDataElement.setQuestion(resourceHandlerForQuestions.getString("Q"+i));
quizDataElement.setAnswer(resourceHandlerForAnswers.getString("A"+i));
quizDataElement.setCounter(String.valueOf(i1)"/"+String.valueOf(size));
// add new context node element of the type QuizeData to ArrayList
questions.add(quizDataElement);
System.out.println(quizDataElement);
}
//===== STEP 3: Bind collection of Q&A pairs to context value node QuizData ====
// Bind collection of context node elements to context value node QuizData
wdContext.nodeQuizData().bind(questions);
//@@end
}
Regards:
Deepak
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.