Skip to content

Commit

Permalink
Add IceFaces support.
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjmerono committed Feb 13, 2017
1 parent 3d04b72 commit f92f523
Show file tree
Hide file tree
Showing 22 changed files with 627 additions and 27 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ This a sample tool with JSF 1.2 technology using RichFaces (3.3.3.Final) and Pri
![](https://raw.githubusercontent.com/juanjmerono/sakai-jsf2/master/images/classic-rich.jpg)
![](https://raw.githubusercontent.com/juanjmerono/sakai-jsf2/master/images/classic-prime.jpg)

For testing retrocompatibility.

KickRoster Ice
====================

This a sample tool with JSF 2.2 technology using IceFaces (4.1.1).

![](https://raw.githubusercontent.com/juanjmerono/sakai-jsf2/master/images/new-ice.jpg)

KickRoster Prime
====================

Expand All @@ -31,9 +40,10 @@ This a sample tool with JSF 2.1 technology using RichFaces (4.3.7.Final).

![](https://raw.githubusercontent.com/juanjmerono/sakai-jsf2/master/images/new-rich.jpg)

RichFaces EOL https://developer.jboss.org/wiki/RichFacesEnd-Of-LifeQuestionsAnswers

Future Work
==============

- Create a more ambitious application, using the most powerful features of latest versions of jsf.
- Add support for IceFaces and MyFaces.

2 changes: 1 addition & 1 deletion kickroster-classic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Sakai JSF1.2 TOOL</name>
<name>Sakai JSF1.2 TOOL RichFaces and PrimeFaces</name>
<groupId>org.sakaiproject.jsfext</groupId>
<artifactId>kickroster-classic</artifactId>
<version>1.0</version>
Expand Down
6 changes: 6 additions & 0 deletions kickroster-ice/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/target/
/.metadata/
/.settings/
/.classpath
/.project
/target/
135 changes: 135 additions & 0 deletions kickroster-ice/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Sakai JSF2.2 TOOL IceFaces</name>
<groupId>org.sakaiproject.jsfext</groupId>
<artifactId>kickroster-ice</artifactId>
<version>1.0</version>
<organization>
<name>Universidad de Murcia</name>
<url>http://www.um.es/</url>
</organization>
<inceptionYear>2010</inceptionYear>
<description>JSF2.2 Web Application</description>
<packaging>war</packaging>

<!-- the base is parent -->
<parent>
<groupId>org.sakaiproject</groupId>
<artifactId>master</artifactId>
<version>12-SNAPSHOT</version>
<relativePath>../master/pom.xml</relativePath>
</parent>

<properties>
<org.mojarra.version>2.2.14</org.mojarra.version>
<org.icefaces.version>4.1.1</org.icefaces.version>
</properties>

<dependencies>
<dependency>
<groupId>org.sakaiproject.kernel</groupId>
<artifactId>sakai-kernel-util</artifactId>
<exclusions>
<exclusion>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.sakaiproject.kernel</groupId>
<artifactId>sakai-kernel-api</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.kernel</groupId>
<artifactId>sakai-component-manager</artifactId>
</dependency>
<!-- Faces Implementation -->
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>${org.mojarra.version}</version>
</dependency>
<!-- Icefaces Version -->
<dependency>
<groupId>org.icefaces</groupId>
<artifactId>icefaces</artifactId>
<version>${org.icefaces.version}</version>
</dependency>
<dependency>
<groupId>org.icefaces</groupId>
<artifactId>icefaces-ace</artifactId>
<version>${org.icefaces.version}</version>
</dependency>
<!-- Sakai JSF -->
<dependency>
<groupId>org.sakaiproject.jsf</groupId>
<artifactId>jsf-app</artifactId>
<version>${sakai.version}</version>
<classifier>jsf2</classifier>
<exclusions>
<exclusion>
<groupId>javax.faces</groupId>
<artifactId>javax.faces-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.sakaiproject.jsf</groupId>
<artifactId>jsf-tool</artifactId>
<version>${sakai.version}</version>
<exclusions>
<exclusion>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.sakaiproject.jsf</groupId>
<artifactId>jsf-widgets-sun-depend</artifactId>
<version>${sakai.version}</version>
<type>pom</type>
<exclusions>
<exclusion>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
<finalName>kickroster-ice</finalName>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/bundle</directory>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
</build>

</project>
167 changes: 167 additions & 0 deletions kickroster-ice/src/main/java/demo/RosterBean.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
package demo;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.icefaces.ace.model.chart.SectorSeries;
import org.icefaces.ace.model.chart.SectorSeries.SectorType;
import org.sakaiproject.authz.api.Member;
import org.sakaiproject.exception.IdUnusedException;
import org.sakaiproject.site.api.Group;
import org.sakaiproject.site.api.Site;
import org.sakaiproject.site.api.SiteService;
import org.sakaiproject.tool.api.ToolManager;
import org.sakaiproject.user.api.User;
import org.sakaiproject.user.api.UserDirectoryService;

public class RosterBean {

private static Log log = LogFactory.getLog(RosterBean.class);

protected String group;
public String getGroup() { return group; }
public void setGroup(String group) { this.group = group; }

protected UserDirectoryService userDirectoryService;
public void setUserDirectoryService(UserDirectoryService userDirectoryService) { this.userDirectoryService = userDirectoryService; }

protected SiteService siteService;
public void setSiteService(SiteService siteService) { this.siteService = siteService; }

protected ToolManager toolManager;
public void setToolManager(ToolManager toolManager) { this.toolManager = toolManager; }

public String getVersion() {
return FacesContext.class.getPackage().getImplementationVersion() + " IceFaces: 4.1.1";
}

public List<SectorSeries> getPieData() {
List<SectorSeries> pieData = new ArrayList<SectorSeries>();
try {
Map<String,Integer> groups = new HashMap<String,Integer>();
Site currentSite = siteService.getSite(toolManager.getCurrentPlacement().getContext());
Collection<Member> currentMembers = currentSite.getMembers();
for (Member m:currentMembers) {
for (Group g:currentSite.getGroupsWithMember(m.getUserId())) {
Integer i = groups.get(g.getTitle());
if (i==null) i = 0;
groups.put(g.getTitle(), i++);
}
}
SectorSeries ss = new SectorSeries();
for (String key:groups.keySet()) {
ss.add(key,groups.get(key));
}
ss.setType(SectorType.PIE);
ss.setShowDataLabels(true);
ss.setSliceMargin(4);
pieData.add(ss);
} catch (Exception ex) {
log.error("Error getting members.",ex);
}
return pieData;
}

public List<Participant> getDataModel() {
List<Participant> users = new ArrayList<Participant>();
try {
Site currentSite = siteService.getSite(toolManager.getCurrentPlacement().getContext());
if (group==null||group.equals("-")) {
Collection<Member> currentMembers = currentSite.getMembers();
for (Member m:currentMembers) {
StringBuffer groups = new StringBuffer("");
for (Group g:currentSite.getGroupsWithMember(m.getUserId())) {
groups.append(g.getTitle() + " ");
}
users.add(new Participant(userDirectoryService.getUser(m.getUserId()),m.getRole().getId(),groups.toString()));
}
} else {
Set<String> groups = new HashSet<String>();
groups.add(group);
Group grp = currentSite.getGroup(group);
Collection<String> members = currentSite.getMembersInGroups(groups);
for (String m:members) {
Member member = currentSite.getMember(m);
users.add(new Participant(userDirectoryService.getUser(m),member.getRole().getId(),grp.getTitle()));
}
}
} catch (Exception ex) {
log.error("Error getting members.",ex);
}
return users;
}

public List<SelectItem> getGroupOptions() {
List<SelectItem> items = new ArrayList<SelectItem>();
items.add(new SelectItem("-","-- Group --"));
if (siteService!=null && toolManager!=null) {
try {
Collection<Group> groups = siteService.getSite(toolManager.getCurrentPlacement().getContext()).getGroups();
for (Group g:groups) {
items.add(new SelectItem(g.getId(),g.getTitle()));
}
} catch (IdUnusedException ex) {
log.error("Error getting groups.",ex);
}
}
return items;
}

public void save(ActionEvent actionEvent) {
FacesContext context = FacesContext.getCurrentInstance();

context.addMessage(null, new FacesMessage("Successful", "Hello " + group));
context.addMessage(null, new FacesMessage("Second Message", "Additional Info Here..."));
}

public class Participant {

public User user;
public String roleTitle;
public String groupsString;

public Participant(User user, String roleTitle, String groupsString) {
this.user = user;
this.roleTitle = roleTitle;
this.groupsString = groupsString;
}

public User getUser() {
return user;
}

public void setUser(User user) {
this.user = user;
}

public String getRoleTitle() {
return roleTitle;
}

public void setRoleTitle(String roleTitle) {
this.roleTitle = roleTitle;
}

public String getGroupsString() {
return groupsString;
}

public void setGroupsString(String groupsString) {
this.groupsString = groupsString;
}

}

}
8 changes: 8 additions & 0 deletions kickroster-ice/src/main/resources/demo/messages.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
title=JSF
mainTitle=Roster Application
showPrime=Show as graph
showRich=Show as table
firstname=First Name
lastname=Last Name
role=Role
group=Group
8 changes: 8 additions & 0 deletions kickroster-ice/src/main/resources/demo/messages_es.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
title=JSF
mainTitle=Aplicacion Orla
showPrime=Ver como grafico
showRich=Ver como tabla
firstname=Nombre
lastname=Apellidos
role=Rol
group=Grupo
Loading

0 comments on commit f92f523

Please sign in to comment.