001/* 002 * (C) Copyright 2006-2007 Nuxeo SAS <http://nuxeo.com> and others 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * Jean-Marc Orliaguet, Chalmers 011 * 012 * $Id$ 013 */ 014 015package org.nuxeo.theme.jsf.component; 016 017import java.io.IOException; 018import java.util.HashMap; 019import java.util.Map; 020 021import javax.faces.component.UIOutput; 022import javax.faces.context.FacesContext; 023import javax.faces.context.ResponseWriter; 024 025import org.nuxeo.theme.html.ui.Button; 026 027public class UIButton extends UIOutput { 028 029 private String identifier; 030 031 private String controlledBy; 032 033 private String switchTo; 034 035 private String link; 036 037 private String menu; 038 039 private String label; 040 041 private String icon; 042 043 private String classNames; 044 045 @Override 046 public void encodeAll(final FacesContext context) throws IOException { 047 final ResponseWriter writer = context.getResponseWriter(); 048 Map<String, String> params = new HashMap<String, String>(); 049 Map<String, Object> attributes = getAttributes(); 050 params.put("identifier", (String) attributes.get("identifier")); 051 params.put("controlledBy", (String) attributes.get("controlledBy")); 052 params.put("switchTo", (String) attributes.get("switchTo")); 053 params.put("link", (String) attributes.get("link")); 054 params.put("label", (String) attributes.get("label")); 055 params.put("menu", (String) attributes.get("menu")); 056 params.put("classNames", (String) attributes.get("classNames")); 057 params.put("icon", (String) attributes.get("icon")); 058 writer.write(Button.render(params)); 059 } 060 061 public String getControlledBy() { 062 return controlledBy; 063 } 064 065 public void setControlledBy(final String controlledBy) { 066 this.controlledBy = controlledBy; 067 } 068 069 public String getIdentifier() { 070 return identifier; 071 } 072 073 public void setIdentifier(final String identifier) { 074 this.identifier = identifier; 075 } 076 077 public String getLabel() { 078 return label; 079 } 080 081 public void setLabel(final String label) { 082 this.label = label; 083 } 084 085 public String getLink() { 086 return link; 087 } 088 089 public void setLink(final String link) { 090 this.link = link; 091 } 092 093 public String getMenu() { 094 return menu; 095 } 096 097 public void setMenu(final String menu) { 098 this.menu = menu; 099 } 100 101 public String getSwitchTo() { 102 return switchTo; 103 } 104 105 public void setSwitchTo(final String switchTo) { 106 this.switchTo = switchTo; 107 } 108 109 public String getClassNames() { 110 return classNames; 111 } 112 113 public void setClassNames(final String classNames) { 114 this.classNames = classNames; 115 } 116 117 public String getIcon() { 118 return icon; 119 } 120 121 public void setIcon(String icon) { 122 this.icon = icon; 123 } 124}