Implemented TreeView
This commit is contained in:
parent
ed01e2796c
commit
aac199f5ed
2 changed files with 27 additions and 3 deletions
|
@ -90,8 +90,20 @@ public class Model {
|
||||||
* oder null wenn es keines gibt.
|
* oder null wenn es keines gibt.
|
||||||
*/
|
*/
|
||||||
public DataObject get(String path) {
|
public DataObject get(String path) {
|
||||||
if ( !objs.containsKey(path) ) return null;
|
if ( !this.objs.containsKey(path) ) return null;
|
||||||
return objs.get(path);
|
return this.objs.get(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt ein Array aus allen vorhandenen UIDs zurück.
|
||||||
|
*
|
||||||
|
* Praktisch für Anzeige von Listen.
|
||||||
|
* TODO: Eventuell ersetzen durch Rückgabe DataObjects?
|
||||||
|
*/
|
||||||
|
public String[] getAllUids() {
|
||||||
|
// was zur hölle ist das denn?
|
||||||
|
// siehe https://docs.oracle.com/javase/8/docs/api/java/util/Set.html#toArray-T:A-
|
||||||
|
return this.objs.keySet().toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package hsmw.jotto5.beleg.views;
|
package hsmw.jotto5.beleg.views;
|
||||||
|
|
||||||
|
import hsmw.jotto5.beleg.data.Model;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import com.sun.net.httpserver.*;
|
import com.sun.net.httpserver.*;
|
||||||
|
@ -9,8 +11,18 @@ public class TreeView implements HttpHandler {
|
||||||
public void handle(HttpExchange t) throws IOException {
|
public void handle(HttpExchange t) throws IOException {
|
||||||
String response;
|
String response;
|
||||||
OutputStream os;
|
OutputStream os;
|
||||||
|
Model m;
|
||||||
|
|
||||||
|
m = Model.getModel();
|
||||||
|
|
||||||
|
response = Defaults.HTMLHEADER + "<h1>Beleg - Objektübersicht</h1><ul>";
|
||||||
|
|
||||||
|
for ( String s : m.getAllUids() ) {
|
||||||
|
response += "<li><a href=\"/object/" + s + "\">" + s + "</a></li>";
|
||||||
|
}
|
||||||
|
|
||||||
|
response += "</ul>" + Defaults.HTMLFOOTER;
|
||||||
|
|
||||||
response = Defaults.HTMLHEADER + "<h1>Beleg - Objektübersicht</h1>" + Defaults.HTMLFOOTER;
|
|
||||||
os = t.getResponseBody();
|
os = t.getResponseBody();
|
||||||
|
|
||||||
t.sendResponseHeaders(200, response.length());
|
t.sendResponseHeaders(200, response.length());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue