From 5c28eb509d5f7f3e6db9b9efd5cb6708a9a50d2f Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Mon, 27 Sep 2010 19:00:32 +0000 Subject: [PATCH] Domain Modul begonnen --- hsarweb/src/de/hsadmin/web/Bean.java | 1 + hsarweb/src/de/hsadmin/web/Domain.java | 106 +++++++++++++++++++ hsarweb/src/de/hsadmin/web/Modules.java | 38 ++++++- hsarweb/src/de/hsadmin/web/Texts.java | 17 +++ hsarweb/src/texts/messages_de.properties | 7 +- hsarweb/src/texts/messages_en.properties | 7 +- hsarweb/webapp/domain/index.xhtml | 46 ++++++++ hsarweb/webapp/templates/menu-template.xhtml | 4 +- 8 files changed, 218 insertions(+), 8 deletions(-) create mode 100644 hsarweb/src/de/hsadmin/web/Domain.java create mode 100644 hsarweb/src/de/hsadmin/web/Texts.java create mode 100644 hsarweb/webapp/domain/index.xhtml diff --git a/hsarweb/src/de/hsadmin/web/Bean.java b/hsarweb/src/de/hsadmin/web/Bean.java index 44da213..c58fc95 100644 --- a/hsarweb/src/de/hsadmin/web/Bean.java +++ b/hsarweb/src/de/hsadmin/web/Bean.java @@ -4,6 +4,7 @@ import java.text.DateFormat; import java.util.Date; import java.util.HashMap; import java.util.Map; +import java.util.ResourceBundle; import javax.faces.bean.ManagedBean; import javax.faces.bean.ManagedProperty; diff --git a/hsarweb/src/de/hsadmin/web/Domain.java b/hsarweb/src/de/hsadmin/web/Domain.java new file mode 100644 index 0000000..1afd769 --- /dev/null +++ b/hsarweb/src/de/hsadmin/web/Domain.java @@ -0,0 +1,106 @@ +package de.hsadmin.web; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.faces.bean.ManagedBean; +import javax.faces.bean.ManagedProperty; +import javax.faces.bean.SessionScoped; +import javax.faces.context.FacesContext; + +@ManagedBean(name="domain") +@SessionScoped +public class Domain { + + @ManagedProperty(value="#{context}") + private Context context; + + @ManagedProperty(value="#{remote}") + private Remote remote; + + @ManagedProperty(value="#{texts}") + private Texts texts; + + private List> list = null; + private String error = null; + public Map labels = null; + public Map urls = null; + + public String getError() { + return error; + } + + public void setContext(Context context) { + this.context = context; + } + + public void setRemote(Remote remote) { + this.remote = remote; + } + + public void setTexts(Texts texts) { + this.texts = texts; + } + + public List> getList() { + if (list == null) { + list = new ArrayList>(); + try { + Map whereParams = new HashMap(); + Object testList = remote.callSearch("domain", context.getUser(), whereParams); + if (testList != null && testList instanceof Object[]) { + Object[] lst = (Object[])testList; + for (int i = 0; i) { + Map row = (Map) testRow; + Map dom = new HashMap(); + for (String key : new String[] { "id", "name", "user", "hive", "pac", "since" }) { + dom.put(key, (String) row.get(key)); + } + list.add(dom); + } + } + } + } catch (HsarwebException e) { + error = e.getMessage(); + } + } + return list; + } + + public Map getLabels() { + if (labels == null) { + labels = new HashMap(); + for (String key : new String[]{ "name", "user" }) { + labels.put(key, texts.getLabel("domain." + key + ".label")); + } + + } + return labels; + } + + public Map getUrls() { + if (urls == null) { + String path = context.getContextPath() + "/"; + urls = new HashMap(); + for (String key : new String[]{ "edit", "delete" }) { + urls.put(key, path + "domain/" + key + ".html"); + } + + } + return urls; + } + + public String delete() { + System.out.println("domain.delete" + FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("dom_id")); + return null; + } + + public String edit() { + System.out.println("domain.edit" + FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("dom_id")); + return null; + } +} diff --git a/hsarweb/src/de/hsadmin/web/Modules.java b/hsarweb/src/de/hsadmin/web/Modules.java index f516e0a..87321c1 100644 --- a/hsarweb/src/de/hsadmin/web/Modules.java +++ b/hsarweb/src/de/hsadmin/web/Modules.java @@ -1,7 +1,9 @@ package de.hsadmin.web; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.faces.bean.ManagedBean; import javax.faces.bean.ManagedProperty; @@ -14,20 +16,48 @@ public class Modules { @ManagedProperty(value="#{context}") private Context context; - public String[] pageNames = new String[] { "hello" }; + @ManagedProperty(value="#{texts}") + private Texts texts; + + public String[] pageNames = new String[] { "hello", "domain" }; + public Map labels = null; + public Map urls = null; public List getPageNames() { ArrayList names = new ArrayList(); - String path = context.getContextPath() + "/"; - names.add(path + context.getUser()); for (String name : pageNames) { - names.add(path + name); + names.add(name); } return names; } + + public Map getLabels() { + if (labels == null) { + labels = new HashMap(); + for (String key : pageNames) { + labels.put(key, texts.getLabel(key + ".label")); + } + } + return labels; + } + + public Map getUrls() { + if (urls == null) { + String path = context.getContextPath() + "/"; + urls = new HashMap(); + for (String key : pageNames) { + urls.put(key, path + key + "/index.html"); + } + } + return urls; + } public void setContext(Context context) { this.context = context; } + public void setTexts(Texts texts) { + this.texts = texts; + } + } diff --git a/hsarweb/src/de/hsadmin/web/Texts.java b/hsarweb/src/de/hsadmin/web/Texts.java new file mode 100644 index 0000000..a5833ba --- /dev/null +++ b/hsarweb/src/de/hsadmin/web/Texts.java @@ -0,0 +1,17 @@ +package de.hsadmin.web; + +import java.util.ResourceBundle; + +import javax.faces.bean.ManagedBean; +import javax.faces.bean.SessionScoped; + +@ManagedBean(name="texts") +@SessionScoped +public class Texts { + + public String getLabel(String key) { + ResourceBundle resource = ResourceBundle.getBundle("texts.messages"); + return resource.getString(key); + } + +} diff --git a/hsarweb/src/texts/messages_de.properties b/hsarweb/src/texts/messages_de.properties index 936ac2e..33d5f7b 100644 --- a/hsarweb/src/texts/messages_de.properties +++ b/hsarweb/src/texts/messages_de.properties @@ -1 +1,6 @@ -hello=Hallo \ No newline at end of file +edit=bearbeiten +delete=loeschen +hello.label=Hallo +domain.label=Domains +domain.name.label=Domain +domain.user.label=Verwalter \ No newline at end of file diff --git a/hsarweb/src/texts/messages_en.properties b/hsarweb/src/texts/messages_en.properties index b400b0c..4ac1c97 100644 --- a/hsarweb/src/texts/messages_en.properties +++ b/hsarweb/src/texts/messages_en.properties @@ -1 +1,6 @@ -hello=Hello \ No newline at end of file +edit=edit +delete=delete +hello.label=Hello +domain.label=Domains +domain.name.label=Domain +domain.user.label=Owner \ No newline at end of file diff --git a/hsarweb/webapp/domain/index.xhtml b/hsarweb/webapp/domain/index.xhtml new file mode 100644 index 0000000..5a20127 --- /dev/null +++ b/hsarweb/webapp/domain/index.xhtml @@ -0,0 +1,46 @@ + + + + + Hello World + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/hsarweb/webapp/templates/menu-template.xhtml b/hsarweb/webapp/templates/menu-template.xhtml index 29d37e5..b3f6d08 100644 --- a/hsarweb/webapp/templates/menu-template.xhtml +++ b/hsarweb/webapp/templates/menu-template.xhtml @@ -14,8 +14,8 @@ - - + +