KickJava   Java API By Example, From Geeks To Geeks.

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


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

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