Source Code Cross Referenced for WikiViewerComponent.java in  » Project-Management » EmForce » ru » emdev » EmForge » wiki » web » component » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Project Management » EmForce » ru.emdev.EmForge.wiki.web.component 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package ru.emdev.EmForge.wiki.web.component;
002:
003:        import java.io.IOException;
004:
005:        import javax.faces.component.UIOutput;
006:        import javax.faces.context.FacesContext;
007:        import javax.faces.context.ResponseWriter;
008:        import javax.faces.el.ValueBinding;
009:
010:        import org.apache.commons.lang.StringUtils;
011:        import org.apache.commons.logging.Log;
012:        import org.apache.commons.logging.LogFactory;
013:
014:        import ru.emdev.EmForge.util.Helper;
015:        import ru.emdev.EmForge.wiki.WikiTextToXHTMLConverter;
016:
017:        import com.ecyrd.jspwiki.WikiEngine;
018:        import com.ecyrd.jspwiki.WikiPage;
019:
020:        public class WikiViewerComponent extends UIOutput {
021:            protected final Log logger = LogFactory.getLog(getClass());
022:            // private static final String FAMILY = "WIKIFAMILY";	
023:
024:            private static final String STYLE_CLASS = "wikibox";
025:
026:            private WikiTextToXHTMLConverter converter = new WikiTextToXHTMLConverter();
027:
028:            // FIXME: Create something like ProviderUtil for selecting Provider class	
029:            public WikiViewerComponent() {
030:                super ();
031:            }
032:
033:            private String m_pageName;
034:            private Integer m_version = -1;
035:            private Integer m_trimText = null;
036:
037:            public String getPageName() {
038:                if (m_pageName != null) {
039:                    return m_pageName;
040:                }
041:
042:                ValueBinding vb = getValueBinding("pageName");
043:                String v = vb != null ? (String) vb.getValue(getFacesContext())
044:                        : null;
045:                return v;
046:            }
047:
048:            public void setPageName(String i_pageName) {
049:                m_pageName = i_pageName;
050:            }
051:
052:            public Integer getVersion() {
053:                if (m_version != null) {
054:                    return m_version;
055:                }
056:
057:                ValueBinding vb = getValueBinding("version");
058:                Integer v = vb != null ? (Integer) vb
059:                        .getValue(getFacesContext()) : null;
060:                return v;
061:            }
062:
063:            public void setVersion(Integer i_version) {
064:                m_version = i_version;
065:            }
066:
067:            public void setTrimText(Integer i_trimText) {
068:                m_trimText = i_trimText;
069:            }
070:
071:            public Integer getTrimText() {
072:                if (m_trimText != null) {
073:                    return m_trimText;
074:                }
075:
076:                ValueBinding vb = getValueBinding("trimText");
077:                Integer v = vb != null ? (Integer) vb
078:                        .getValue(getFacesContext()) : null;
079:                return v;
080:            }
081:
082:            public void encodeEnd(FacesContext context) throws IOException {
083:                String pageName = getPageName();
084:                Integer version = getVersion();
085:
086:                if (getPageName() != null) {
087:                    ResponseWriter writer = context.getResponseWriter();
088:                    String pageTextOutput = null;
089:
090:                    try {
091:                        boolean pageExists = false;
092:                        WikiEngine engine = Helper.getWikiEngine(context);
093:
094:                        pageExists = engine.pageExists(pageName, m_version);
095:
096:                        if (pageExists) {
097:
098:                            // TODO: Change with versioning
099:                            // TODO: Also think about XHTMLRenderer in faces tag context
100:                            WikiPage pageInfo = engine.getPage(pageName,
101:                                    version);
102:                            pageTextOutput = converter.getAsString(context,
103:                                    null, pageInfo);
104:                            if (getTrimText() != null) {
105:                                if (pageTextOutput.length() > getTrimText()) {
106:                                    pageTextOutput = StringUtils.substring(
107:                                            pageTextOutput, 0, getTrimText())
108:                                            + "...";
109:                                }
110:                            }
111:                        } else {
112:                            pageTextOutput = "";
113:                        }
114:
115:                    } catch (Exception ex) {
116:                        throw new IOException(
117:                                "Provider exception while rendering WikiViewer: "
118:                                        + ex);
119:                    }
120:
121:                    writer.startElement("div", this );
122:                    // FIXME: Must not to be hardcoded
123:                    writer.writeAttribute("class", STYLE_CLASS, null);
124:                    writer.writeAttribute("id", getClientId(context), null);
125:                    writer.startElement("br", this );
126:                    writer.write(pageTextOutput);
127:                    writer.endElement("div");
128:                } else {
129:                    logger.error("Wiki Viewer tag got null pageName");
130:                }
131:            }
132:
133:            public Object saveState(FacesContext i_context) {
134:                Object values[] = new Object[4];
135:                values[0] = super .saveState(i_context);
136:                values[1] = m_pageName;
137:                values[2] = m_version;
138:                values[3] = m_trimText;
139:                return values;
140:            }
141:
142:            public void restoreState(FacesContext i_context, Object i_state) {
143:                Object values[] = (Object[]) i_state;
144:                super .restoreState(i_context, values[0]);
145:                m_pageName = (String) values[1];
146:                m_version = (Integer) values[2];
147:                m_trimText = (Integer) values[3];
148:            }
149:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.