KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > deprecated > taglibs > button > DeleteContainerButtonTag


1 package org.jahia.deprecated.taglibs.button;
2
3 import javax.servlet.jsp.JspException JavaDoc;
4
5 import org.jahia.data.JahiaData;
6 import org.jahia.data.containers.JahiaContainer;
7 import org.jahia.data.containers.JahiaContainerList;
8 import org.jahia.deprecated.taglibs.container.ContainerListTag;
9 import org.jahia.deprecated.taglibs.container.ContainerTag;
10 import org.jahia.exceptions.JahiaException;
11 import org.jahia.services.usermanager.JahiaUser;
12
13
14 /**
15  * Class DeleteContainerButtonTag : returns the full link ("<a href...>...</a>")
16  * allowing to open the delete container popup window
17  *
18  * @author Jerome Tamiotti
19  */

20 public class DeleteContainerButtonTag extends AbstractButtonTag {
21
22     private JahiaContainer container = null;
23     private JahiaContainerList containerList = null;
24
25     private String JavaDoc title = "Delete";
26     private String JavaDoc style = "";
27
28     public void setTitle(String JavaDoc title) {
29         this.title = title;
30     }
31
32     public void setStyle(String JavaDoc style) {
33         this.style = style;
34     }
35
36     public String JavaDoc getTitle() {
37         return this.title;
38     }
39
40     public String JavaDoc getStyle() {
41         return this.style;
42     }
43
44     public boolean testRights (JahiaData jData) {
45
46         ContainerTag parent = (ContainerTag) findAncestorWithClass(this,ContainerTag.class);
47         if (parent != null) {
48             this.container = parent.getContainer();
49             ContainerListTag listTag = (ContainerListTag) parent.getParent();
50             if (listTag != null) {
51                 if (listTag.isDeclarationPass()) {
52                     return false;
53                 }
54                this.containerList = listTag.getContainerList();
55             }
56         }
57         if ((this.container != null) && (this.containerList != null)) {
58             JahiaUser user = jData.params().getUser();
59             return ( this.container.checkWriteAccess(user)
60                      && jData.gui().isEditMode() );
61         }
62         return false;
63     }
64
65     public String JavaDoc getLauncher(JahiaData jData) throws JahiaException {
66         // returns the URL that launches the delete container popup window
67
return "javascript:" + jData.gui().html().drawDeleteContainerLauncher(this.container);
68     }
69
70     public int doEndTag() throws JspException JavaDoc {
71         // let's reinitialize the tag variables to allow tag object reuse in
72
// pooling.
73
container = null;
74         containerList = null;
75
76         title = "Delete";
77         style = "";
78         return EVAL_PAGE;
79     }
80
81
82 }
83
Popular Tags