Directory

← Back

AppFoundation

Application foundation provides commonly used features to your Vaadin applications, such as persistence, authentication, permission management, i18n and view helpers.

Author

Rating

Popularity

<100

The add-on's goal is to provide a simple and lightweight foundation for Vaadin application. The add-on consists of individual modules which are designed to be used separately or in combination with other modules. Minimization of dependencies to other modules and third party libraries have been one of the primary goals with the module designs. With the application foundation library you get commonly used features such as JPA based persistence, view handling, i18n, authentication and permission management.

Dependencies: EclipseLink (persistence module) and XOM XML parser (i18n module)

Sample code

User user = new User();
user.setUsername(username);
FacadeFactory.getFacade().store(user);
...
String query = "SELECT u FROM User u WHERE u.username = :username";
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("username", username);

User user = FacadeFactory.getFacade().find(query, parameters);
// Authenticate a user
AuthenticationMessage msg = AuthenticationUtil.authenticate(
                    username, password);

// Get the User object of the currently inlogged used
User user = SessionHandler.get();

// Register a new user
RegistrationMsg msg = UserUtil.registerUser((String) username
                    .getValue(), (String) password.getValue(),
                    (String) verifyPassword.getValue());

// Change the password of a user
ProfileMsg msg = UserUtil.changePassword(user, "currentpassword", 
        "newpassword","newpassword");

public class YourClass {
    ...
    @FieldTranslation(tuid = "USER")
    private String user;

    ...
}


class YourFormFieldFactory implements FormFieldFactory {
  private static final long serialVersionUID = 7983734476850858693L;

  public Field createField(Item item, Object propertyId,
    Component uiContext) {
    TextField field = new TextField();

    // Get the caption of the field from the YourClass class's
    // field's @FieldTranslation-annotation.
    field.setCaption(TranslationUtil.getFieldTranslation(
    YourClass.class, (String) propertyId));   
    field.setRequired(true);
    // Add a translated error message
    field
      .setRequiredError(InternationalizationServlet
      .getMessage(Locale.getDefault().getLanguage(), 
	  "ERROR_FIELD_MAY_NOT_BE_EMPTY"));
    field.setNullRepresentation("");
    return field;
  }
}
// Example of a view class
public class YourView extends AbstractView<Panel> implements
        ClickListener {
  ...
  public AdModificationView() {
    super(new Panel());
    ...
  }

  ...
}

// Example of a view container class
public class MainView extends CustomComponent implements ViewContainer {

  private VerticalLayout mainLayout = new VerticalLayout();
  private AbstractView<?> currentView = null;
  ...
   public MainView() {
    setCompositionRoot(mainLayout);
    ...
    ViewHandler.addView(YourView.class, this);
    ...
  }

  @Override
  public void activate(AbstractView<?> view) {
    if(currentView != null) {
      mainLayout.replaceComponent(currentView, view);
    } else {
      mainLayout.addComponent(view);
    }

    currentView = view;
  }

  ...
}


// Example of a method invoking the activation of a view
public class SomeClass {
  ...
  public void someMethod() {
    // This will trigger the MainView's activate()-method
    // with an instance of the YourView class
    ViewHandler.activateView(YourView.class);
  }
  ...
}


Permissions.initialize(application, new MemoryPermissionManager());

Role visitors = getVisitorRole();
Role regUsers = getRegisteredUsersRole();
Resource newsFeedView = getNewsFeedView();

Permissions.allow(visitors, "read", newsFeedView);
Permissions.allow(regUsers, "comment", newsFeedView);

// Before opening the resource, we can check the user's permissions
if(Permissions.hasAccess("read", newsFeedView)) {
	layout.addComponent(newsFeedView);
}

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Released
2010-02-27
Maturity
BETA
License
Apache License 2.0

Compatibility

Framework
Vaadin 6.0+
Vaadin 6.2+ in 1.0
Vaadin 7.0+ in 2.0.0
Browser
Browser Independent

AppFoundation - Vaadin Add-on Directory

Application foundation provides commonly used features to your Vaadin applications, such as persistence, authentication, permission management, i18n and view helpers. AppFoundation - Vaadin Add-on Directory
The add-on's goal is to provide a simple and lightweight foundation for Vaadin application. The add-on consists of individual modules which are designed to be used separately or in combination with other modules. Minimization of dependencies to other modules and third party libraries have been one of the primary goals with the module designs. With the application foundation library you get commonly used features such as JPA based persistence, view handling, i18n, authentication and permission management. Dependencies: EclipseLink (persistence module) and XOM XML parser (i18n module)
Javadoc
Live demo
Demo source
Issue Tracker
Give feedback
Project home
Documentation

AppFoundation version 1.0
null

AppFoundation version 1.0.1
null

AppFoundation version 1.0.2
null

AppFoundation version 1.1.0
null

AppFoundation version 1.2
null

AppFoundation version 1.3.0
- Protection against brute force attacks - Password policies - Deactivation of views - Default implementation for the ViewContainer

AppFoundation version 1.3.1
There was a packaging problem in the 1.3.0 release, it is fixed now.

AppFoundation version 1.3.2
- Bug fixed in the initialization of Permissions class - Added methods for removing permissions in the authorization module - AbstractView replaced with a View interface in the view handling logic - AbstractView implements View, so existing code will work with minimal changes

AppFoundation version 1.3.3
- ViewHandler now supports URI fragment parameters - The FillXml tool can add new languages to existing translation files

AppFoundation version 1.3.4
- Added a I18nForm for making forms with localized field captions - Added the possibility to fetch a subset of POJOs with the facades' list() methods - Added a getFieldValues() method for fetching the values of one specific field in a POJO

AppFoundation version 1.3.5
- Oracle XE compatible - Ability to use any format for importing translation messages - ViewItem's getView throws a NullPointerException if both view and factory instances are null For more details, please see http://code.google.com/p/vaadin-appfoundation/wiki/ReleaseNotes

AppFoundation version 2.0.0
Version 2.0.0 supports (only) Vaadin 7. It's maturity level is experimental, because it has not been tested sufficiently to be able to have it's maturity level as something else. If you find bugs, please file tickets to the issue tracker.

Online