KickJava   Java API By Example, From Geeks To Geeks.

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


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.JahiaContainerList;
7 import org.jahia.deprecated.taglibs.container.ContainerListTag;
8 import org.jahia.exceptions.JahiaException;
9 import org.jahia.services.usermanager.JahiaUser;
10
11
12 /**
13  * Class AddContainerButtonTag : returns the full link ("<a href...>...</a>") allowing to
14  * open the add container popup window if the user is authorized
15  *
16  * @author Jerome Tamiotti
17  */

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