Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Linnea Samila
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 1cf9b5cc
authored
Apr 06, 2012
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Menujuttu vielä rikki, mutta kääntyy ja toimii muuten..
1 parent
d84249ae
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
832 additions
and
155 deletions
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/Menubean.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/GenericFacade.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/MenuNavigationFacade.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/MenuitemFacade.java
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/MenubeanLocal.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/MenuNavigation.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/Menuitem.java
code/LanBortalWeb/.metadata/WebContent/WEB-INF/faces-config.pageflow
code/LanBortalWeb/WebContent/WEB-INF/faces-config.xml
code/LanBortalWeb/WebContent/layout/insomnia2/template.xhtml
code/LanBortalWeb/WebContent/utils/flushCache.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/web/TestDataView.java
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/menu/JsfMenuitem.java
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/menu/MenuDataView.java
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/menu/MenuRequestView.java
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/menu/MenuView.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/Menubean.java
0 → 100644
View file @
1cf9b5c
package
fi
.
insomnia
.
bortal
.
beans
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
javax.annotation.security.DeclareRoles
;
import
javax.annotation.security.RolesAllowed
;
import
javax.ejb.EJB
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
fi.insomnia.bortal.enums.apps.BillPermission
;
import
fi.insomnia.bortal.enums.apps.MapPermission
;
import
fi.insomnia.bortal.enums.apps.PollPermission
;
import
fi.insomnia.bortal.enums.apps.SpecialPermission
;
import
fi.insomnia.bortal.enums.apps.UserPermission
;
import
fi.insomnia.bortal.facade.MenuNavigationFacade
;
import
fi.insomnia.bortal.facade.MenuitemFacade
;
import
fi.insomnia.bortal.model.MenuNavigation
;
import
fi.insomnia.bortal.model.Menuitem
;
/**
* Session Bean implementation class Menubean
*/
@Stateless
@LocalBean
@DeclareRoles
(
SpecialPermission
.
S_SUPERADMIN
)
public
class
Menubean
implements
MenubeanLocal
{
public
Menubean
()
{
}
@EJB
private
MenuNavigationFacade
navifacade
;
@EJB
private
MenuitemFacade
menuitemfacade
;
@EJB
private
EventBean
eventbean
;
@EJB
private
PermissionBeanLocal
permbean
;
@Override
public
MenuNavigation
getMenuNavigation
(
String
url
)
{
return
navifacade
.
find
(
url
,
eventbean
.
getCurrentEvent
());
}
@Override
public
List
<
MenuNavigation
>
getTopnavigations
()
{
HashMap
<
Menuitem
,
MenuNavigation
>
ret
=
new
HashMap
<
Menuitem
,
MenuNavigation
>();
for
(
MenuNavigation
navi
:
navifacade
.
findToplevels
())
{
if
((
navi
.
getEvent
()
==
null
&&
ret
.
containsKey
(
navi
.
getItem
())))
continue
;
ret
.
put
(
navi
.
getItem
(),
navi
);
}
ArrayList
<
MenuNavigation
>
retlist
=
new
ArrayList
<
MenuNavigation
>(
ret
.
values
());
if
(
retlist
.
isEmpty
())
{
initializeMenu
();
}
Collections
.
sort
(
retlist
);
return
retlist
;
}
@RolesAllowed
(
SpecialPermission
.
S_SUPERADMIN
)
@Override
public
void
flushDefaultmenu
()
{
navifacade
.
deleteAllDefaults
();
initializeMenu
();
}
public
void
initializeMenu
()
{
// Frontpage
MenuNavigation
frontTopnavi
=
new
MenuNavigation
();
frontTopnavi
.
setKey
(
"topnavi.frontpage"
);
frontTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/index"
),
UserPermission
.
ANYUSER
);
frontTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/create"
),
UserPermission
.
CREATE_NEW
);
frontTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/auth/sendResetMail"
),
UserPermission
.
LOGIN
);
navifacade
.
create
(
frontTopnavi
);
// User
MenuNavigation
userTopnavi
=
new
MenuNavigation
();
userTopnavi
.
setKey
(
"topnavi.user"
);
userTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/edit"
),
UserPermission
.
VIEW_SELF
).
setHeader
(
"submenu.user.userlinks"
);
userTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/changePassword"
),
null
);
userTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/accountEvents"
),
null
);
userTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/place/myGroups"
),
null
);
userTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/place/insertToken"
),
null
);
userTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/sendPicture"
),
null
);
userTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/list"
),
UserPermission
.
VIEW_ALL
).
setHeader
(
"submenu.user.manageuserlinks"
);
userTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/create"
),
UserPermission
.
VIEW_ALL
);
userTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/role/list"
),
UserPermission
.
READ_ROLES
).
setHeader
(
"submenu.user.rolelinks"
);
userTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/role/create"
),
UserPermission
.
WRITE_ROLES
);
userTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/listCardTemplates"
),
UserPermission
.
READ_ROLES
);
userTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/createCardTemplate"
),
UserPermission
.
WRITE_ROLES
);
navifacade
.
create
(
userTopnavi
);
MenuNavigation
placemapTopmenu
=
new
MenuNavigation
();
placemapTopmenu
.
setKey
(
"topnavi.placemap"
);
placemapTopmenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/place/placemap"
),
MapPermission
.
VIEW
);
navifacade
.
create
(
placemapTopmenu
);
MenuNavigation
shopTopmenu
=
new
MenuNavigation
();
shopTopmenu
.
setKey
(
"topnavi.shop"
);
shopTopmenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/shop/createBill"
),
BillPermission
.
CREATE_BILL
);
shopTopmenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/bill/list"
),
BillPermission
.
VIEW_OWN
);
navifacade
.
create
(
shopTopmenu
);
MenuNavigation
pollTopmenu
=
new
MenuNavigation
();
pollTopmenu
.
setKey
(
"topnavi.poll"
);
pollTopmenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/poll/index"
),
PollPermission
.
ANSWER
);
navifacade
.
create
(
pollTopmenu
);
}
}
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/GenericFacade.java
View file @
1cf9b5c
...
@@ -76,8 +76,8 @@ public abstract class GenericFacade<I extends Serializable, C extends ModelInter
...
@@ -76,8 +76,8 @@ public abstract class GenericFacade<I extends Serializable, C extends ModelInter
/**
/**
* Deprekoitu! Yleensä ei haluta palauttaa kaikkia entryjä kannasta, vaan
* Deprekoitu! Yleensä ei haluta palauttaa kaikkia entryjä kannasta, vaan
* vain ko. tapahtumaan / käyttäjään / muuhun olioon liittyvät Jos
oikeasti
* vain ko. tapahtumaan / käyttäjään / muuhun olioon liittyvät Jos
* tarpeellinen luo funktio facadeen!
*
oikeasti
tarpeellinen luo funktio facadeen!
*/
*/
// @Deprecated
// @Deprecated
// public List<C> findAll() {
// public List<C> findAll() {
...
...
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/MenuNavigationFacade.java
0 → 100644
View file @
1cf9b5c
package
fi
.
insomnia
.
bortal
.
facade
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.ejb.EJB
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
javax.persistence.EntityManager
;
import
javax.persistence.PersistenceContext
;
import
javax.persistence.Query
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Path
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.insomnia.bortal.beans.EventBean
;
import
fi.insomnia.bortal.beans.PermissionBeanLocal
;
import
fi.insomnia.bortal.model.LanEvent
;
import
fi.insomnia.bortal.model.MenuNavigation
;
import
fi.insomnia.bortal.model.MenuNavigation_
;
import
fi.insomnia.bortal.model.Menuitem
;
import
fi.insomnia.bortal.model.Menuitem_
;
@Stateless
@LocalBean
public
class
MenuNavigationFacade
extends
GenericFacade
<
Integer
,
MenuNavigation
>
{
public
MenuNavigationFacade
()
{
super
(
MenuNavigation
.
class
);
// TODO Auto-generated constructor stub
}
@EJB
private
MenuitemFacade
menuitemfacade
;
@PersistenceContext
private
EntityManager
em
;
@EJB
private
EventBean
eventbean
;
@EJB
private
PermissionBeanLocal
permbean
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
MenuNavigationFacade
.
class
);
@Override
protected
EntityManager
getEm
()
{
return
em
;
}
public
MenuNavigation
find
(
String
url
,
LanEvent
event
)
{
logger
.
debug
(
"Finding MenuNavigation with url {}"
,
url
);
if
(
url
==
null
||
url
.
isEmpty
())
{
return
null
;
}
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
MenuNavigation
>
cq
=
cb
.
createQuery
(
MenuNavigation
.
class
);
Root
<
MenuNavigation
>
root
=
cq
.
from
(
MenuNavigation
.
class
);
Predicate
eventFilter
=
null
;
if
(
event
==
null
)
{
eventFilter
=
cb
.
isNull
(
root
.
get
(
MenuNavigation_
.
event
));
}
else
{
eventFilter
=
cb
.
equal
(
root
.
get
(
MenuNavigation_
.
event
),
event
);
}
cq
.
where
(
cb
.
equal
(
root
.
get
(
MenuNavigation_
.
item
).
get
(
Menuitem_
.
url
),
url
),
eventFilter
);
cq
.
orderBy
(
cb
.
asc
(
root
.
get
(
MenuNavigation_
.
sort
)));
List
<
MenuNavigation
>
results
=
em
.
createQuery
(
cq
).
getResultList
();
MenuNavigation
ret
=
null
;
for
(
MenuNavigation
navi
:
results
)
{
if
(
permbean
.
hasPermission
(
navi
.
getPermission
()))
{
ret
=
navi
;
}
}
if
(
ret
==
null
&&
!
results
.
isEmpty
())
{
ret
=
results
.
get
(
0
);
}
if
(
ret
==
null
)
{
if
(
event
!=
null
)
{
return
find
(
url
,
null
);
}
else
{
Menuitem
item
=
menuitemfacade
.
findOrCreate
(
url
);
if
(
item
.
getNavigations
()
==
null
||
item
.
getNavigations
().
isEmpty
())
{
ret
=
new
MenuNavigation
();
ret
.
setItem
(
item
);
ret
.
setEvent
(
null
);
item
.
setNavigations
(
new
ArrayList
<
MenuNavigation
>());
item
.
getNavigations
().
add
(
ret
);
}
}
}
return
ret
;
}
/**
* Returns top level navigations for BOTH default and current event Results
* have to be filtered for duplicates to get correct result!!
*
* @param event
* @return
*/
public
List
<
MenuNavigation
>
findToplevels
()
{
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
MenuNavigation
>
cq
=
cb
.
createQuery
(
MenuNavigation
.
class
);
Root
<
MenuNavigation
>
root
=
cq
.
from
(
MenuNavigation
.
class
);
Path
<
LanEvent
>
eventpath
=
root
.
get
(
MenuNavigation_
.
event
);
cq
.
where
(
cb
.
isNull
(
root
.
get
(
MenuNavigation_
.
parent
)),
cb
.
or
(
cb
.
equal
(
eventpath
,
eventbean
.
getCurrentEvent
()),
cb
.
isNull
(
eventpath
)));
return
em
.
createQuery
(
cq
).
getResultList
();
}
public
void
deleteAllDefaults
()
{
Query
q
=
em
.
createQuery
(
"delete from MenuNavigation where parent is null"
);
q
.
executeUpdate
();
}
}
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/MenuitemFacade.java
0 → 100644
View file @
1cf9b5c
package
fi
.
insomnia
.
bortal
.
facade
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
javax.persistence.EntityManager
;
import
javax.persistence.PersistenceContext
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Root
;
import
fi.insomnia.bortal.model.Menuitem
;
import
fi.insomnia.bortal.model.Menuitem_
;
@Stateless
@LocalBean
public
class
MenuitemFacade
extends
GenericFacade
<
Integer
,
Menuitem
>
{
public
MenuitemFacade
()
{
super
(
Menuitem
.
class
);
}
@PersistenceContext
private
EntityManager
em
;
@Override
protected
EntityManager
getEm
()
{
return
em
;
}
public
Menuitem
findOrCreate
(
String
url
)
{
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Menuitem
>
cq
=
cb
.
createQuery
(
Menuitem
.
class
);
Root
<
Menuitem
>
root
=
cq
.
from
(
Menuitem
.
class
);
cq
.
where
(
cb
.
equal
(
root
.
get
(
Menuitem_
.
url
),
url
));
Menuitem
ret
=
super
.
getSingleNullableResult
(
em
.
createQuery
(
cq
));
if
(
ret
==
null
)
{
ret
=
new
Menuitem
();
ret
.
setUrl
(
url
);
create
(
ret
);
}
return
ret
;
}
}
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/MenubeanLocal.java
0 → 100644
View file @
1cf9b5c
package
fi
.
insomnia
.
bortal
.
beans
;
import
java.util.List
;
import
javax.ejb.Local
;
import
fi.insomnia.bortal.model.MenuNavigation
;
@Local
public
interface
MenubeanLocal
{
MenuNavigation
getMenuNavigation
(
String
url
);
List
<
MenuNavigation
>
getTopnavigations
();
void
flushDefaultmenu
();
}
code/LanBortalDatabase/src/fi/insomnia/bortal/model/MenuNavigation.java
0 → 100644
View file @
1cf9b5c
package
fi
.
insomnia
.
bortal
.
model
;
import
static
javax
.
persistence
.
CascadeType
.
ALL
;
import
static
javax
.
persistence
.
CascadeType
.
PERSIST
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.JoinColumn
;
import
javax.persistence.Lob
;
import
javax.persistence.ManyToOne
;
import
javax.persistence.OneToMany
;
import
javax.persistence.OrderBy
;
import
javax.persistence.Table
;
import
javax.persistence.Transient
;
import
org.eclipse.persistence.annotations.PrivateOwned
;
import
fi.insomnia.bortal.enums.BortalApplication
;
import
fi.insomnia.bortal.enums.apps.IAppPermission
;
@Entity
@Table
(
name
=
"menu_navigation"
)
// uniqueConstraints = { @UniqueConstraint(columnNames = {
// MenuNavigation.ITEM_COLUMN, MenuNavigation.EVENT_COLUMN }) })
public
class
MenuNavigation
extends
GenericEntity
implements
Comparable
<
MenuNavigation
>
{
private
static
final
long
serialVersionUID
=
1404769998091479699L
;
protected
static
final
String
EVENT_COLUMN
=
"event_id"
;
protected
static
final
String
ITEM_COLUMN
=
"item_id"
;
@Lob
private
String
key
;
@Lob
private
String
header
;
@Lob
private
String
footer
;
@Column
(
nullable
=
false
)
private
Integer
sort
=
1000
;
@Column
(
nullable
=
false
)
private
boolean
visible
=
false
;
@ManyToOne
(
cascade
=
PERSIST
)
@JoinColumn
(
name
=
ITEM_COLUMN
)
private
Menuitem
item
;
@ManyToOne
()
private
SitePage
sitepage
;
@ManyToOne
@JoinColumn
(
nullable
=
true
,
name
=
EVENT_COLUMN
)
private
LanEvent
event
;
@ManyToOne
@JoinColumn
(
nullable
=
true
)
private
MenuNavigation
parent
;
@OneToMany
(
mappedBy
=
"parent"
,
cascade
=
ALL
)
@PrivateOwned
@OrderBy
(
"sort"
)
private
List
<
MenuNavigation
>
children
;
@Transient
transient
private
IAppPermission
privatePerm
;
@Transient
transient
private
BortalApplication
privateApp
;
private
String
application
;
private
String
permission
;
public
BortalApplication
getApplication
()
{
if
(
privateApp
==
null
&&
application
!=
null
)
{
privateApp
=
BortalApplication
.
valueOf
(
application
);
}
return
privateApp
;
}
public
void
setPermission
(
IAppPermission
perm
)
{
if
(
perm
!=
null
)
{
privatePerm
=
perm
;
privateApp
=
perm
.
getParent
();
this
.
application
=
perm
.
getParent
().
toString
();
this
.
permission
=
perm
.
toString
();
}
}
public
IAppPermission
getPermission
()
{
if
(
privatePerm
==
null
&&
application
!=
null
&&
permission
!=
null
)
{
for
(
IAppPermission
appPerm
:
getApplication
().
getPermissions
())
{
if
(
appPerm
.
toString
().
equals
(
permission
))
{
privatePerm
=
appPerm
;
break
;
}
}
}
return
privatePerm
;
}
public
List
<
MenuNavigation
>
getChildren
()
{
return
children
;
}
public
void
setChildren
(
List
<
MenuNavigation
>
children
)
{
this
.
children
=
children
;
}
public
MenuNavigation
getParent
()
{
return
parent
;
}
public
void
setParent
(
MenuNavigation
parent
)
{
this
.
parent
=
parent
;
}
public
LanEvent
getEvent
()
{
return
event
;
}
public
void
setEvent
(
LanEvent
event
)
{
this
.
event
=
event
;
}
public
Menuitem
getItem
()
{
return
item
;
}
public
void
setItem
(
Menuitem
item
)
{
this
.
item
=
item
;
}
public
String
getFooter
()
{
return
footer
;
}
public
void
setFooter
(
String
footer
)
{
this
.
footer
=
footer
;
}
public
String
getHeader
()
{
return
header
;
}
public
void
setHeader
(
String
header
)
{
this
.
header
=
header
;
}
public
String
getKey
()
{
return
key
;
}
public
void
setKey
(
String
key
)
{
this
.
key
=
key
;
}
public
boolean
isVisible
()
{
return
visible
;
}
public
void
setVisible
(
boolean
visible
)
{
this
.
visible
=
visible
;
}
@Override
public
int
compareTo
(
MenuNavigation
o
)
{
return
sort
.
compareTo
(
o
.
sort
);
}
// used only for initialization function...
public
MenuNavigation
addPage
(
Menuitem
item
,
IAppPermission
permission
)
{
if
(
children
==
null
)
{
children
=
new
ArrayList
<
MenuNavigation
>();
}
MenuNavigation
add
=
new
MenuNavigation
();
add
.
setKey
(
"submenu"
+
item
.
getUrl
().
replace
(
"/"
,
"."
));
add
.
setItem
(
item
);
add
.
setPermission
(
permission
);
add
.
setParent
(
this
);
add
.
setVisible
(
true
);
children
.
add
(
add
);
return
add
;
}
public
SitePage
getSitepage
()
{
return
sitepage
;
}
public
void
setSitepage
(
SitePage
sitepage
)
{
this
.
sitepage
=
sitepage
;
}
}
code/LanBortalDatabase/src/fi/insomnia/bortal/model/Menuitem.java
0 → 100644
View file @
1cf9b5c
package
fi
.
insomnia
.
bortal
.
model
;
import
java.util.List
;
import
javax.persistence.CascadeType
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Lob
;
import
javax.persistence.OneToMany
;
import
javax.persistence.Table
;
import
org.eclipse.persistence.annotations.PrivateOwned
;
@Entity
@Table
(
name
=
"menuitem"
)
public
class
Menuitem
extends
GenericEntity
{
private
static
final
long
serialVersionUID
=
-
3544095800802935237L
;
@Column
(
nullable
=
false
,
unique
=
true
)
private
String
url
;
@Lob
private
String
description
;
@OneToMany
(
mappedBy
=
"item"
,
cascade
=
CascadeType
.
ALL
)
@PrivateOwned
private
List
<
MenuNavigation
>
navigations
;
public
String
getUrl
()
{
return
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
List
<
MenuNavigation
>
getNavigations
()
{
return
navigations
;
}
public
void
setNavigations
(
List
<
MenuNavigation
>
navigations
)
{
this
.
navigations
=
navigations
;
}
}
code/LanBortalWeb/.metadata/WebContent/WEB-INF/faces-config.pageflow
View file @
1cf9b5c
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<pageflow:Pageflow
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:pageflow=
"http://www.sybase.com/suade/pageflow"
id=
"pf13012981621060"
configfile=
"/LanBortalWeb/WebContent/WEB-INF/faces-config.xml"
>
<pageflow:Pageflow
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:pageflow=
"http://www.sybase.com/suade/pageflow"
id=
"pf13012981621060"
configfile=
"/LanBortalWeb/WebContent/WEB-INF/faces-config.xml"
>
<nodes
xsi:type=
"pageflow:PFPage"
name=
"*"
x=
"120"
y=
"60"
id=
"pf131682121330014"
referenceLink=
"//@navigationRule.0/@fromViewId|"
outlinks=
"pf131682121330015 pf13196506256640"
path=
"*"
/>
<nodes
xsi:type=
"pageflow:PFPage"
name=
"*"
x=
"122"
y=
"370"
id=
"pf131682121330014"
referenceLink=
"//@navigationRule.0/@fromViewId|"
outlinks=
"pf131682121330015 pf13196506256640"
path=
"*"
/>
<nodes
xsi:type=
"pageflow:PFPage"
name=
"auth/logoutResponse"
x=
"288"
y=
"60"
id=
"pf131682121330016"
referenceLink=
"//@navigationRule.0/@navigationCase.0/@toViewId|"
inlinks=
"pf131682121330015"
path=
"/auth/logoutResponse"
/>
<nodes
xsi:type=
"pageflow:PFPage"
name=
"auth/logoutResponse"
x=
"338"
y=
"178"
id=
"pf131682121330016"
referenceLink=
"//@navigationRule.0/@navigationCase.0/@toViewId|"
inlinks=
"pf131682121330015"
path=
"/auth/logoutResponse"
/>
<nodes
xsi:type=
"pageflow:PFPage"
name=
"place/placemap"
x=
"264"
y=
"204"
id=
"pf13168224196920"
referenceLink=
"//@navigationRule.2/@navigationCase.0/@toViewId|"
outlinks=
"pf13168224196921"
inlinks=
"pf13168224196921"
path=
"/place/placemap"
/>
<nodes
xsi:type=
"pageflow:PFPage"
name=
"place/placemap"
x=
"122"
y=
"754"
id=
"pf13168224196920"
referenceLink=
"//@navigationRule.2/@navigationCase.0/@toViewId|"
outlinks=
"pf13168224196921"
inlinks=
"pf13168224196921"
path=
"/place/placemap"
/>
<nodes
xsi:type=
"pageflow:PFPage"
name=
"user/sendPicture"
x=
"12"
y=
"192"
id=
"pf13196506256641"
referenceLink=
"//@navigationRule.0/@navigationCase.1/@toViewId|"
inlinks=
"pf13196506256640"
path=
"/user/sendPicture"
/>
<nodes
xsi:type=
"pageflow:PFPage"
name=
"user/sendPicture"
x=
"338"
y=
"562"
id=
"pf13196506256641"
referenceLink=
"//@navigationRule.0/@navigationCase.1/@toViewId|"
inlinks=
"pf13196506256640"
path=
"/user/sendPicture"
/>
<nodes
xsi:type=
"pageflow:PFPage"
name=
"news/edit"
x=
"248"
y=
"312"
id=
"pf13241645918110"
path=
"/news/edit.xhtml"
/>
<nodes
xsi:type=
"pageflow:PFPage"
name=
"news/edit"
x=
"122"
y=
"1138"
id=
"pf13241645918110"
path=
"/news/edit.xhtml"
/>
<nodes
xsi:type=
"pageflow:PFPage"
name=
"news/listAll"
x=
"480"
y=
"269"
id=
"pf13241645918111"
path=
"/news/listAll.xhtml"
/>
<nodes
xsi:type=
"pageflow:PFPage"
name=
"news/listAll"
x=
"122"
y=
"1522"
id=
"pf13241645918111"
path=
"/news/listAll.xhtml"
/>
<nodes
xsi:type=
"pageflow:PFPage"
name=
"news/editNews"
id=
"pf13241648116130"
referenceLink=
"//@navigationRule.1/@fromViewId|"
outlinks=
"pf13241648116141"
path=
"news/editNews"
/>
<nodes
xsi:type=
"pageflow:PFPage"
name=
"actionlog/messagelist"
x=
"122"
y=
"2290"
id=
"pf13336707109910"
referenceLink=
"//@navigationRule.3/@navigationCase.0/@toViewId|"
outlinks=
"pf13336707109911"
inlinks=
"pf13336707109911"
path=
"/actionlog/messagelist.xhtml"
/>
<nodes
xsi:type=
"pageflow:PFPage"
name=
"news/listAll"
id=
"pf13241648116142"
referenceLink=
"//@navigationRule.1/@navigationCase.0/@toViewId|"
inlinks=
"pf13241648116141"
path=
"news/listAll"
/>
<nodes
xsi:type=
"pageflow:PFPage"
name=
"news/editNews"
id=
"pf13336707109912"
referenceLink=
"//@navigationRule.1/@fromViewId|"
outlinks=
"pf13336707109913"
path=
"/news/editNews"
/>
<nodes
xsi:type=
"pageflow:PFPage"
name=
"news/listAll"
id=
"pf13336707109914"
referenceLink=
"//@navigationRule.1/@navigationCase.0/@toViewId|"
inlinks=
"pf13336707109913"
path=
"/news/listAll"
/>
<links
id=
"pf131682121330015"
target=
"pf131682121330016"
source=
"pf131682121330014"
outcome=
"logoutDone"
redirect=
"true"
/>
<links
id=
"pf131682121330015"
target=
"pf131682121330016"
source=
"pf131682121330014"
outcome=
"logoutDone"
redirect=
"true"
/>
<links
id=
"pf13168224196921"
target=
"pf13168224196920"
source=
"pf13168224196920"
outcome=
"placesReserved"
redirect=
"true"
/>
<links
id=
"pf13196506256640"
target=
"pf13196506256641"
source=
"pf131682121330014"
outcome=
"redirToUserimage"
redirect=
"true"
/>
<links
id=
"pf13196506256640"
target=
"pf13196506256641"
source=
"pf131682121330014"
outcome=
"redirToUserimage"
redirect=
"true"
/>
<links
id=
"pf13241648116141"
target=
"pf13241648116142"
source=
"pf13241648116130"
outcome=
"news/listAll"
redirect=
"true"
/>
<links
id=
"pf13168224196921"
target=
"pf13168224196920"
source=
"pf13168224196920"
outcome=
"placesReserved"
redirect=
"true"
>
<bendPoints
d1Height=
"-36"
d2Height=
"-36"
/>
<bendPoints
d1Width=
"-64"
d1Height=
"-36"
d2Width=
"-64"
d2Height=
"-36"
/>
<bendPoints
d1Width=
"-64"
d2Width=
"-64"
/>
</links>
<links
id=
"pf13336707109911"
target=
"pf13336707109910"
source=
"pf13336707109910"
outcome=
"success"
redirect=
"true"
>
<bendPoints
d1Height=
"-36"
d2Height=
"-36"
/>
<bendPoints
d1Width=
"-64"
d1Height=
"-36"
d2Width=
"-64"
d2Height=
"-36"
/>
<bendPoints
d1Width=
"-64"
d2Width=
"-64"
/>
</links>
<links
id=
"pf13336707109913"
target=
"pf13336707109914"
source=
"pf13336707109912"
outcome=
"news/listAll"
redirect=
"true"
/>
</pageflow:Pageflow>
</pageflow:Pageflow>
code/LanBortalWeb/WebContent/WEB-INF/faces-config.xml
View file @
1cf9b5c
...
@@ -64,10 +64,10 @@
...
@@ -64,10 +64,10 @@
<navigation-rule>
<navigation-rule>
<from-view-id>
news/editNews
</from-view-id>
<from-view-id>
/
news/editNews
</from-view-id>
<navigation-case>
<navigation-case>
<from-outcome>
news/listAll
</from-outcome>
<from-outcome>
news/listAll
</from-outcome>
<to-view-id>
news/listAll
</to-view-id>
<to-view-id>
/
news/listAll
</to-view-id>
<redirect/>
<redirect/>
</navigation-case>
</navigation-case>
</navigation-rule>
</navigation-rule>
...
...
code/LanBortalWeb/WebContent/layout/insomnia2/template.xhtml
View file @
1cf9b5c
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:tools=
"http://java.sun.com/jsf/composite/cditools"
xmlns:tools=
"http://java.sun.com/jsf/composite/cditools"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
<f:view
contentType=
"text/html"
locale=
"#{sessionHandler.locale}"
>
<f:view
contentType=
"text/html"
locale=
"#{sessionHandler.locale}"
>
<h:head>
<h:head>
...
@@ -31,9 +29,7 @@
...
@@ -31,9 +29,7 @@
</div>
</div>
<div
id=
"login"
>
<div
id=
"login"
>
<h:outputText
rendered=
"#{sessionHandler.loggedIn}"
<h:outputText
rendered=
"#{sessionHandler.loggedIn}"
value=
"Olet kirjautunut käyttäjällä: #{sessionHandler.currentUser.nick}"
/>
value=
"Olet kirjautunut käyttäjällä: #{sessionHandler.currentUser.nick}"
/>
<tools:loginLogout
/>
<tools:loginLogout
/>
</div>
</div>
...
@@ -42,9 +38,7 @@
...
@@ -42,9 +38,7 @@
<div
id=
"wrapper"
>
<div
id=
"wrapper"
>
<div
id=
"navigation"
>
<div
id=
"navigation"
>
<ul
class=
"menu"
jsfc=
"ui:repeat"
var=
"menuitem"
value=
"#{menuView.topmenu}"
>
<ul
class=
"menu"
jsfc=
"ui:repeat"
var=
"menuitem"
value=
"#{menuView.topmenu}"
>
<li><h:link
outcome=
"#{menuitem.outcome}"
value=
"#{menuitem.linktext}"
<li><h:link
outcome=
"#{menuitem.outcome}"
value=
"#{i18n[menuitem.navigation.key]}"
styleClass=
"#{menuitem.selected?'active':''}"
/></li>
styleClass=
"#{menuitem.selected?'active':''}"
/></li>
</ul>
</ul>
</div>
</div>
<div
id=
"container"
class=
"top"
/>
<div
id=
"container"
class=
"top"
/>
...
@@ -59,12 +53,9 @@
...
@@ -59,12 +53,9 @@
<ul
class=
"menu"
>
<ul
class=
"menu"
>
<ui:repeat
var=
"menuitem"
value=
"#{menuView.submenu}"
>
<ui:repeat
var=
"menuitem"
value=
"#{menuView.submenu}"
>
<h:outputText
rendered=
"#{!empty menuitem.header}"
<h:outputText
rendered=
"#{!empty menuitem.header}"
value=
"</ul><h1>#{i18n[menuitem.header]}</h1><ul>"
escape=
"false"
/>
value=
"</ul><h1>#{i18n[menuitem.header]}</h1><ul>"
escape=
"false"
<li>
/>
<h:link
outcome=
"#{menuitem.outcome}"
value=
"#{i18n[menuitem.navigation.key]}"
styleClass=
"#{menuitem.selected?'active':''}"
/>
<li><h:link
outcome=
"#{menuitem.outcome}"
value=
"#{menuitem.linktext}"
styleClass=
"#{menuitem.selected?'active':''}"
/>
</li>
</li>
</ui:repeat>
</ui:repeat>
</ul>
</ul>
...
...
code/LanBortalWeb/WebContent/utils/flushCache.xhtml
View file @
1cf9b5c
<!DOCTYPE html
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:users=
"http://java.sun.com/jsf/composite/tools/user"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
xmlns:h=
"http://java.sun.com/jsf/html"
<h:body>
xmlns:f=
"http://java.sun.com/jsf/core"
<ui:composition
template=
"/layout/#{sessionHandler.layout}/template.xhtml"
>
xmlns:users=
"http://java.sun.com/jsf/composite/tools/user"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition
template=
"/layout/#{sessionHandler.layout}/template.xhtml"
>
<ui:param
name=
"thispage"
value=
"page.eventorg.edit"
/>
<ui:param
name=
"thispage"
value=
"page.eventorg.edit"
/>
<ui:define
name=
"content"
>
<ui:define
name=
"content"
>
#{sessionHandler.flushCache()}
#{sessionHandler.flushCache()}
<h:form>
<h:commandButton
action=
"#{testView.resetMenu()}"
value=
"Reset menu"
onclick=
"return confirm('THIS WILL RESET ALL MODIFICATIONS TO DEFAULT MENU!!\n Are you really sure?!');"
/>
</h:form>
</ui:define>
</ui:define>
</ui:composition>
</ui:composition>
</h:body>
</h:body>
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/TestDataView.java
View file @
1cf9b5c
...
@@ -15,6 +15,7 @@ import org.slf4j.LoggerFactory;
...
@@ -15,6 +15,7 @@ import org.slf4j.LoggerFactory;
import
fi.insomnia.bortal.beans.CardTemplateBeanLocal
;
import
fi.insomnia.bortal.beans.CardTemplateBeanLocal
;
import
fi.insomnia.bortal.beans.EventBeanLocal
;
import
fi.insomnia.bortal.beans.EventBeanLocal
;
import
fi.insomnia.bortal.beans.MenubeanLocal
;
import
fi.insomnia.bortal.beans.PollBeanLocal
;
import
fi.insomnia.bortal.beans.PollBeanLocal
;
import
fi.insomnia.bortal.beans.RoleBeanLocal
;
import
fi.insomnia.bortal.beans.RoleBeanLocal
;
import
fi.insomnia.bortal.beans.TestDataBeanLocal
;
import
fi.insomnia.bortal.beans.TestDataBeanLocal
;
...
@@ -49,12 +50,20 @@ public class TestDataView {
...
@@ -49,12 +50,20 @@ public class TestDataView {
private
EventBeanLocal
eventbean
;
private
EventBeanLocal
eventbean
;
@EJB
@EJB
private
PollBeanLocal
pollbean
;
private
PollBeanLocal
pollbean
;
@EJB
private
MenubeanLocal
menubean
;
public
void
convertUsernames
()
{
public
void
convertUsernames
()
{
utilbean
.
convertUsernames
();
utilbean
.
convertUsernames
();
}
}
public
String
resetMenu
()
{
menubean
.
flushDefaultmenu
();
return
null
;
}
// public void generateTestMap() {
// public void generateTestMap() {
// EventMap map = testdatabean.generateTestMap();
// EventMap map = testdatabean.generateTestMap();
//
//
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/menu/JsfMenuitem.java
View file @
1cf9b5c
package
fi
.
insomnia
.
bortal
.
web
.
cdiview
.
menu
;
package
fi
.
insomnia
.
bortal
.
web
.
cdiview
.
menu
;
import
fi.insomnia.bortal.model.SitePage
;
import
fi.insomnia.bortal.model.MenuNavigation
;
import
fi.insomnia.bortal.model.Menuitem
;
public
class
JsfMenuitem
{
public
class
JsfMenuitem
{
private
final
Menuitem
item
;
private
boolean
selected
;
private
boolean
selected
;
private
final
String
text
;
private
final
MenuNavigation
navigation
;
private
String
outcome
;
public
JsfMenuitem
(
Menuitem
item
,
String
text
)
{
public
JsfMenuitem
(
MenuNavigation
navi
)
{
this
.
item
=
item
;
this
.
navigation
=
navi
;
this
.
text
=
text
;
if
(
navi
.
getSitepage
()
==
null
)
{
setItem
(
navi
.
getItem
());
}
else
{
outcome
=
new
StringBuilder
(
"/page/?id="
).
append
(
navi
.
getSitepage
().
getId
()).
toString
();
}
}
public
JsfMenuitem
(
SitePage
sitepage
)
{
item
=
new
Menuitem
(
"/page/?id="
+
sitepage
.
getId
(),
null
,
null
);
text
=
sitepage
.
getName
();
}
}
public
MenuGroup
getGroup
()
{
// public JsfMenuitem(SitePage sitepage) {
return
item
.
getGroup
();
// item = new Menuitem("/page/?id=" + sitepage.getId(), null, null);
}
// text = sitepage.getName();
// }
public
void
setSelected
()
{
public
void
setSelected
()
{
selected
=
true
;
selected
=
true
;
...
@@ -31,15 +33,18 @@ public class JsfMenuitem {
...
@@ -31,15 +33,18 @@ public class JsfMenuitem {
}
}
public
String
getOutcome
()
{
public
String
getOutcome
()
{
return
item
.
getUrl
()
;
return
outcome
;
}
}
public
String
getLinktext
()
{
public
void
setItem
(
Menuitem
item
)
{
return
text
;
if
(
item
!=
null
)
{
this
.
outcome
=
item
.
getUrl
();
}
}
}
public
String
getHeader
()
{
public
MenuNavigation
getNavigation
()
{
return
item
.
getHeader
()
;
return
navigation
;
}
}
}
}
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/menu/MenuDataView.java
View file @
1cf9b5c
...
@@ -7,11 +7,7 @@ import java.util.List;
...
@@ -7,11 +7,7 @@ import java.util.List;
import
java.util.MissingResourceException
;
import
java.util.MissingResourceException
;
import
java.util.ResourceBundle
;
import
java.util.ResourceBundle
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.SessionScoped
;
import
javax.faces.context.FacesContext
;
import
javax.faces.context.FacesContext
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
fi.insomnia.bortal.beans.PermissionBeanLocal
;
import
fi.insomnia.bortal.beans.PermissionBeanLocal
;
import
fi.insomnia.bortal.beans.SitePageBeanLocal
;
import
fi.insomnia.bortal.beans.SitePageBeanLocal
;
...
@@ -19,10 +15,9 @@ import fi.insomnia.bortal.enums.apps.BillPermission;
...
@@ -19,10 +15,9 @@ import fi.insomnia.bortal.enums.apps.BillPermission;
import
fi.insomnia.bortal.enums.apps.MapPermission
;
import
fi.insomnia.bortal.enums.apps.MapPermission
;
import
fi.insomnia.bortal.enums.apps.PollPermission
;
import
fi.insomnia.bortal.enums.apps.PollPermission
;
import
fi.insomnia.bortal.enums.apps.UserPermission
;
import
fi.insomnia.bortal.enums.apps.UserPermission
;
import
fi.insomnia.bortal.model.SitePage
;
@SessionScoped
//
@SessionScoped
@Named
//
@Named
public
class
MenuDataView
{
public
class
MenuDataView
{
private
ArrayList
<
JsfMenuitem
>
topmenu
;
private
ArrayList
<
JsfMenuitem
>
topmenu
;
...
@@ -31,11 +26,11 @@ public class MenuDataView {
...
@@ -31,11 +26,11 @@ public class MenuDataView {
private
Integer
pagegroupId
;
private
Integer
pagegroupId
;
private
PageGroup
currentPagegroup
;
private
PageGroup
currentPagegroup
;
@Inject
//
@Inject
private
FacesContext
context
;
private
FacesContext
context
;
@EJB
//
@EJB
private
PermissionBeanLocal
permbean
;
private
PermissionBeanLocal
permbean
;
@EJB
//
@EJB
private
SitePageBeanLocal
sitePageBean
;
private
SitePageBeanLocal
sitePageBean
;
private
ResourceBundle
rb
;
private
ResourceBundle
rb
;
...
@@ -123,38 +118,39 @@ public class MenuDataView {
...
@@ -123,38 +118,39 @@ public class MenuDataView {
return
context
;
return
context
;
}
}
public
List
<
JsfMenuitem
>
getTopmenu
()
{
// public List<JsfMenuitem> getTopmenu() {
//
if
(
topmenu
==
null
)
{
// if (topmenu == null) {
topmenu
=
new
ArrayList
<
JsfMenuitem
>();
// topmenu = new ArrayList<JsfMenuitem>();
//
Menuitem
currentPage
=
PAGEGROUPS
.
get
(
getPagename
());
// Menuitem currentPage = PAGEGROUPS.get(getPagename());
MenuGroup
currentGroup
=
null
;
// MenuGroup currentGroup = null;
if
(
currentPage
!=
null
)
{
// if (currentPage != null) {
currentGroup
=
currentPage
.
getGroup
();
// currentGroup = currentPage.getGroup();
}
// }
//
for
(
MenuGroup
m
:
PAGEGROUPS
)
{
// for (MenuGroup m : PAGEGROUPS) {
for
(
Menuitem
item
:
m
.
getItems
())
{
// for (Menuitem item : m.getItems()) {
if
(
permbean
.
hasPermission
(
item
.
getPermission
()))
{
// if (permbean.hasPermission(item.getPermission())) {
JsfMenuitem
thisitem
=
new
JsfMenuitem
(
item
,
this
.
localize
(
item
,
"menu"
));
// JsfMenuitem thisitem = new JsfMenuitem(item, this.localize(item,
topmenu
.
add
(
thisitem
);
// "menu"));
if
(
m
.
equals
(
currentGroup
))
{
// topmenu.add(thisitem);
thisitem
.
setSelected
();
// if (m.equals(currentGroup)) {
}
// thisitem.setSelected();
break
;
// }
}
// break;
}
// }
}
// }
// }
for
(
SitePage
sitepage
:
sitePageBean
.
getPagerootsForUser
())
//
{
// for (SitePage sitepage : sitePageBean.getPagerootsForUser())
topmenu
.
add
(
new
JsfMenuitem
(
sitepage
));
// {
}
// topmenu.add(new JsfMenuitem(sitepage));
}
// }
// }
return
topmenu
;
//
}
// return topmenu;
// }
private
String
localize
(
Menuitem
item
,
String
prefix
)
{
private
String
localize
(
Menuitem
item
,
String
prefix
)
{
StringBuilder
sb
=
new
StringBuilder
(
prefix
);
StringBuilder
sb
=
new
StringBuilder
(
prefix
);
...
@@ -170,25 +166,25 @@ public class MenuDataView {
...
@@ -170,25 +166,25 @@ public class MenuDataView {
this
.
submenu
=
submenu
;
this
.
submenu
=
submenu
;
}
}
public
ArrayList
<
JsfMenuitem
>
getSubmenu
()
{
//
public ArrayList<JsfMenuitem> getSubmenu() {
if
(
submenu
==
null
)
{
//
if (submenu == null) {
Menuitem
currentPage
=
PAGEGROUPS
.
get
(
getPagename
());
//
Menuitem currentPage = PAGEGROUPS.get(getPagename());
if
(
currentPage
!=
null
)
{
//
if (currentPage != null) {
MenuGroup
currentGroup
=
currentPage
.
getGroup
();
//
MenuGroup currentGroup = currentPage.getGroup();
//
submenu
=
new
ArrayList
<
JsfMenuitem
>();
//
submenu = new ArrayList<JsfMenuitem>();
for
(
Menuitem
item
:
currentGroup
.
getItems
())
{
//
for (Menuitem item : currentGroup.getItems()) {
if
(
permbean
.
hasPermission
(
item
.
getPermission
()))
{
//
if (permbean.hasPermission(item.getPermission())) {
JsfMenuitem
thisitem
=
new
JsfMenuitem
(
item
,
localize
(
item
,
"submenu"
));
//
JsfMenuitem thisitem = new JsfMenuitem(item, localize(item, "submenu"));
submenu
.
add
(
thisitem
);
//
submenu.add(thisitem);
if
(
currentPage
.
equals
(
item
))
{
//
if (currentPage.equals(item)) {
thisitem
.
setSelected
();
//
thisitem.setSelected();
}
//
}
}
//
}
}
//
}
//
}
//
}
}
//
}
return
submenu
;
//
return submenu;
}
//
}
}
}
\ No newline at end of file
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/menu/MenuRequestView.java
deleted
100644 → 0
View file @
d84249a
package
fi
.
insomnia
.
bortal
.
web
.
cdiview
.
menu
;
import
javax.enterprise.context.RequestScoped
;
import
javax.faces.context.FacesContext
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
javax.servlet.http.HttpServletRequest
;
@Named
@RequestScoped
public
class
MenuRequestView
{
private
String
pagename
;
@Inject
private
FacesContext
context
;
public
String
getPagename
()
{
if
(
pagename
==
null
)
{
HttpServletRequest
req
=
(
HttpServletRequest
)
getContext
().
getExternalContext
().
getRequest
();
String
[]
splitted
=
req
.
getServletPath
().
split
(
"\\."
);
if
(
splitted
.
length
>
0
)
{
pagename
=
splitted
[
0
];
}
}
return
pagename
;
}
public
FacesContext
getContext
()
{
return
context
;
}
public
void
setContext
(
FacesContext
context
)
{
this
.
context
=
context
;
}
}
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/menu/MenuView.java
0 → 100644
View file @
1cf9b5c
package
fi
.
insomnia
.
bortal
.
web
.
cdiview
.
menu
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.RequestScoped
;
import
javax.faces.context.FacesContext
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
javax.servlet.http.HttpServletRequest
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.insomnia.bortal.beans.MenubeanLocal
;
import
fi.insomnia.bortal.beans.PermissionBeanLocal
;
import
fi.insomnia.bortal.beans.SitePageBeanLocal
;
import
fi.insomnia.bortal.model.MenuNavigation
;
@Named
@RequestScoped
public
class
MenuView
{
private
String
pagename
;
private
List
<
JsfMenuitem
>
submenu
;
private
List
<
JsfMenuitem
>
topmenu
;
private
MenuNavigation
currentPage
;
@Inject
private
FacesContext
context
;
@EJB
private
MenubeanLocal
menubean
;
@EJB
private
PermissionBeanLocal
permbean
;
@EJB
private
SitePageBeanLocal
sitepagebean
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
MenuView
.
class
);
public
String
getPagename
()
{
if
(
pagename
==
null
)
{
HttpServletRequest
req
=
(
HttpServletRequest
)
getContext
().
getExternalContext
().
getRequest
();
String
[]
splitted
=
req
.
getServletPath
().
split
(
"\\."
);
if
(
splitted
.
length
>
0
)
{
pagename
=
splitted
[
0
];
}
}
return
pagename
;
}
public
List
<
JsfMenuitem
>
getSubmenu
()
{
if
(
submenu
==
null
)
{
submenu
=
new
ArrayList
<
JsfMenuitem
>();
for
(
MenuNavigation
item
:
menubean
.
getMenuNavigation
(
getPagename
()).
getChildren
())
{
if
(
permbean
.
hasPermission
(
item
.
getPermission
()))
{
JsfMenuitem
thisitem
=
new
JsfMenuitem
(
item
);
submenu
.
add
(
thisitem
);
if
(
currentPage
.
equals
(
item
))
{
thisitem
.
setSelected
();
}
}
}
}
return
submenu
;
}
public
List
<
JsfMenuitem
>
getTopmenu
()
{
if
(
topmenu
==
null
)
{
topmenu
=
new
ArrayList
<
JsfMenuitem
>();
// this function will also initialize empty menu hierarchy, but only
// if there are no results!
List
<
MenuNavigation
>
menuitems
=
menubean
.
getTopnavigations
();
currentPage
=
menubean
.
getMenuNavigation
(
getPagename
());
MenuNavigation
topPage
=
currentPage
;
while
(
topPage
.
getParent
()
!=
null
)
{
topPage
=
topPage
.
getParent
();
}
for
(
MenuNavigation
m
:
menuitems
)
{
JsfMenuitem
thisitem
=
new
JsfMenuitem
(
m
);
if
(
m
.
getItem
()
==
null
&&
m
.
getSitepage
()
==
null
)
{
for
(
MenuNavigation
child
:
m
.
getChildren
())
{
if
(
permbean
.
hasPermission
(
child
.
getPermission
()))
{
thisitem
.
setItem
(
child
.
getItem
());
break
;
}
}
}
logger
.
info
(
"Trying to add topmenu {}"
,
m
.
getKey
());
if
(
thisitem
.
getOutcome
()
!=
null
)
{
topmenu
.
add
(
thisitem
);
if
(
m
.
equals
(
topPage
))
{
thisitem
.
setSelected
();
}
}
}
}
return
topmenu
;
}
public
FacesContext
getContext
()
{
return
context
;
}
public
void
setContext
(
FacesContext
context
)
{
this
.
context
=
context
;
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment