Wiki

Imprimir Propiedades
Scrooge installing users module

The users module will allow us to manage user's accounts with different profiles and privileges. First of all we add this module from the Roma console:
./roma.sh add users

A set of files will be created in the current project. The structure and functionality of these files are as follow:
roma-users0.6.jar - Under /lib directory provide the java classes for the module.
applicationContext-users.xml - Under WebContent/WEB-INF with some information like the dependences of the user module.
applicationContext.xml – Where are defined the modules currently installed in the application.
CustomLogin – Under com.gesfor.scrooge.view.domain package. This class extends Login and allow us to login in the application under different profiles. It has two methods: onSuccess() - Where we can define the actions to perform if the introduced user and password corresponds to an existent user account. onError() - Where we define the actions to perform if the user and/or password are incorrect. By default, this class is rendered as “popup” so if we visualize this class in a browser a popup window requiring our user and password will appear.

To indicate what to do when entering a correct user and password we modify the onSuccess() method inside CustomLogin located in com.gesfor.scrooge.view.domain as follow:
@Override
protected void onSuccess() {
super.onSuccess();
ActivityLogHelper.getInstance().log(LoggingConstants.LEVEL_INFO,
ActivityLogCategories.CATEGORY_LOGIN,"Connection from ip: "
+WebRenderServlet.getActiveConnection().getRequest().getRemoteHost());
try {
ObjectContext.getInstance().show(AuthenticatedHomePage.class.newInstance());
} catch (Exception e) {
e.printStackTrace();
}


Note: In order to avoid errors, we must import and add to project build path, the “roma-core” project inside Roma /dev/modules directory.

Inside com.gesfor.scrooge.view.domain package we must create the AuthenticatedHomePage class showed when any user log in. This class is as follow:
@ViewClass(layout = "screen:body") public class AuthenticatedHomePage {
public void products() {
ObjectContext.getInstance().show(new ProductMain());
}
public void savings() {
ObjectContext.getInstance().show(new SavingMain());
}
@FlowAction (next=HomePage.class, position="screen:
body")
public void Logout() {
ObjectContext.getInstance().show(new HomePage());
}
}


Once we have fixed the required imports we can observe that different methods redirects the flow to the classes generated with the ./roma.sh crud command. Specifically the NameMain classes (where name is the name of the class which we have generated a CRUD).

1320 Accesos, 0 Ficheros adjuntos 0 Ficheros adjuntos

  • Comentarios