Skip to content

Commit

Permalink
Support plain JSF pages in Admin Console
Browse files Browse the repository at this point in the history
URLs that start with /faces/* are handled by xhtml pages
(e.g. /faces/header.xhtml handled by header.xhtml (in the webapp root).
Can be injected to JSF templating pages via iframe. 
Example in upload.jsf (Application -> Deploy...)
Signed-off-by:Ondro Mihalyi <mihalyi@omnifish.ee>
  • Loading branch information
OndroMih committed Apr 6, 2024
1 parent ae30f35 commit d0937a3
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
<script type="text/javascript">
document.body.style.cursor = 'auto';
</script>
<iframe src="/faces/header.xhtml" style="overflow:auto; width:100%; height:100px; border:0px;">
</iframe>
<iframe src="/common/applications/uploadFrame.jsf" style="overflow:auto; width:100%; height:100%; border:0px;">
</iframe>
</f:verbatim>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
treeAdaptorClass="org.glassfish.admingui.common.tree.ListTreeAdaptor"
children="#{requestScope.children}"
text="$resource{i18n.tree.applications}"
url="/common/applications/applications.xhtml"
url="/common/applications/applications.jsf"
expanded="false"
childImageURL="/resource/images/webModule.gif"
imageURL="/resource/images/application.gif"
Expand Down
5 changes: 5 additions & 0 deletions appserver/admingui/war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@
<artifactId>jakarta.el-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void setViewHandler(ViewHandler handler) {
super.setViewHandler(handler);
}

public ViewHandler getDefaViewHandler() {
public ViewHandler getDefaultViewHandler() {
return defaultViewHandler;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,24 @@ public AdminGuiViewHandler(ViewHandler wrapped) {
super(wrapped);
Application app = FacesContext.getCurrentInstance().getApplication();
if (app instanceof AdminGuiApplication) {
defaultViewHandler = ((AdminGuiApplication) app).getDefaViewHandler();
defaultViewHandler = ((AdminGuiApplication) app).getDefaultViewHandler();
} else {
defaultViewHandler = wrapped;
}
}

@Override
public ViewHandler getWrapped() {
String requestServletPath = null;
if (FacesContext.getCurrentInstance() != null) {
requestServletPath = FacesContext.getCurrentInstance().getExternalContext().getRequestServletPath();
}
if (defaultViewHandler != null && requestServletPath != null && requestServletPath.startsWith("/faces")) {
return defaultViewHandler;
}
return super.getWrapped();
}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package org.glassfish.admingui.common.view;

import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Named;

/**
*
* @author Ondro Mihalyi
*/
@RequestScoped
@Named
public class HeaderView {

public String getTitle() {
return "This is a new header";
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!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">
<head>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="jakarta.faces.html">
<h:head>
<title>Facelet Title</title>
</head>
<body>
Hello from Facelets
</body>
</h:head>
<h:body>
#{headerView.title} (using standard Jakarta Faces)
</h:body>
</html>

0 comments on commit d0937a3

Please sign in to comment.