001/* 002 * (C) Copyright 2006-2007 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Jean-Marc Orliaguet, Chalmers 018 * 019 * $Id$ 020 */ 021 022package org.nuxeo.theme.jsf.component; 023 024import java.io.IOException; 025import java.util.HashMap; 026import java.util.Map; 027 028import javax.faces.component.UIOutput; 029import javax.faces.context.FacesContext; 030import javax.faces.context.ResponseWriter; 031 032import org.nuxeo.theme.html.ui.Button; 033 034public class UIButton extends UIOutput { 035 036 private String identifier; 037 038 private String controlledBy; 039 040 private String switchTo; 041 042 private String link; 043 044 private String menu; 045 046 private String label; 047 048 private String icon; 049 050 private String classNames; 051 052 @Override 053 public void encodeAll(final FacesContext context) throws IOException { 054 final ResponseWriter writer = context.getResponseWriter(); 055 Map<String, String> params = new HashMap<String, String>(); 056 Map<String, Object> attributes = getAttributes(); 057 params.put("identifier", (String) attributes.get("identifier")); 058 params.put("controlledBy", (String) attributes.get("controlledBy")); 059 params.put("switchTo", (String) attributes.get("switchTo")); 060 params.put("link", (String) attributes.get("link")); 061 params.put("label", (String) attributes.get("label")); 062 params.put("menu", (String) attributes.get("menu")); 063 params.put("classNames", (String) attributes.get("classNames")); 064 params.put("icon", (String) attributes.get("icon")); 065 writer.write(Button.render(params)); 066 } 067 068 public String getControlledBy() { 069 return controlledBy; 070 } 071 072 public void setControlledBy(final String controlledBy) { 073 this.controlledBy = controlledBy; 074 } 075 076 public String getIdentifier() { 077 return identifier; 078 } 079 080 public void setIdentifier(final String identifier) { 081 this.identifier = identifier; 082 } 083 084 public String getLabel() { 085 return label; 086 } 087 088 public void setLabel(final String label) { 089 this.label = label; 090 } 091 092 public String getLink() { 093 return link; 094 } 095 096 public void setLink(final String link) { 097 this.link = link; 098 } 099 100 public String getMenu() { 101 return menu; 102 } 103 104 public void setMenu(final String menu) { 105 this.menu = menu; 106 } 107 108 public String getSwitchTo() { 109 return switchTo; 110 } 111 112 public void setSwitchTo(final String switchTo) { 113 this.switchTo = switchTo; 114 } 115 116 public String getClassNames() { 117 return classNames; 118 } 119 120 public void setClassNames(final String classNames) { 121 this.classNames = classNames; 122 } 123 124 public String getIcon() { 125 return icon; 126 } 127 128 public void setIcon(String icon) { 129 this.icon = icon; 130 } 131}