Web-Client mit MyFaces 2.0 gestartet

This commit is contained in:
Peter Hormanns 2010-09-21 18:14:58 +00:00
parent e316834a3e
commit 64cb9b0a2a
25 changed files with 376 additions and 0 deletions

29
hsarweb/build.xml Normal file
View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="hsarweb" default="war">
<path id="cp">
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="war" depends="compile">
<war destfile="build/hsarweb.war" basedir="webapp">
<lib dir="lib">
<include name="**/*.jar"/>
</lib>
<classes dir="build/cls" />
<classes dir="src">
<include name="**/*.properties"/>
</classes>
</war>
</target>
<target name="compile">
<mkdir dir="build/cls"/>
<javac srcdir="src" destdir="build/cls"
classpathref="cp" debug="on"
/>
</target>
</project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,23 @@
package de.hsadmin.web;
import java.text.DateFormat;
import java.util.Date;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean
@SessionScoped
public class Bean {
public final static DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
public String getMessage() {
return "Hallo Welt";
}
public String getTime() {
return df.format(new Date());
}
}

View File

@ -0,0 +1,26 @@
package de.hsadmin.web;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import org.jasig.cas.client.authentication.AttributePrincipal;
import org.jasig.cas.client.util.AbstractCasFilter;
import org.jasig.cas.client.validation.Assertion;
@ManagedBean
@SessionScoped
public class Context {
private ExternalContext getContext() {
return FacesContext.getCurrentInstance().getExternalContext();
}
public String getUser() {
Assertion assertion = (Assertion) getContext().getSessionMap().get(AbstractCasFilter.CONST_CAS_ASSERTION);
AttributePrincipal principal = assertion.getPrincipal();
return principal.getName();
}
}

View File

@ -0,0 +1,22 @@
package de.hsadmin.web;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
@ManagedBean
@ApplicationScoped
public class Modules {
public String[] pageNames = new String[] { "hello" };
public List<String> getPageNames() {
ArrayList<String> names = new ArrayList<String>();
for (String name : pageNames) {
names.add(name);
}
return names;
}
}

View File

@ -0,0 +1 @@
hello=Hallo

View File

@ -0,0 +1 @@
hello=Hello

View File

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<application>
<locale-config>
<default-locale>de</default-locale>
<supported-locale>en</supported-locale>
</locale-config>
<message-bundle>texts.messages</message-bundle>
<resource-bundle>
<base-name>texts.messages</base-name>
<var>msgs</var>
</resource-bundle>
</application>
</faces-config>

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<filter>
<filter-name>CAS Authentication Filter</filter-name>
<filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class>
<init-param>
<param-name>casServerLoginUrl</param-name>
<param-value>http://agnes.ostwall195.de:8080/cas/login</param-value>
</init-param>
<init-param>
<param-name>serverName</param-name>
<param-value>http://agnes.ostwall195.de:8080</param-value>
</init-param>
<init-param>
<param-name>service</param-name>
<param-value>http://agnes.ostwall195.de:8080/hsarweb</param-value>
</init-param>
</filter>
<filter>
<filter-name>CAS Validation Filter</filter-name>
<filter-class>org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter</filter-class>
<init-param>
<param-name>casServerUrlPrefix</param-name>
<param-value>http://agnes.ostwall195.de:8080/cas</param-value>
</init-param>
<init-param>
<param-name>serverName</param-name>
<param-value>http://agnes.ostwall195.de:8080</param-value>
</init-param>
<init-param>
<param-name>proxyReceptorUrl</param-name>
<param-value>/proxyReceptor</param-value>
</init-param>
<init-param>
<param-name>service</param-name>
<param-value>http://agnes.ostwall195.de:8080/hsarweb</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CAS Authentication Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>CAS Validation Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

View File

@ -0,0 +1,21 @@
<?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"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
<title>Hello World</title>
</head>
<body>
<ui:composition template="/templates/menu-template.xhtml">
<ui:param name="title" value="Hallo schöne Welt"/>
<ui:define name="content">
<f:view>
Hallo&#160; <h:outputText value="#{context.user}"/>, es ist jetzt&#160; <h:outputText value="#{bean.time}"/> Uhr.
</f:view>
</ui:define>
</ui:composition>
</body>
</html>

12
hsarweb/webapp/index.jsp Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Hello World</title>
</head>
<body>
<jsp:forward page="hello/index.html" />
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@ -0,0 +1,93 @@
body {
font-family:Arial,Helvetica,SansSerif;
font-style:normal;
font-variant:normal;
font-size:12pt;
font-weight:normal;
margin:0px;
padding:0px;
min-height:1600px;
color:#707172;
background-color:#f0f0f0;
}
.page {
width:944px;
margin-left:auto;
margin-top:2px;
margin-right:auto;
padding-top:0px;
padding-left:0px;
padding-right:0px;
color:#707172;
background-color:#ffffff;
}
.header {
height:68px;
width:944px;
margin:0px;
padding:0px;
background-color:#005094;
background-image:url(../resources/images/logo.png);
background-repeat:no-repeat;
border-style: none solid;
border-width: 1px;
border-color: #005094;
}
.main {
width:936px;
margin:0px;
padding-top:10px;
padding-left:4px;
padding-right:4px;
padding-bottom:0px;
border-style: none solid;
border-width: 1px;
border-color: #dd4901;
}
.menu {
float:left;
width:300px;
margin-left:0px;
margin-top:0px;
margin-right:0px;
padding-top:0px;
padding-left:0px;
padding-right:0px;
}
.content {
width:606px;
margin-left:304px;
margin-top:0px;
margin-right:auto;
margin-bottom:0px;
padding-top:0px;
padding-left:10px;
padding-right:10px;
}
.footer {
width:944px;
clear:left;
font-family:Arial,Helvetica,SansSerif;
font-style:normal;
font-variant:normal;
font-size:10pt;
font-weight:normal;
text-decoration:none;
text-align:center;
padding-top:4px;
padding-bottom:4px;
padding-left:0px;
padding-right:0px;
border-top-color:#ede9e8;
border-top-width:2pt;
border-top-style:solid;
border-left-style: solid;
border-left-width: 1px;
border-left-color: #dd4901;
border-right-style: solid;
border-right-width: 1px;
border-right-color: #dd4901;
border-bottom-style: solid;
border-bottom-width: 1px;
border-bottom-color: #dd4901;
}

View File

@ -0,0 +1,26 @@
<?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"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
<title>Hello World</title>
</head>
<body>
<ui:composition template="/templates/template.xhtml">
<ui:define name="menu">
<f:view>
<h:dataTable var="menuitem" value="#{modules.pageNames}">
<h:column>
<h:outputLink value="#{menuitem}/index.html">
<h:outputText value="#{msgs.hello}" />
</h:outputLink>
</h:column>
</h:dataTable>
</f:view>
</ui:define>
</ui:composition>
</body>
</html>

View File

@ -0,0 +1,33 @@
<?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"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:insert name="metadata"/>
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>#{title}</title>
</h:head>
<h:body>
<h:outputStylesheet library="styles" name="hsar.css"/>
<h:outputScript library="javax.faces" name="jsf.js" target="head"/>
<div class="page">
<div class="header">
<ui:insert name="header" />
</div>
<div class="main">
<div class="menu">
<ui:insert name="menu">Default Menu</ui:insert>
</div>
<div class="content">
<ui:insert name="content">Default Content</ui:insert>
</div>
</div>
<div class="footer">
<ui:insert name="footer">Default Footer</ui:insert>
</div>
</div>
</h:body>
</html>