1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.myfaces.custom.toggle;
20
21 import javax.faces.component.html.HtmlOutputLink;
22
23 /**
24 * Extends standard outputLink but links to a dynamically rendered resource (image, file, ...).
25 *
26 * Should be nested within an HtmlToggleGroup component. Controls nested within
27 * this component will be displayed in 'view' mode, controls outside this
28 * component (within the parent HtmlToggleGroup) will be displayed in 'edit'
29 * mode.
30 *
31 * @JSFComponent
32 * name = "t:toggleLink"
33 * class = "org.apache.myfaces.custom.toggle.ToggleLink"
34 * tagClass = "org.apache.myfaces.custom.toggle.ToggleLinkTag"
35 *
36 * @author Sharath Reddy
37 */
38 public abstract class AbstractToggleLink extends HtmlOutputLink
39 {
40 public static final String COMPONENT_TYPE = "org.apache.myfaces.ToggleLink";
41 public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.ToggleLink";
42 private static final boolean DEFAULT_DISABLED = false;
43
44 /**
45 * The class which implements
46 * org.apache.myfaces.custom.dynamicResources.ResourceRenderer.
47 * The resource renderer is responsible for resource the image.
48 * The class must have a default constructor.
49 * Any request scoped attribute or managed bean is not available when
50 * this resource renderer is instantiated and used.
51 * The resource renderer must render the binary data for the resource
52 * by using the parameters passed by nested f:param elements and/or
53 * using session or application scoped beans.
54 *
55 * @JSFProperty
56 * required="true"
57 * literalOnly = "true"
58 * @return
59 */
60 public abstract String getFor();
61
62 /**
63 * HTML: When true, this element cannot receive focus.
64 *
65 * @JSFProperty
66 * defaultValue = "false"
67 * @return
68 */
69 public abstract boolean isDisabled();
70
71 /**
72 * Id of the component that will be focused when toggleLink is clicked
73 *
74 * @JSFProperty
75 * literalOnly = "true"
76 * @return
77 */
78 public abstract String getOnClickFocusId();
79
80 public AbstractToggleLink()
81 {
82 super();
83 setRendererType(AbstractToggleLink.DEFAULT_RENDERER_TYPE);
84 setValue( "#" );
85 }
86
87 /**
88 * If true, this component will force the use of the specified id when rendering.
89 *
90 * @JSFProperty
91 * literalOnly = "true"
92 * defaultValue = "false"
93 *
94 * @return
95 */
96 public abstract Boolean getForceId();
97
98 public abstract void setForceId(Boolean forceId);
99
100 /**
101 * If false, this component will not append a '[n]' suffix
102 * (where 'n' is the row index) to components that are
103 * contained within a "list." This value will be true by
104 * default and the value will be ignored if the value of
105 * forceId is false (or not specified.)
106 *
107 * @JSFProperty
108 * literalOnly = "true"
109 * defaultValue = "true"
110 *
111 * @return
112 */
113 public abstract Boolean getForceIdIndex();
114
115 public abstract void setForceIdIndex(Boolean forceIdIndex);
116
117 /**
118 * If user is in given role, this component will be rendered
119 * normally. If not, no hyperlink is rendered but all nested
120 * tags (=body) are rendered.
121 *
122 * @JSFProperty
123 * @return
124 */
125 public abstract String getEnabledOnUserRole();
126
127 public abstract void setEnabledOnUserRole(String userRole);
128
129 /**
130 * If user is in given role, this component will be rendered
131 * normally. If not, nothing is rendered and the body of this
132 * tag will be skipped.
133 *
134 * @JSFProperty
135 * @return
136 */
137 public abstract String getVisibleOnUserRole();
138
139 public abstract void setVisibleOnUserRole(String userRole);
140
141
142 }