Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
reg-app
Regapp
Commits
f2d94bec
Commit
f2d94bec
authored
Mar 27, 2015
by
michael.simon
Browse files
Make text properties admin editable
parent
fef0c2b7
Changes
4
Hide whitespace changes
Inline
Side-by-side
bwreg-service/src/main/java/edu/kit/scc/webreg/service/TextPropertyService.java
0 → 100644
View file @
f2d94bec
/*******************************************************************************
* 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.service
;
import
edu.kit.scc.webreg.entity.TextPropertyEntity
;
public
interface
TextPropertyService
extends
BaseService
<
TextPropertyEntity
,
Long
>
{
TextPropertyEntity
findAllBySingleton
(
String
key
,
String
language
);
}
bwreg-service/src/main/java/edu/kit/scc/webreg/service/impl/TextPropertyServiceImpl.java
0 → 100644
View file @
f2d94bec
/*******************************************************************************
* 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.service.impl
;
import
javax.ejb.Stateless
;
import
javax.inject.Inject
;
import
edu.kit.scc.webreg.dao.BaseDao
;
import
edu.kit.scc.webreg.dao.TextPropertyDao
;
import
edu.kit.scc.webreg.entity.TextPropertyEntity
;
import
edu.kit.scc.webreg.service.TextPropertyService
;
@Stateless
public
class
TextPropertyServiceImpl
extends
BaseServiceImpl
<
TextPropertyEntity
,
Long
>
implements
TextPropertyService
{
private
static
final
long
serialVersionUID
=
1L
;
@Inject
private
TextPropertyDao
dao
;
@Override
public
TextPropertyEntity
findAllBySingleton
(
String
key
,
String
language
)
{
return
dao
.
findByKeyAndLang
(
key
,
language
);
}
@Override
protected
BaseDao
<
TextPropertyEntity
,
Long
>
getDao
()
{
return
dao
;
}
}
bwreg-webapp/src/main/java/edu/kit/scc/webreg/bean/admin/config/TextPropertyBean.java
0 → 100644
View file @
f2d94bec
/*******************************************************************************
* 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.config
;
import
java.io.Serializable
;
import
javax.faces.bean.ManagedBean
;
import
javax.faces.bean.ViewScoped
;
import
javax.faces.event.ComponentSystemEvent
;
import
javax.inject.Inject
;
import
org.primefaces.model.LazyDataModel
;
import
edu.kit.scc.webreg.entity.TextPropertyEntity
;
import
edu.kit.scc.webreg.model.GenericLazyDataModelImpl
;
import
edu.kit.scc.webreg.service.TextPropertyService
;
@ManagedBean
@ViewScoped
public
class
TextPropertyBean
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@Inject
private
TextPropertyService
service
;
private
Boolean
initialized
=
false
;
private
LazyDataModel
<
TextPropertyEntity
>
list
;
private
String
newKey
,
newLang
,
newValue
;
public
void
preRenderView
(
ComponentSystemEvent
ev
)
{
if
(!
initialized
)
{
init
();
initialized
=
true
;
}
}
private
void
init
()
{
list
=
new
GenericLazyDataModelImpl
<
TextPropertyEntity
,
TextPropertyService
,
Long
>(
service
);
}
public
void
save
(
TextPropertyEntity
tp
)
{
tp
=
service
.
save
(
tp
);
init
();
}
public
void
create
()
{
TextPropertyEntity
tp
=
service
.
createNew
();
tp
.
setKey
(
newKey
);
tp
.
setLanguage
(
newLang
);
tp
.
setValue
(
newValue
);
tp
=
service
.
save
(
tp
);
}
public
void
delete
(
TextPropertyEntity
tp
)
{
newKey
=
tp
.
getKey
();
newLang
=
tp
.
getLanguage
();
newValue
=
tp
.
getValue
();
service
.
delete
(
tp
);
}
public
LazyDataModel
<
TextPropertyEntity
>
getList
()
{
return
list
;
}
public
void
setList
(
LazyDataModel
<
TextPropertyEntity
>
list
)
{
this
.
list
=
list
;
}
public
String
getNewKey
()
{
return
newKey
;
}
public
void
setNewKey
(
String
newKey
)
{
this
.
newKey
=
newKey
;
}
public
String
getNewLang
()
{
return
newLang
;
}
public
void
setNewLang
(
String
newLang
)
{
this
.
newLang
=
newLang
;
}
public
String
getNewValue
()
{
return
newValue
;
}
public
void
setNewValue
(
String
newValue
)
{
this
.
newValue
=
newValue
;
}
}
bwreg-webapp/src/main/webapp/admin/config/text-property.xhtml
0 → 100644
View file @
f2d94bec
<!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"
xmlns:of=
"http://omnifaces.org/functions"
>
<head>
<title></title>
</head>
<body>
<f:view>
<f:metadata>
<f:event
type=
"javax.faces.event.PreRenderViewEvent"
listener=
"#{textPropertyBean.preRenderView}"
/>
</f:metadata>
<ui:composition
template=
"/template/default-admin.xhtml"
>
<ui:param
name=
"title"
value=
"#{messages.title}"
/>
<ui:define
name=
"content"
>
<h:form
id=
"form"
>
<div
id=
"panelInline"
>
<p:dataTable
id=
"dataTable"
var=
"tp"
value=
"#{textPropertyBean.list}"
paginator=
"true"
lazy=
"true"
rows=
"15"
>
<p:column
sortBy=
"#{tp.id}"
style=
"width:36px;"
>
<f:facet
name=
"header"
>
<h:outputText
value=
"#{messages.id}"
/>
</f:facet>
<h:outputText
value=
"#{tp.id}"
/>
</p:column>
<p:column
sortBy=
"#{tp.key}"
filterBy=
"#{tp.key}"
style=
"width:192px;"
>
<f:facet
name=
"header"
>
<h:outputText
value=
"#{messages.key}"
/>
</f:facet>
<h:outputText
value=
"#{tp.key}"
/>
</p:column>
<p:column
sortBy=
"#{tp.language}"
filterBy=
"#{tp.language}"
style=
"width:128px;"
>
<f:facet
name=
"header"
>
<h:outputText
value=
"#{messages.language}"
/>
</f:facet>
<h:outputText
value=
"#{tp.language}"
/>
</p:column>
<p:column
sortBy=
"#{tp.value}"
filterBy=
"#{tp.value}"
>
<f:facet
name=
"header"
>
<h:outputText
value=
"#{messages.value}"
/>
</f:facet>
<p:inplace
id=
"ajax"
editor=
"true"
>
<p:ajax
event=
"save"
listener=
"#{textPropertyBean.save(tp)}"
update=
":form:dataTable"
/>
<p:inputText
value=
"#{tp.value}"
/>
</p:inplace>
</p:column>
<p:column
style=
"width:36px;"
>
<p:commandButton
icon=
"ui-icon-trash"
actionListener=
"#{textPropertyBean.delete(tp)}"
update=
":form:dataTable :form:newPropTable"
/>
</p:column>
</p:dataTable>
<h:panelGrid
id=
"newPropTable"
columns=
"3"
columnClasses=
"labelColumn, elementColumn"
>
<h:inputText
id=
"key_input"
value=
"#{textPropertyBean.newKey}"
/>
<h:inputText
id=
"lang_input"
value=
"#{textPropertyBean.newLang}"
/>
<h:inputText
id=
"value_input"
value=
"#{textPropertyBean.newValue}"
/>
<h:commandLink
value=
"#{messages.add}"
action=
"#{textPropertyBean.create()}"
>
<f:ajax
execute=
"form"
render=
":form:dataTable :form:newPropTable"
/>
</h:commandLink>
</h:panelGrid>
</div>
</h:form>
</ui:define>
</ui:composition>
</f:view>
</body>
</html>
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment