-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
241 changed files
with
4,283 additions
and
11,312 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
bennu-portal/src/main/java/org/fenixedu/bennu/portal/servlet/PortalBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.fenixedu.bennu.portal.servlet; | ||
|
||
import javax.servlet.ServletContext; | ||
|
||
import org.fenixedu.bennu.core.json.adapters.AuthenticatedUserViewer; | ||
import org.fenixedu.bennu.core.rest.BennuRestResource; | ||
|
||
/** | ||
* The goal of this bean is to allow easy injection of Bennu Portal variables in JSP pages. | ||
* | ||
* Refer to each individual method for its documentation. | ||
* | ||
* @author João Carvalho ([email protected]) | ||
* | ||
*/ | ||
public class PortalBean { | ||
|
||
private final String ctxPath; | ||
|
||
public PortalBean(ServletContext servletContext) { | ||
this.ctxPath = servletContext.getContextPath(); | ||
} | ||
|
||
/** | ||
* Injects a Javascript context with contains the {@code BennuPortal} variable, which is a subset | ||
* of the Bennu Portal Data REST API, containing information about the configured locales, the current | ||
* locale, as well as some information regarding the currently logged user. | ||
* | ||
* If also sets up the {@code contextPath} variable, which contains the configured context path of the | ||
* application. | ||
* | ||
* @return | ||
* A {@code <script>} tag containing the {@code BennuPortal} and {@code contextPath} variables. | ||
*/ | ||
public String bennuPortal() { | ||
StringBuilder builder = new StringBuilder(); | ||
builder.append("<script>"); | ||
{ | ||
builder.append("window.BennuPortal = "); | ||
builder.append(BennuRestResource.getBuilder().view(null, Void.class, AuthenticatedUserViewer.class)).append(";"); | ||
} | ||
{ | ||
builder.append("window.contextPath = '").append(ctxPath).append("';"); | ||
} | ||
builder.append("</script>"); | ||
return builder.toString(); | ||
} | ||
} |
Oops, something went wrong.