on 05-05-2009 4:44 PM
Hello
I am trying to pass the first role in the array to a context attribute
but the request method is marked in red and the complier doesnt accept it
public void wdDoInit()
{
//@@begin wdDoInit()
// get Portal User
IUserFactory userFactory= UMFactory.getUserFactory();
try
{
IUser User = userFactory.getUser(request.getUser().getUniqueID());
String[] s=((IRoleFactory) UMFactory.getRoleFactory()).getRolesOfUser(User.getUniqueID(),true);
String strtest = s[0];
wdContext.getCurrentElement().setAttributeValue("Role",strtest);
}
catch (UMException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
//System.out.println(e.getMessage());
}
//@@end
}
any ideas?
>
> Hello
>
> I am trying to pass the first role in the array to a context attribute
> but the request method is marked in red and the complier doesnt accept it
>
> public void wdDoInit() > { > //@@begin wdDoInit() > // get Portal User > IUserFactory userFactory= UMFactory.getUserFactory(); > > try > { > > IUser User = userFactory.getUser(request.getUser().getUniqueID()); > String[] s=((IRoleFactory) UMFactory.getRoleFactory()).getRolesOfUser(User.getUniqueID(),true); > String strtest = s[0]; > wdContext.getCurrentElement().setAttributeValue("Role",strtest); > > } > catch (UMException e) > { > // TODO Auto-generated catch block > e.printStackTrace(); > //System.out.println(e.getMessage()); > > } > > > > //@@end > } > >
>
> any ideas?
Hi,
Have you declared the variable request
Ex:
IWDRequest request;
Some thing like this?
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Use the below code...
String strRoleName=null;
try
{
IUserFactory ufactory=UMFactory.getUserFactory();
IRoleFactory rfcat=UMFactory.getRoleFactory();
IUser myuser=ufactory.getUserByLogonID("ssistu");
// IUserAccount uacc=uafactory.getMutableUserAccount(myuser.getUniqueID());
Iterator i=myuser.getRoles(true);
IRole urole=null;
while(i.hasNext())
{
String s=(String)i.next();
urole=rfcat.getRole(s);
strRoleName=urole.getDisplayName();
wdComponentAPI.getMessageManager().reportSuccess("urole.getDisplayName()"+urole.getDisplayName());
}
}
catch(Exception e)
{
wdComponentAPI.getMessageManager().reportSuccess("Exception "+e);
}
now to assign this role to a Conext attribute..
say , attribute is Va_RoleName of String type and Node name iv Vn_Role
then..
wdContext.currentVn_RoleElement().setVa_RoleName(strRoleName);
Hope this helps you...
Regards,
Srinivas
Thx Ayyapparaj
is this is right way of assigning value to context attribute ?
the attribute Role is under folder RoleNode
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
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.