on 01-26-2007 9:18 PM
I'm new so this will be simple - I think
I'm attempting to follow the tutorial on SAP HELP located at:
http://help.sap.com/saphelp_nw04/helpdata/en/44/47b87e9d780597e10000000a155369/frameset.htm
I got threw tutorial 1 with no problem...
When I get to the "Writing Code" section of Tutorial II, writing the mySiteMap.java code, I assume I'm suppose to use the code as written in the tutorial... however my IDE (NWDS) gives me :
Syntax error on token "Hashtable", "interface", "class" expected
on this block of code, (which I copied from the tutorial):
*CODE*
public Hashtable getEnvironment(IPortalComponentRequest request ) {
Hashtable environment = new Hashtable();
IUserContext userContext = request.getUser();
if (userContext != null) {
environment.put("NavigationPrincipal", userContext);
String user = userContext.getUniqueName();
if (user != null && !user.equals("")) {
environment.put("User", user);
}
}
return environment;
}
*END CODE*
Any help is greatly appreciated
Put the "code" into a class and make sure there is an import statement for Hashtable.
For instance,
package myPackage;
import java.util.Hashtable;
public class MyClass
{
public Hashtable getEnvironment(IPortalComponentRequest request ) {
Hashtable environment = new Hashtable();
IUserContext userContext = request.getUser();
if (userContext != null) {
environment.put("NavigationPrincipal", userContext);
String user = userContext.getUniqueName();
if (user != null && !user.equals("")) {
environment.put("User", user);
}
}
return environment;
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Marty,
could look trivial, but if you paste the code of the method getEnvironment from the link in help.sap.com there is one closing parenthesis not needed.
The error is just in the presence of that parentesis, the hashtable is ok!
public class test{
public Hashtable getEnvironment(IPortalComponentRequest request) {
Hashtable environment = new Hashtable();
IUserContext userContext = request.getUser();
if (userContext != null) {
environment.put("NavigationPrincipal", userContext);
String user = userContext.getUniqueName();
if (user != null && !user.equals("")) {
environment.put("User", user);
}//end if on user
}//end if on userContext
return environment;
}//end method getEnvironment
}//<-- THIS IS WRONG!!!!! (CODE PASTED)
}//end class
So Just remove it and it will work!
Kind Regards,
Sergio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
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.