Skip to content

Commit

Permalink
SAK-45442 - jsf upgrade for postem (sakaiproject#9224)
Browse files Browse the repository at this point in the history
  • Loading branch information
maurercw authored Apr 30, 2021
1 parent 505ac48 commit f6a7555
Show file tree
Hide file tree
Showing 20 changed files with 99 additions and 148 deletions.
79 changes: 20 additions & 59 deletions postem/postem-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,67 +12,19 @@
<artifactId>sakai-postem-tool</artifactId>
<packaging>war</packaging>

<!-- profiles added for WAS support -->
<profiles>
<profile>
<id>full</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.sakaiproject.jsf</groupId>
<artifactId>myfaces-tool</artifactId>
<type>pom</type>
<exclusions>
<!-- exclude this to avoid the collision btw RI and tomahawk -->
<exclusion>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</profile>
<profile>
<!-- exclude xerces xml parser apis for WAS -->
<id>was</id>
<dependencies>
<dependency>
<groupId>org.sakaiproject.jsf</groupId>
<artifactId>myfaces-tool</artifactId>
<type>pom</type>
<exclusions>
<!-- exclude this to avoid the collision btw RI and tomahawk -->
<exclusion>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</profile>
</profiles>

<dependencies>
<!-- postem requires and older version of myfaces -->
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
<version>1.1.10</version>
</dependency>
<dependency>
<groupId>org.sakaiproject.jsf2</groupId>
<artifactId>jsf2-tool</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.jsf2</groupId>
<artifactId>jsf2-app</artifactId>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
<version>1.1.10</version>
<groupId>org.sakaiproject.jsf2</groupId>
<artifactId>jsf2-widgets-sun-depend</artifactId>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.sakaiproject.kernel</groupId>
Expand Down Expand Up @@ -110,6 +62,15 @@
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet-shaded</artifactId>
<version>${sakai.weld.shaded.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
</dependencies>
<build>
<resources>
Expand Down
13 changes: 7 additions & 6 deletions postem/postem-app/src/java/org/sakaiproject/tool/postem/CSV.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

import org.apache.myfaces.shared_impl.util.MessageUtils;
import org.sakaiproject.util.ResourceLoader;

public class CSV {

Expand All @@ -48,6 +48,9 @@ public class CSV {

public static final int MAX_COL_LENGTH = 2000;

public static final String messageBundle = "org.sakaiproject.tool.postem.bundle.Messages";
private static final ResourceLoader msgs = new ResourceLoader(messageBundle);

// private boolean withHeaders = true;

public CSV(String csv, boolean withHeader) throws DataFormatException {
Expand Down Expand Up @@ -277,11 +280,9 @@ private static StringBuilder truncateIt(StringBuilder buffer)

if (!truncatingWarningDisplayed) {
truncatingWarningDisplayed = true;
FacesContext.getCurrentInstance().addMessage(
null,
MessageUtils.getMessage(FacesMessage.SEVERITY_INFO,
"data_truncated_warning", (new Object[] { new Integer(MAX_COL_LENGTH) }), FacesContext
.getCurrentInstance()));

String message = msgs.getFormattedMessage("data_truncated_warning", MAX_COL_LENGTH);
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(message));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.sakaiproject.jsf.util.JsfTool;
import org.sakaiproject.jsf2.util.JsfTool;
import org.sakaiproject.tool.api.ActiveTool;
import org.sakaiproject.tool.api.Tool;
import org.sakaiproject.tool.api.ToolException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.myfaces.shared_impl.util.MessageUtils;

import org.sakaiproject.api.app.postem.data.Gradebook;
import org.sakaiproject.api.app.postem.data.GradebookManager;
Expand Down Expand Up @@ -403,11 +402,8 @@ public String processCreateNew() {

} catch (PermissionException e) {
// logger.info(this + ".getEntries() in PostemTool " + e);
FacesContext.getCurrentInstance().addMessage(
null,
MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,
"error_permission", (new Object[] { e.toString() }), FacesContext
.getCurrentInstance()));
String message = msgs.getFormattedMessage("error_permission", e.toString());
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, message, null));
return "permission_error";
}
this.userId = SessionManager.getCurrentSessionUserId();
Expand All @@ -432,11 +428,8 @@ public String processGradebookUpdate() {

} catch (PermissionException e) {
// logger.info(this + ".getEntries() in PostemTool " + e);
FacesContext.getCurrentInstance().addMessage(
null,
MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,
"error_permission", (new Object[] { e.toString() }), FacesContext
.getCurrentInstance()));
String message = msgs.getFormattedMessage("error_permission", e.toString());
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, message, null));
this.currentGradebook = null;
this.csv = null;
this.newTemplate = null;
Expand Down Expand Up @@ -496,11 +489,8 @@ public String processCreate() {

} catch (PermissionException e) {
// logger.info(this + ".getEntries() in PostemTool " + e);
FacesContext.getCurrentInstance().addMessage(
null,
MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,
"error_permission", (new Object[] { e.toString() }), FacesContext
.getCurrentInstance()));
String message = msgs.getFormattedMessage("error_permission", e.toString());
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, message, null));
this.currentGradebook = null;
this.csv = null;
this.newTemplate = null;
Expand Down Expand Up @@ -822,11 +812,8 @@ public String processInstructorView() {

} catch (PermissionException e) {
// logger.info(this + ".getEntries() in PostemTool " + e);
FacesContext.getCurrentInstance().addMessage(
null,
MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,
"error_permission", (new Object[] { e.toString() }), FacesContext
.getCurrentInstance()));
String message = msgs.getFormattedMessage("error_permission", e.toString());
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, message, null));
return "permission_error";
}
Long currentGbId = ((Gradebook) gradebookTable.getRowData()).getId();
Expand All @@ -846,11 +833,8 @@ public String processGradebookDelete() {

} catch (PermissionException e) {
// logger.info(this + ".getEntries() in PostemTool " + e);
FacesContext.getCurrentInstance().addMessage(
null,
MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,
"error_permission", (new Object[] { e.toString() }), FacesContext
.getCurrentInstance()));
String message = msgs.getFormattedMessage("error_permission", e.toString());
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, message, null));
return "permission_error";
}
Long currentGbId = ((Gradebook) gradebookTable.getRowData()).getId();
Expand All @@ -869,11 +853,8 @@ public String processDelete() {

} catch (PermissionException e) {
// logger.info(this + ".getEntries() in PostemTool " + e);
FacesContext.getCurrentInstance().addMessage(
null,
MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,
"error_permission", (new Object[] { e.toString() }), FacesContext
.getCurrentInstance()));
String message = msgs.getFormattedMessage("error_permission", e.toString());
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, message, null));
return "permission_error";
}
gradebookManager.deleteGradebook(currentGradebook);
Expand All @@ -894,11 +875,8 @@ public String processCsvDownload() {

} catch (PermissionException e) {
// logger.info(this + ".getEntries() in PostemTool " + e);
FacesContext.getCurrentInstance().addMessage(
null,
MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,
"error_permission", (new Object[] { e.toString() }), FacesContext
.getCurrentInstance()));
String message = msgs.getFormattedMessage("error_permission", e.toString());
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, message, null));
return "permission_error";
}
Long currentGbId = ((Gradebook) gradebookTable.getRowData()).getId();
Expand Down Expand Up @@ -932,11 +910,8 @@ public String processTemplateDownload() {

} catch (PermissionException e) {
// logger.info(this + ".getEntries() in PostemTool " + e);
FacesContext.getCurrentInstance().addMessage(
null,
MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,
"error_permission", (new Object[] { e.toString() }), FacesContext
.getCurrentInstance()));
String message = msgs.getFormattedMessage("error_permission", e.toString());
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, message, null));
return "permission_error";
}
currentGradebook = (Gradebook) gradebookTable.getRowData();
Expand Down
6 changes: 6 additions & 0 deletions postem/postem-app/src/webapp/META-INF/context.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Context>
<Resource name="BeanManager"
auth="Container"
type="javax.enterprise.inject.spi.BeanManager"
factory="org.jboss.weld.resources.ManagerObjectFactory" />
</Context>
6 changes: 6 additions & 0 deletions postem/postem-app/src/webapp/WEB-INF/beans.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
bean-discovery-mode="all" version="2.0">
</beans>
10 changes: 5 additions & 5 deletions postem/postem-app/src/webapp/WEB-INF/faces-config.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0"?>
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">

<faces-config>
<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd"
version="2.3">

<application>
<message-bundle>org.sakaiproject.tool.postem.bundle.Messages</message-bundle>
Expand Down
8 changes: 5 additions & 3 deletions postem/postem-app/src/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>sakai-postem</display-name>
<description>Sakai Postem Gradebook Tool</description>

Expand Down
2 changes: 1 addition & 1 deletion postem/postem-app/src/webapp/postem/Title.jsp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://sakaiproject.org/jsf/sakai" prefix="sakai" %>
<%@ taglib uri="http://sakaiproject.org/jsf2/sakai" prefix="sakai" %>

<%
response.setContentType("text/html; charset=UTF-8");
Expand Down
10 changes: 5 additions & 5 deletions postem/postem-app/src/webapp/postem/create_gradebook.jsp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://sakaiproject.org/jsf/sakai" prefix="sakai" %>
<%@ taglib uri="http://sakaiproject.org/jsf2/sakai" prefix="sakai" %>
<%@ taglib uri="http://java.sun.com/upload" prefix="corejsf" %>

<%
Expand Down Expand Up @@ -60,7 +60,7 @@
<div class="col-xs-4">
<sakai:button_bar>
<%-- (gsilver) cannot pass a needed title atribute to these next items --%>
<sakai:button_bar_item
<h:commandButton
id="choosefile"
action="#{PostemTool.processAddAttachRedirect}"
value="#{msgs.gradebook_choosefile}"/>
Expand All @@ -72,7 +72,7 @@
<div class="form-group row">
<h:outputLabel for="release" value="#{msgs.gradebook_feedbackavail}" styleClass="form-group-label col-xs-2" />
<div class="col-xs-4">
<h:selectBooleanCheckbox id="release" value="#{PostemTool.currentGradebook.release}" />
<h:selectBooleanCheckbox id="release" value="#{PostemTool.currentGradebook.release}" style="margin-right: 5px;" />
<h:outputLabel for="release" value="#{msgs.release}" />
</div>
</div>
Expand All @@ -81,13 +81,13 @@
<br />

<sakai:button_bar>
<sakai:button_bar_item
<h:commandButton
action="#{PostemTool.processCreate}"
value="#{msgs.bar_post}"
onclick="SPNR.disableControlsAndSpin(this, null);"
rendered="#{PostemTool.editable}"
styleClass="active" />
<sakai:button_bar_item
<h:commandButton
action="#{PostemTool.processCancelNew}"
value="#{msgs.cancel}"
onclick="SPNR.disableControlsAndSpin(this, null);"
Expand Down
6 changes: 3 additions & 3 deletions postem/postem-app/src/webapp/postem/delete_confirm.jsp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://sakaiproject.org/jsf/sakai" prefix="sakai" %>
<%@ taglib uri="http://sakaiproject.org/jsf2/sakai" prefix="sakai" %>

<%
response.setContentType("text/html; charset=UTF-8");
Expand Down Expand Up @@ -37,11 +37,11 @@
</table>

<sakai:button_bar>
<sakai:button_bar_item action="#{PostemTool.processDelete}"
<h:commandButton action="#{PostemTool.processDelete}"
onclick="SPNR.disableControlsAndSpin(this, null);"
value="#{msgs.bar_delete}"
styleClass="active" />
<sakai:button_bar_item action="#{PostemTool.processCancelView}"
<h:commandButton action="#{PostemTool.processCancelView}"
onclick="SPNR.disableControlsAndSpin(this, null);"
value="#{msgs.cancel}" />
</sakai:button_bar>
Expand Down
6 changes: 3 additions & 3 deletions postem/postem-app/src/webapp/postem/main.jsp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://sakaiproject.org/jsf/sakai" prefix="sakai" %>
<%@ taglib uri="http://sakaiproject.org/jsf2/sakai" prefix="sakai" %>

<%
response.setContentType("text/html; charset=UTF-8");
Expand Down Expand Up @@ -28,7 +28,7 @@
<%@ include file="/postem/postemMenu.jsp" %>
<sakai:view_content>
<h:outputText styleClass="sak-banner-info" value="#{msgs.no_gradebooks}" rendered="#{!PostemTool.gradebooksExist}" />
<sakai:flat_list rendered="#{PostemTool.gradebooksExist}" value="#{PostemTool.gradebooks}" var="gradebook" binding="#{PostemTool.gradebookTable}" styleClass="table table-bordered table-striped">
<h:dataTable rendered="#{PostemTool.gradebooksExist}" value="#{PostemTool.gradebooks}" var="gradebook" binding="#{PostemTool.gradebookTable}" styleClass="table table-bordered table-striped">
<h:column>
<f:facet name="header">
<h:commandLink action="#{PostemTool.toggleTitleSort}" title="#{msgs.sort_title}">
Expand Down Expand Up @@ -113,7 +113,7 @@
<h:outputText value="#{msgs.template}"/>
</h:commandLink>
</h:column>
</sakai:flat_list>
</h:dataTable>
</sakai:view_content>

</h:form>
Expand Down
Loading

0 comments on commit f6a7555

Please sign in to comment.