on 04-28-2006 7:00 PM
Ok, I will admit I'm very much a Web Dynpro newbie, and this whole context thing is really confusing for me, though I've been a Java programmer for 6 years.
Here's what's going on. Basically, I'm trying to make a more simplified version of the spell checker (using Jazzy) that was written about in a weblog on here. But, the part that's messing me up is the context. In my Component Controller, I defined a couple things. I defined a value attribute called "misspelledWord", a value node called "Suggestions", and under that a value attribute called "word" (I have more defined than that, but for the purposes of this post, that's all you need to know)
I have a text area, and a "Check Spelling" button underneath it, and in the action for that button, I want to set all those context attributes so that I can display them in the pop-up screen that comes up, which shows the user a misspelled word and all the suggestions for it. Or, at least, it's SUPPOSED to.
In my code I do the following:
wdThis.wdGetSpellCheckComponentController().wdGetContext().currentContextElement().setMisspelledWord(ew.getText());
"ew" is an object I defined called ErrorWord, which contains all the information about each misspelled word and gets populated in my spell checking class.
This works GREAT. misspelledWord gets populated and displayed on the pop-up screen.
My problem is getting all the suggestions. I have them all in an ArrayList in my ErrorWord object, so I HAVE them, I just can't seem to store them in the context. Everything I try gives me a NullPointerException.
All I want to do is loop through my ArrayList, and assign the String value I have in there to the "word" attribute.
Thanks in advance for any help you are able to provide,
Jennifer
for (Iterator i = ew.getSuggestions().iterator(); i.hasNext() ; )
{
String word = (String) i.next();
ISuggestionsElement suggestion = wdContext.nodeSuggestions().createAndAddSuggestionsElement();
suggestion.setWord(word);
}
The context node "Suggestions" should be able to store any number of elements (cardinality = 0:N).
About "context":
The context is a generic, hierarchical storage for the data accessible by a controller. Contexts may be mapped which means you get references to the context elements in used controllers or to the underlying model.
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well, I'm no longer getting a NullPointerException, and for that I'm extremely grateful!
However, it's still not displaying in my pop-up view.
I'm wondering if I somehow defined my Suggestions node wrong, or something? Because, I don't have a createAndAddSuggestionsElement method option, so I had to just do createSuggestionsElement. So, I guess it makes sense that it's not showing up, since it wasn't actually added, but how do I add it then?
Thanks so much,
Jennifer
I really recommend Chris Whealy's excellent book "Inside Web Dynpro for Java".
http://www.amazon.com/gp/product/1592290388/ref=sr_11_1/102-6967880-1651331?%5Fencoding=UTF8
Armin
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.