CCM NG: Renamed classes ending with "Builder" in in the pagemodel packages to end with "Renderer" to avoid confusion. Classes with a name ending with "Builder" are usually classes which implement the Builder pattern. The classes rendering a page model and its components do not implemement this pattern.
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5071 8810af33-2d31-482b-a856-94f89814c4df
Former-commit-id: cac7214f83
pull/2/head
parent
9dac93e17a
commit
3b971b3682
|
|
@ -21,7 +21,6 @@ package org.librecms.pagemodel;
|
|||
import com.arsdigita.kernel.KernelConfig;
|
||||
|
||||
import org.libreccm.configuration.ConfigurationManager;
|
||||
import org.libreccm.pagemodel.ComponentBuilder;
|
||||
import org.libreccm.security.PermissionChecker;
|
||||
import org.librecms.contentsection.ContentItem;
|
||||
import org.librecms.contentsection.ContentItemL10NManager;
|
||||
|
|
@ -42,13 +41,15 @@ import javax.ws.rs.core.Response;
|
|||
|
||||
import static org.librecms.pages.PagesConstants.*;
|
||||
|
||||
import org.libreccm.pagemodel.ComponentRenderer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class AbstractContentItemComponentBuilder<T extends ContentItemComponent>
|
||||
implements ComponentBuilder<T> {
|
||||
public abstract class AbstractContentItemComponentRenderer<T extends ContentItemComponent>
|
||||
implements ComponentRenderer<T> {
|
||||
|
||||
@Inject
|
||||
private ConfigurationManager confManager;
|
||||
|
|
@ -70,7 +71,7 @@ public abstract class AbstractContentItemComponentBuilder<T extends ContentItemC
|
|||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
@Override
|
||||
public Map<String, Object> buildComponent(
|
||||
public Map<String, Object> renderComponent(
|
||||
final T componentModel,
|
||||
final Map<String, Object> parameters) {
|
||||
|
||||
|
|
@ -48,8 +48,8 @@ import static org.librecms.pages.PagesConstants.*;
|
|||
*/
|
||||
@RequestScoped
|
||||
@ComponentModelType(componentModel = CategorizedItemComponent.class)
|
||||
public class CategorizedItemComponentBuilder
|
||||
extends AbstractContentItemComponentBuilder<CategorizedItemComponent> {
|
||||
public class CategorizedItemComponentRenderer
|
||||
extends AbstractContentItemComponentRenderer<CategorizedItemComponent> {
|
||||
|
||||
@Inject
|
||||
private CategoryRepository categoryRepo;
|
||||
|
|
@ -27,7 +27,6 @@ import org.libreccm.categorization.DomainRepository;
|
|||
import org.libreccm.configuration.ConfigurationManager;
|
||||
import org.libreccm.core.CcmObject;
|
||||
import org.libreccm.l10n.GlobalizationHelper;
|
||||
import org.libreccm.pagemodel.ComponentBuilder;
|
||||
import org.libreccm.pagemodel.ComponentModelType;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
|
@ -43,45 +42,41 @@ import javax.transaction.Transactional;
|
|||
|
||||
import static org.librecms.pages.PagesConstants.*;
|
||||
|
||||
import org.libreccm.pagemodel.ComponentRenderer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@ComponentModelType(componentModel = CategoryTreeComponent.class)
|
||||
public class CategoryTreeComponentBuilder
|
||||
implements ComponentBuilder<CategoryTreeComponent> {
|
||||
|
||||
@Inject
|
||||
private DomainRepository domainRepo;
|
||||
|
||||
public class CategoryTreeComponentRenderer
|
||||
implements ComponentRenderer<CategoryTreeComponent> {
|
||||
|
||||
@Inject
|
||||
private CategoryManager categoryManager;
|
||||
|
||||
|
||||
@Inject
|
||||
private CategoryRepository categoryRepo;
|
||||
|
||||
|
||||
@Inject
|
||||
private ConfigurationManager confManager;
|
||||
|
||||
@Inject
|
||||
private GlobalizationHelper globalizationHelper;
|
||||
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
@Override
|
||||
public Map<String, Object> buildComponent(
|
||||
public Map<String, Object> renderComponent(
|
||||
final CategoryTreeComponent componentModel,
|
||||
final Map<String, Object> parameters) {
|
||||
|
||||
|
||||
Objects.requireNonNull(componentModel);
|
||||
Objects.requireNonNull(parameters);
|
||||
|
||||
|
||||
if (!parameters.containsKey(PARAMETER_CATEGORY)) {
|
||||
throw new IllegalArgumentException(
|
||||
"The parameters map passed to this GreetingItem component does "
|
||||
+ "not include the parameter \"category\"");
|
||||
}
|
||||
|
||||
|
||||
if (!(parameters.get(PARAMETER_CATEGORY) instanceof Category)) {
|
||||
throw new IllegalArgumentException(String
|
||||
.format("The parameters map passed to this GreetingItem "
|
||||
|
|
@ -90,14 +85,14 @@ public class CategoryTreeComponentBuilder
|
|||
Category.class.getName(),
|
||||
parameters.get(PARAMETER_CATEGORY).getClass().getName()));
|
||||
}
|
||||
|
||||
|
||||
final Category category = categoryRepo
|
||||
.findById(((CcmObject) parameters.get(PARAMETER_CATEGORY))
|
||||
.getObjectId())
|
||||
.orElseThrow(() -> new IllegalArgumentException(String.format(
|
||||
"No category with ID %d in the database.",
|
||||
((CcmObject) parameters.get(PARAMETER_CATEGORY)).getObjectId())));
|
||||
|
||||
|
||||
final Locale language;
|
||||
if (parameters.containsKey(PARAMETER_LANGUAGE)) {
|
||||
language = new Locale((String) parameters.get(PARAMETER_LANGUAGE));
|
||||
|
|
@ -106,19 +101,19 @@ public class CategoryTreeComponentBuilder
|
|||
.findConfiguration(KernelConfig.class);
|
||||
language = kernelConfig.getDefaultLocale();
|
||||
}
|
||||
|
||||
|
||||
final Map<String, Object> result = new HashMap<>();
|
||||
if (componentModel.isShowFullTree()) {
|
||||
|
||||
|
||||
final Category rootCategory = findRootCategory(category);
|
||||
|
||||
|
||||
result.put("categoryName", rootCategory.getName());
|
||||
result.put("categoryPath",
|
||||
categoryManager.getCategoryPath(rootCategory));
|
||||
result.put("categoryTitle",
|
||||
rootCategory.getTitle().getValue(language));
|
||||
result.put("selected", rootCategory.equals(category));
|
||||
|
||||
|
||||
final List<Map<String, Object>> subCategories = rootCategory
|
||||
.getSubCategories()
|
||||
.stream()
|
||||
|
|
@ -132,7 +127,7 @@ public class CategoryTreeComponentBuilder
|
|||
result.put("categoryPath",
|
||||
categoryManager.getCategoryPath(category));
|
||||
result.put("categoryTitle", category.getTitle().getValue(language));
|
||||
|
||||
|
||||
final List<Map<String, Object>> subCategories = category
|
||||
.getSubCategories()
|
||||
.stream()
|
||||
|
|
@ -142,28 +137,28 @@ public class CategoryTreeComponentBuilder
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
protected Map<String, Object> generateCategory(final Category category,
|
||||
final Locale language) {
|
||||
|
||||
|
||||
final Map<String, Object> result = new HashMap<>();
|
||||
result.put("categoryName", category.getName());
|
||||
result.put("categoryPath", categoryManager.getCategoryPath(category));
|
||||
result.put("categoryTitle", category.getTitle().getValue(language));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
protected Map<String, Object> generateCategoryWithTree(
|
||||
final Category category,
|
||||
final Category selectedCategory,
|
||||
final Locale language) {
|
||||
|
||||
|
||||
final Map<String, Object> result = new HashMap<>();
|
||||
result.put("categoryName", category.getName());
|
||||
result.put("categoryPath", categoryManager.getCategoryPath(category));
|
||||
result.put("categoryTitle", category.getTitle().getValue(language));
|
||||
result.put("selected", selectedCategory.equals(category));
|
||||
|
||||
|
||||
if (!category.getSubCategories().isEmpty()) {
|
||||
final List<Map<String, Object>> subCategories = category
|
||||
.getSubCategories()
|
||||
|
|
@ -174,17 +169,17 @@ public class CategoryTreeComponentBuilder
|
|||
.collect(Collectors.toList());
|
||||
result.put("subCategories", subCategories);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
protected Category findRootCategory(final Category category) {
|
||||
|
||||
|
||||
if (category.getParentCategory() == null) {
|
||||
return category;
|
||||
} else {
|
||||
return findRootCategory(category.getParentCategory());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -21,16 +21,10 @@ package org.librecms.pagemodel;
|
|||
import org.libreccm.pagemodel.ComponentModel;
|
||||
import org.libreccm.pagemodel.PageModel;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.CollectionTable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.ElementCollection;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import static org.librecms.CmsConstants.*;
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ import javax.ws.rs.NotFoundException;
|
|||
*/
|
||||
@RequestScoped
|
||||
@ComponentModelType(componentModel = FixedContentItemComponent.class)
|
||||
public class FixedContentItemComponentBuilder
|
||||
extends AbstractContentItemComponentBuilder<FixedContentItemComponent> {
|
||||
public class FixedContentItemComponentRenderer
|
||||
extends AbstractContentItemComponentRenderer<FixedContentItemComponent> {
|
||||
|
||||
@Inject
|
||||
private ContentItemRepository itemRepo;
|
||||
|
|
@ -41,8 +41,8 @@ import static org.librecms.pages.PagesConstants.*;
|
|||
*/
|
||||
@RequestScoped
|
||||
@ComponentModelType(componentModel = GreetingItemComponent.class)
|
||||
public class GreetingItemComponentBuilder
|
||||
extends AbstractContentItemComponentBuilder<GreetingItemComponent> {
|
||||
public class GreetingItemComponentRenderer
|
||||
extends AbstractContentItemComponentRenderer<GreetingItemComponent> {
|
||||
|
||||
@Inject
|
||||
private CategoryRepository categoryRepo;
|
||||
|
|
@ -76,6 +76,7 @@ public class ItemListComponent extends ComponentModel {
|
|||
joinColumns = {
|
||||
@JoinColumn(name = "ITEM_LIST_ID")
|
||||
})
|
||||
@Column(name = "LIST_ORDER")
|
||||
private List<String> listOrder;
|
||||
|
||||
public boolean isDescending() {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
package org.librecms.pages;
|
||||
|
||||
import org.libreccm.pagemodel.AbstractPageBuilder;
|
||||
import org.libreccm.pagemodel.AbstractPageRenderer;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
@ -30,10 +30,10 @@ import javax.enterprise.context.RequestScoped;
|
|||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
public class CmsPageBuilder extends AbstractPageBuilder {
|
||||
public class CmsPageBuilder extends AbstractPageRenderer {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> buildPage(final Map<String, Object> parameters) {
|
||||
public Map<String, Object> renderPage(final Map<String, Object> parameters) {
|
||||
|
||||
final Map<String, Object> result = new HashMap<>();
|
||||
|
||||
|
|
|
|||
|
|
@ -444,9 +444,9 @@ public class PagesRouter {
|
|||
|
||||
final Map<String, Object> result;
|
||||
if (pageModel == null) {
|
||||
result = pageBuilder.buildPage(parameters);
|
||||
result = pageBuilder.renderPage(parameters);
|
||||
} else {
|
||||
result = pageBuilder.buildPage(pageModel, parameters);
|
||||
result = pageBuilder.renderPage(pageModel, parameters);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -25,40 +25,40 @@ import javax.inject.Inject;
|
|||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* An abstract base class for implementations of the {@link PageBuilder}
|
||||
* An abstract base class for implementations of the {@link PageRenderer}
|
||||
* interface providing some functionality needed by all implementations of the
|
||||
* {@link PageBuilder} interface.
|
||||
* {@link PageRenderer} interface.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractPageBuilder implements PageBuilder {
|
||||
public abstract class AbstractPageRenderer implements PageRenderer {
|
||||
|
||||
@Inject
|
||||
private ComponentBuilderManager componentBuilderManager;
|
||||
private ComponentRendererManager componentRendererManager;
|
||||
|
||||
/**
|
||||
* Build a {@code Page} based on a {@link PageModel}. This implementation
|
||||
* first calls {@link #buildPage()} to create the page object. After that
|
||||
* Renders a {@code Page} based on a {@link PageModel}. This implementation
|
||||
* first calls {@link #renderPage()} to create the page object. After that
|
||||
* all {@link ComponentModel}s of the {@link PageModel} are processed and
|
||||
* the component objects created by the {@link ComponentBuilder}s are added
|
||||
* the component objects created by the {@link ComponentRenderer}s are added
|
||||
* to the page.
|
||||
*
|
||||
* @param pageModel The {@link PageModel} to process.
|
||||
* @param parameters Parameters provided by application which wants to
|
||||
* render a {@link PageModel}. The parameters are passed
|
||||
* the {@link ComponentBuilder}s.
|
||||
* the {@link ComponentRenderer}s.
|
||||
*
|
||||
* @return A page containing all components from the {@link PageModel}.
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> buildPage(final PageModel pageModel,
|
||||
final Map<String, Object> parameters) {
|
||||
public Map<String, Object> renderPage(final PageModel pageModel,
|
||||
final Map<String, Object> parameters) {
|
||||
|
||||
final Map<String, Object> page = buildPage(parameters);
|
||||
final Map<String, Object> page = renderPage(parameters);
|
||||
|
||||
for (final ComponentModel componentModel : pageModel.getComponents()) {
|
||||
final Optional<Object> component = buildComponent(
|
||||
final Optional<Object> component = renderComponent(
|
||||
componentModel, componentModel.getClass(),
|
||||
parameters);
|
||||
if (component.isPresent()) {
|
||||
|
|
@ -71,7 +71,7 @@ public abstract class AbstractPageBuilder implements PageBuilder {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper method for building the components.
|
||||
* Helper method for rendering the components.
|
||||
*
|
||||
* @param <M> Generics variable for the type the component
|
||||
* created.
|
||||
|
|
@ -79,24 +79,24 @@ public abstract class AbstractPageBuilder implements PageBuilder {
|
|||
* @param componentModelClass The class of the {@link ComponentModel}.
|
||||
* @param parameters Parameters provided by application which wants
|
||||
* to render a {@link PageModel}. The parameters
|
||||
* are passed the {@link ComponentBuilder}s.
|
||||
* are passed the {@link ComponentRenderer}s.
|
||||
*
|
||||
* @return The components described by the {@code componentModel}.
|
||||
*/
|
||||
protected <M extends ComponentModel> Optional<Object> buildComponent(
|
||||
protected <M extends ComponentModel> Optional<Object> renderComponent(
|
||||
final ComponentModel componentModel,
|
||||
final Class<M> componentModelClass,
|
||||
final Map<String, Object> parameters) {
|
||||
|
||||
componentBuilderManager.findComponentBuilder(componentModel.getClass());
|
||||
componentRendererManager.findComponentRenderer(componentModel.getClass());
|
||||
|
||||
final Optional<ComponentBuilder<M>> builder = componentBuilderManager
|
||||
.findComponentBuilder(componentModelClass);
|
||||
final Optional<ComponentRenderer<M>> renderer = componentRendererManager
|
||||
.findComponentRenderer(componentModelClass);
|
||||
|
||||
if (builder.isPresent()) {
|
||||
if (renderer.isPresent()) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final M model = (M) componentModel;
|
||||
return Optional.of(builder.get().buildComponent(model, parameters));
|
||||
return Optional.of(renderer.get().renderComponent(model, parameters));
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
|
@ -25,8 +25,8 @@ import java.lang.annotation.RetentionPolicy;
|
|||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Specifies for which component and view technology a {@link ComponentBuilder} builds the
|
||||
* components.
|
||||
* Specifies which type of components a {@link ComponentRenderer} implenentation
|
||||
* renders.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
|
|
@ -36,6 +36,5 @@ import java.lang.annotation.Target;
|
|||
public @interface ComponentModelType {
|
||||
|
||||
Class<? extends ComponentModel> componentModel();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,16 +21,16 @@ package org.libreccm.pagemodel;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A {@code ComponentBuilder} transforms a {@link ComponentModel} into a
|
||||
* A {@code ComponentRenderer} transforms a {@link ComponentModel} into a
|
||||
* component.
|
||||
*
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
* @param <M> Type of the model the component builder processes.
|
||||
* @param <M> Type of the model the component renderer processes.
|
||||
*/
|
||||
public interface ComponentBuilder<M extends ComponentModel> {
|
||||
public interface ComponentRenderer<M extends ComponentModel> {
|
||||
|
||||
Map<String, Object> buildComponent(M componentModel,
|
||||
Map<String, Object> renderComponent(M componentModel,
|
||||
final Map<String, Object> parameters);
|
||||
|
||||
}
|
||||
|
|
@ -30,63 +30,63 @@ import java.util.Optional;
|
|||
|
||||
/**
|
||||
* Provides access to all available implementations of the
|
||||
* {@link ComponentBuilder} interface.
|
||||
* {@link ComponentRenderer} interface.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
public class ComponentBuilderManager {
|
||||
public class ComponentRendererManager {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(
|
||||
ComponentBuilderManager.class);
|
||||
ComponentRendererManager.class);
|
||||
|
||||
@Inject
|
||||
private Instance<ComponentBuilder<?>> componentBuilders;
|
||||
private Instance<ComponentRenderer<?>> componentRenderers;
|
||||
|
||||
/**
|
||||
* Find an implementation of the {@link ComponentBuilder} interface for a
|
||||
* Find an implementation of the {@link ComponentRenderer} interface for a
|
||||
* specific {@link ComponentModel}.
|
||||
*
|
||||
* @param <M> Generic variable for the subtype of
|
||||
* {@link ComponentModel} which is produced by
|
||||
* the {@link ComponentBuilder} implementation.
|
||||
* the {@link ComponentRenderer} implementation.
|
||||
* @param componentModelClass The sub class of the {@link ComponentModel}
|
||||
* for which is processed by the
|
||||
* {@link ComponentBuilder}.
|
||||
* {@link ComponentRenderer}.
|
||||
*
|
||||
* @return An {@link Optional} containing the implementation of the
|
||||
* {@link ComponentBuilder} interface for the specified parameters.
|
||||
* {@link ComponentRenderer} interface for the specified parameters.
|
||||
* If there is no implementation for the specified parameters an
|
||||
* empty {@link Optional} is returned.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <M extends ComponentModel> Optional<ComponentBuilder<M>> findComponentBuilder(
|
||||
public <M extends ComponentModel> Optional<ComponentRenderer<M>> findComponentRenderer(
|
||||
final Class<M> componentModelClass) {
|
||||
|
||||
LOGGER.debug("Trying to find ComponentBuilder for ComponentModel\"{}\""
|
||||
LOGGER.debug("Trying to find ComponentRenderer for ComponentModel\"{}\""
|
||||
+ "and type \"{}\"...",
|
||||
componentModelClass.getName());
|
||||
|
||||
final ComponentModelTypeLiteral literal = new ComponentModelTypeLiteral(
|
||||
componentModelClass);
|
||||
|
||||
final Instance<ComponentBuilder<?>> instance = componentBuilders
|
||||
final Instance<ComponentRenderer<?>> instance = componentRenderers
|
||||
.select(literal);
|
||||
if (instance.isUnsatisfied()) {
|
||||
LOGGER.warn("No ComponentBuilder for component model \"%s\" "
|
||||
LOGGER.warn("No ComponentRenderer for component model \"%s\" "
|
||||
+ "and type \"%s\". Ignoring component model.");
|
||||
return Optional.empty();
|
||||
} else if (instance.isAmbiguous()) {
|
||||
throw new IllegalStateException(String.format(
|
||||
"Multiple ComponentBuilders for component model \"%s\"available. "
|
||||
+ "Something is wrong",
|
||||
"Multiple ComponentRenderers for component model \"%s\"available. "
|
||||
+ "Something is wrong",
|
||||
componentModelClass.getName()));
|
||||
} else {
|
||||
final Iterator<ComponentBuilder<?>> iterator = instance.
|
||||
final Iterator<ComponentRenderer<?>> iterator = instance.
|
||||
iterator();
|
||||
final ComponentBuilder<?> componentBuilder = iterator.next();
|
||||
final ComponentRenderer<?> componentRenderer = iterator.next();
|
||||
|
||||
return Optional.of((ComponentBuilder<M>) componentBuilder);
|
||||
return Optional.of((ComponentRenderer<M>) componentRenderer);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -50,14 +50,14 @@ import javax.persistence.OneToMany;
|
|||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* A {@link PageModel} is used by a {@link PageBuilder} implementation to build
|
||||
* A {@link PageModel} is used by a {@link PageRenderer} implementation to render
|
||||
* a page. The {@code PageModel} specifics which components are used on a page.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*
|
||||
* @see PageModelRepository
|
||||
* @see PageModelManager
|
||||
* @see PageBuilder
|
||||
* @see PageRenderer
|
||||
*/
|
||||
@Entity
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
|
|
|
|||
|
|
@ -20,11 +20,10 @@ package org.libreccm.pagemodel;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* Interface for page builders. A page builder is invoked to build a page a
|
||||
* Interface for page renderers. A page renderer is invoked to render a page of
|
||||
* specific type. An implementation should be a CDI bean which is annotated with
|
||||
* the qualifier {@link PageModelType}.
|
||||
* the qualifier {@link PageModelType}.
|
||||
*
|
||||
* An implementation should add all default components which have to be present
|
||||
* in page. The {@link PageModel} should only specify
|
||||
|
|
@ -33,35 +32,35 @@ import java.util.Map;
|
|||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public interface PageBuilder {
|
||||
public interface PageRenderer {
|
||||
|
||||
/**
|
||||
* Build a page for the view technology supported by this page builder
|
||||
* Render a page for the view technology supported by this page renderer
|
||||
* without any additional components.
|
||||
* {@link #buildPage(org.libreccm.pagemodel.PageModel)} should use this
|
||||
* {@link #renderPage(org.libreccm.pagemodel.PageModel)} should use this
|
||||
* method for creating the default page.
|
||||
*
|
||||
* @param parameters Parameters provided by application which wants to
|
||||
* render a {@link PageModel}. The parameters are passed
|
||||
* the {@link ComponentBuilder}s.
|
||||
* the {@link ComponentRenderer}s.
|
||||
*
|
||||
* @return A page with the default components.
|
||||
*/
|
||||
Map<String, Object> buildPage(Map<String, Object> parameters);
|
||||
Map<String, Object> renderPage(Map<String, Object> parameters);
|
||||
|
||||
/**
|
||||
* Build a page of type {@code P} using the provided {@link PageModel}.
|
||||
* Implementations should call the implementation of {@link #buildPage()}
|
||||
* Render a page of type {@code P} using the provided {@link PageModel}.
|
||||
* Implementations should call the implementation of {@link #renderPage()}
|
||||
* for creating the basic page with the default components.
|
||||
*
|
||||
* @param pageModel The {@link PageModel} from which the page is generated.
|
||||
* @param parameters Parameters provided by application which wants to
|
||||
* render a {@link PageModel}. The parameters are passed
|
||||
* the {@link ComponentBuilder}s.
|
||||
* the {@link ComponentRenderer}s.
|
||||
*
|
||||
* @return The page generated from the provided {@link PageModel}.
|
||||
*/
|
||||
Map<String, Object> buildPage(PageModel pageModel,
|
||||
Map<String, Object> parameters);
|
||||
Map<String, Object> renderPage(PageModel pageModel,
|
||||
Map<String, Object> parameters);
|
||||
|
||||
}
|
||||
|
|
@ -24,19 +24,19 @@
|
|||
* </p>
|
||||
* <p>
|
||||
* The Page Model system allows it to specify which components are used on a
|
||||
* page are therefore which information is displayed on a page. It is intended
|
||||
* page and therefore which information is displayed on a page. It is intended
|
||||
* to be used for public pages (like the item page of a content item category
|
||||
* page in ccm-cms. The Page Model system uses data containers which are read by
|
||||
* some builder classes. Because we are not using any active code in the page
|
||||
* a renderer class. Because we are not using any active code in the page
|
||||
* models this avoids a potential attack point.
|
||||
* </p>
|
||||
* <p>
|
||||
* The central interface is the {@link org.libreccm.pagemodel.PageBuilder}
|
||||
* The central interface is the {@link org.libreccm.pagemodel.PageRenderer}
|
||||
* interface. An implementation of this interface will take a
|
||||
* {@link org.libreccm.pagemodel.PageModel} and process it and create a page
|
||||
* from it using the view technology supported by the implementation.
|
||||
* {@code PageBuilder}s are CDI beans. Implementations can be retrieved using
|
||||
* the {@link org.libreccm.pagemodel.PageBuilderManager#findPageBuilder(String, Class)} method.
|
||||
* {@code PageRenderer}s are CDI beans. Implementations can be retrieved using
|
||||
* the {@link org.libreccm.pagemodel.PageRendererManager#findPageRenderer(String, Class)} method.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue