Resource interface in the Authorization appfoundation module

Hi,
I want to use the Authorization module in the appfoundation add-on, I referred to the documentation in the wiki:

http://code.google.com/p/vaadin-appfoundation/wiki/Authorization

then I implement this in my application,
I can’t define the Resource element:



Resource myView = getMyView();

the
getMyView();
method must return a resource element, such as a registration form fo example:


private Resource getMyView() {
		
		Resource r= (Resource) buildRegisterForm();
		return r;
	}

and that return an error:


com.vaadin.ui.FormLayout cannot be cast to org.vaadin.appfoundation.authorization.Resource

My question is: how can I implements or define a resource??
thanks

Your buildRegisterForm() method must return a Resource, just casting the returned object as a Resource doesn’t actually make it an instance of Resource. It looks like the method returns a FormLayout, so what you need to do is to extend the FormLayout and implement the Resource interface.

public class RegisterForm extends FormLayout implements Resource {
 .....
}

Thanks, it works!!
I want to define a role,
I use this method:


private Role getRegisteredUsersRole() {
		Role role1 = null;
		Set roles = null;
		roles.add("create");
		role1.setRoles(roles);
		
		
		return role1;
	}

but it dose not work,

It’s the same approach ?? do I create a class that implement the Role Interface??
thanks

Your problem has to do with very basic programming - please search the internet for variable initialization in java, what the value “null” means and what NullPointerException means.