KickJava   Java API By Example, From Geeks To Geeks.

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


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.exceptions.JahiaException;
7
8
9 /**
10  * Class LogButtonTag : return the full link ("<a href...>...</a>") allowing to
11  * login / logout
12  *
13  * @author Jerome Tamiotti
14  */

15 public class LogButtonTag extends AbstractButtonTag {
16
17     private String JavaDoc loginTitle = "Login";
18     private String JavaDoc logoutTitle = "Logout";
19     private String JavaDoc style = "";
20
21     private boolean isLogged = false;
22
23     public void setLoginTitle(String JavaDoc title) {
24         this.loginTitle = title;
25     }
26
27     public void setLogoutTitle(String JavaDoc title) {
28         this.logoutTitle = title;
29     }
30
31     public void setStyle(String JavaDoc style) {
32         this.style = style;
33     }
34
35     public String JavaDoc getTitle() {
36         return isLogged ? logoutTitle : loginTitle;
37     }
38
39     public String JavaDoc getStyle() {
40         return this.style;
41     }
42
43     public boolean testRights (JahiaData jData) {
44         // this button is always visible
45
return true;
46     }
47
48     public String JavaDoc getLauncher(JahiaData jData) throws JahiaException {
49         // returns the URL used to login / logout
50
if (jData.gui().isLogged()) {
51             this.isLogged = true;
52             return jData.gui().html().drawLogoutLauncher();
53         } else {
54             this.isLogged = false;
55             return "javascript:" + jData.gui().html().drawLoginLauncher() ;
56         }
57     }
58
59     public int doEndTag() throws JspException JavaDoc {
60         // let's reinitialize the tag variables to allow tag object reuse in
61
// pooling.
62
loginTitle = "Login";
63         logoutTitle = "Logout";
64         style = "";
65
66         isLogged = false;
67         return EVAL_PAGE;
68     }
69
70
71 }
72
Popular Tags