1 /**
2 *
3 * Copyright 2003-2004 The Apache Software Foundation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.apache.geronimo.console.web.taglib;
19
20 import java.io.IOException;
21 import javax.management.MBeanServer;
22 import javax.servlet.jsp.JspWriter;
23
24 /**
25 * If the application detects that a filter other than "*:*" has been used in
26 * the console for limiting the components displayed, this button will appear,
27 * allowing the user to revert to the default filter. If the default filter is
28 * being used, no button shall appear.
29 */
30 public final class ClearFilterTag extends MBeanServerContextSupport {
31 private MBeanServerContextTag ctx;
32 private MBeanServer server;
33
34 public int doStartTag() {
35 ctx = getMBeanServerContext();
36 server = ctx.getMBeanServer();
37 JspWriter out = pageContext.getOut();
38
39 try {
40 if (server != null) {
41 if (filtered()) {
42 out.println("<input class=\"submit\" type=\"button\" " +
43 "tabindex=\"2\" value=\"Clear Filter\" " +
44 "onclick=\"window.location='index.jsp'\"/>");
45 }
46 }
47 } catch (IOException e) {
48 e.printStackTrace();
49 }
50 return EVAL_BODY_INCLUDE;
51 }
52
53 public int doEndTag() {
54 return EVAL_PAGE;
55 }
56
57 private boolean filtered() {
58 return (!ctx.getObjectNameFilter().equals("*:*"));
59 }
60 }