Commit acfb7e26 authored by michael.simon's avatar michael.simon
Browse files

Add admin pages to edit and add page templates

parent f6382725
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.bean.admin.tpl;
import java.io.Serializable;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import edu.kit.scc.webreg.entity.VelocityTemplateEntity;
import edu.kit.scc.webreg.service.tpl.VelocityTemplateService;
import edu.kit.scc.webreg.util.ViewIds;
@Named
@ViewScoped
public class AddTemplateBean implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
private VelocityTemplateService service;
private VelocityTemplateEntity entity;
public String save() {
entity = service.save(entity);
return ViewIds.EDIT_PAGE_TEMPLATE + "?faces-redirect=true&id=" + entity.getId();
}
public VelocityTemplateEntity getEntity() {
if (entity == null) {
entity = service.createNew();
}
return entity;
}
public void setEntity(VelocityTemplateEntity entity) {
this.entity = entity;
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.bean.admin.tpl;
import java.io.Serializable;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import edu.kit.scc.webreg.entity.VelocityTemplateEntity;
import edu.kit.scc.webreg.service.tpl.VelocityTemplateService;
import edu.kit.scc.webreg.util.ViewIds;
@Named
@ViewScoped
public class EditTemplateBean implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
private VelocityTemplateService service;
private VelocityTemplateEntity entity;
private Long id;
public String save() {
entity = service.save(entity);
return ViewIds.SHOW_PAGE_TEMPLATE + "?faces-redirect=true&id=" + entity.getId();
}
public VelocityTemplateEntity getEntity() {
if (entity == null) {
entity = service.findById(id);
}
return entity;
}
public void setEntity(VelocityTemplateEntity entity) {
this.entity = entity;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.bean.admin.tpl;
import java.io.Serializable;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import org.primefaces.model.LazyDataModel;
import edu.kit.scc.webreg.entity.VelocityTemplateEntity;
import edu.kit.scc.webreg.model.GenericLazyDataModelImpl;
import edu.kit.scc.webreg.service.tpl.VelocityTemplateService;
@Named
@ViewScoped
public class ListTemplatesBean implements Serializable {
private static final long serialVersionUID = 1L;
private LazyDataModel<VelocityTemplateEntity> list;
@Inject
private VelocityTemplateService service;
public LazyDataModel<VelocityTemplateEntity> getEntityList() {
if (list == null)
list = new GenericLazyDataModelImpl<VelocityTemplateEntity, VelocityTemplateService, Long>(service);
return list;
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.bean.admin.tpl;
import java.io.Serializable;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import edu.kit.scc.webreg.entity.VelocityTemplateEntity;
import edu.kit.scc.webreg.service.tpl.VelocityTemplateService;
@Named("showTemplateBean")
@RequestScoped
public class ShowTemplateBean implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
private VelocityTemplateService service;
private VelocityTemplateEntity entity;
private Long id;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public VelocityTemplateEntity getEntity() {
if (entity == null) {
entity = service.findById(id);
}
return entity;
}
public void setEntity(VelocityTemplateEntity entity) {
this.entity = entity;
}
}
......@@ -138,6 +138,14 @@ public class ViewIds {
public static final String EDIT_ATTRIBUTE_SOURCE = "/admin/as/edit-attribute-source.xhtml";
public static final String SHOW_ATTRIBUTE_SOURCE = "/admin/as/show-attribute-source.xhtml";
/*
* Page Templates
*/
public static final String LIST_PAGE_TEMPLATES = "/admin/tpl/index.xhtml";
public static final String ADD_PAGE_TEMPLATE = "/admin/tpl/add-template.xhtml";
public static final String SHOW_PAGE_TEMPLATE = "/admin/tpl/show-template.xhtml";
public static final String EDIT_PAGE_TEMPLATE = "/admin/tpl/edit-template.xhtml";
/*
* Public
*/
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:bw="http://www.scc.kit.edu/bwfacelets"
xmlns:p="http://primefaces.org/ui">
<head>
<title></title>
</head>
<body>
<f:view>
<f:metadata>
</f:metadata>
<ui:composition template="/template/default-admin.xhtml">
<ui:param name="title" value="#{messages.title}"/>
<ui:define name="content">
<h:form id="form">
<h2><h:outputText value="#{addPolicyBean.service.name}: #{messages.add_policy}"/></h2>
<div id="panelInline">
<p:panel header="#{messages.policy}">
<p:panelGrid id="baseData" columns="2">
<bw:inputText id="nameField" label="#{messages.name}"
value="#{addPolicyBean.entity.name}" required="true" />
</p:panelGrid>
<p:commandButton id="save" action="#{addPolicyBean.save}" value="#{messages.save}"/>
</p:panel>
</div>
</h:form>
</ui:define>
</ui:composition>
</f:view>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:bw="http://www.scc.kit.edu/bwfacelets"
xmlns:p="http://primefaces.org/ui">
<head>
<title></title>
</head>
<body>
<f:view>
<f:metadata>
<f:viewParam name="id" value="#{editTemplateBean.id}"/>
</f:metadata>
<ui:composition template="/template/default-admin.xhtml">
<ui:param name="title" value="#{messages.title}"/>
<ui:define name="content">
<h:form id="form">
<h2><h:outputText value="#{messages.agreement_texts}: #{editTemplateBean.entity.name}"/></h2>
<p:panel header="#{messages.policy}">
<p:panelGrid id="baseData" columns="2">
<h:outputText value="#{messages.id}:"/>
<h:outputText value="#{editTemplateBean.entity.id}"/>
<bw:inputText id="nameField" label="#{messages.name}"
value="#{editTemplateBean.entity.name}" required="true" />
<h:outputText value="#{messages.template}:"/>
<p:inputTextarea value="#{editTemplateBean.entity.template}" style="width: 600px; height: 300px;"
autoResize="false" />
</p:panelGrid>
<p:commandButton id="save" action="#{editTemplateBean.save}" value="#{messages.save}"/>
</p:panel>
</h:form>
</ui:define>
</ui:composition>
</f:view>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:bw="http://www.scc.kit.edu/bwfacelets"
xmlns:p="http://primefaces.org/ui">
<head>
<title></title>
</head>
<body>
<ui:composition template="/template/default-admin.xhtml">
<ui:param name="title" value="#{messages.title}"/>
<ui:define name="content">
<h:form id="form">
<p:dataTable id="dataTable" var="entity" value="#{listTemplatesBean.entityList}" paginator="true"
lazy="true" rows="15">
<p:column>
<f:facet name="header">
<h:outputText value="#{messages.id}" />
</f:facet>
<h:outputText value="#{entity.id}" />
</p:column>
<p:column sortBy="#{entity.name}" filterBy="#{entity.name}" filterMatchMode="contains">
<f:facet name="header">
<h:outputText value="#{messages.name}" />
</f:facet>
<h:link outcome="show-template.xhtml" value="#{entity.name}">
<f:param name="id" value="#{entity.id}"/>
</h:link>
</p:column>
</p:dataTable>
<h:link outcome="add-template.xhtml" value="#{messages.add_template}"/>
</h:form>
</ui:define>
</ui:composition>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:bw="http://www.scc.kit.edu/bwfacelets"
xmlns:p="http://primefaces.org/ui">
<head>
<title></title>
</head>
<body>
<f:view>
<f:metadata>
<f:viewParam name="id" value="#{showTemplateBean.id}"/>
</f:metadata>
<ui:composition template="/template/default-admin.xhtml">
<ui:param name="title" value="#{messages.title}"/>
<ui:define name="content">
<h:form id="form">
<h2><h:outputText value="#{messages.page_template}: #{showTemplateBean.entity.name}"/></h2>
<p:panel header="#{messages.policy}">
<p:panelGrid id="baseData" columns="2">
<h:outputText value="#{messages.id}:"/>
<h:outputText value="#{showTemplateBean.entity.id}"/>
<h:outputText value="#{messages.name}:"/>
<h:outputText value="#{showTemplateBean.entity.name}"/>
</p:panelGrid>
<h:link outcome="edit-template.xhtml" value="#{messages.edit}">
<f:param name="id" value="#{showTemplateBean.entity.id}"/>
</h:link>
</p:panel>
<p:panel>
<h:outputText style="white-space: pre;" value="#{showTemplateBean.entity.template}" />
</p:panel>
</h:form>
</ui:define>
</ui:composition>
</f:view>
</body>
</html>
......@@ -50,6 +50,9 @@
<li><span class="ui-icon ui-icon-mail-closed" style="display:inline-block; vertical-align: bottom;" />
<h:link outcome="/admin/mail/list-email-templates.xhtml" value="#{messages.email_template}" />
</li>
<li><span class="ui-icon ui-icon-script" style="display:inline-block; vertical-align: bottom;" />
<h:link outcome="/admin/tpl/index.xhtml" value="#{messages.page_template}" />
</li>
<li><span class="ui-icon ui-icon-play" style="display:inline-block; vertical-align: bottom;" />
<h:link outcome="/admin/user/user-events.xhtml" value="#{messages.user_events}" />
</li>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment