Rev 137 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
26 | soliveira | 1 | package org.kawai.tag; |
2 | |||
3 | import java.util.Locale; |
||
4 | |||
5 | import javax.servlet.jsp.JspException; |
||
6 | |||
7 | import org.kawai.model.Language; |
||
8 | import org.kawai.model.Page; |
||
9 | import org.kawai.model.User; |
||
10 | import org.mentawai.i18n.LocaleManager; |
||
11 | import org.mentawai.tag.util.PrintTag; |
||
12 | |||
194 | helio.frota | 13 | /** |
14 | * PrintTag class EditTooltip. |
||
15 | * |
||
16 | * @author Sergio Oliveira |
||
17 | * |
||
18 | */ |
||
26 | soliveira | 19 | public class EditTooltip extends PrintTag { |
194 | helio.frota | 20 | |
21 | /** Attribute name of EditTooltip. */ |
||
22 | private String name; |
||
23 | |||
24 | public void setName(String name) { |
||
25 | this.name = name; |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * {@inheritDoc}. |
||
30 | */ |
||
31 | @Override |
||
32 | public String getStringToPrint() throws JspException { |
||
33 | |||
34 | Locale loc = Language.getDefault().getLocale(); |
||
35 | |||
36 | Page page = (Page) pageContext.findAttribute(name); |
||
37 | if (page == null) { |
||
38 | throw new JspException("Cannot find page with name: " + name); |
||
39 | } |
||
40 | User modifier = page.getModifiedBy(); |
||
41 | if (modifier != null) { |
||
42 | return "Last modified by " + modifier.getUsername() + " on " + LocaleManager.formatDateTime(loc, page.getModifiedOn()); |
||
43 | } else { |
||
44 | User creator = page.getCreatedBy(); |
||
45 | if (creator == null) { |
||
46 | throw new IllegalStateException("Page without creator: " + page); |
||
47 | } else { |
||
48 | return "Created by " + creator.getUsername() + " on " + LocaleManager.formatDateTime(loc, page.getCreatedOn()); |
||
49 | } |
||
50 | } |
||
51 | } |
||
52 | } |