Example usage for com.liferay.portal.kernel.repository.model RepositoryModel toEscapedModel

List of usage examples for com.liferay.portal.kernel.repository.model RepositoryModel toEscapedModel

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.repository.model RepositoryModel toEscapedModel.

Prototype

public T toEscapedModel();

Source Link

Usage

From source file:com.liferay.taglib.ui.SearchContainerRowTag.java

License:Open Source License

protected void processRow() {
    Object model = _results.get(_rowIndex);

    if (isEscapedModel()) {
        if (model instanceof BaseModel) {
            BaseModel<?> baseModel = (BaseModel<?>) model;

            model = baseModel.toEscapedModel();
        } else if (model instanceof RepositoryModel) {
            RepositoryModel<?> repositoryModel = (RepositoryModel<?>) model;

            model = repositoryModel.toEscapedModel();
        }//  w w w  .  j ava2  s. co  m
    }

    if (Validator.isNull(_keyProperty)) {
        String primaryKey = String.valueOf(model);

        _row = new ResultRow(model, primaryKey, _rowIndex, _bold);
    } else if (isStringKey()) {
        String primaryKey = BeanPropertiesUtil.getString(model, _keyProperty);

        _row = new ResultRow(model, primaryKey, _rowIndex, _bold);
    } else {
        Object primaryKey = BeanPropertiesUtil.getObject(model, _keyProperty);

        _row = new ResultRow(model, String.valueOf(primaryKey), _rowIndex, _bold);
    }

    pageContext.setAttribute(_indexVar, _rowIndex);
    pageContext.setAttribute(_modelVar, model);
    pageContext.setAttribute(_rowVar, _row);
}