Source Code Cross Referenced for ActionTag.java in  » Portal » gridsphere » org » gridsphere » provider » portletui » tags » 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 » Portal » gridsphere » org.gridsphere.provider.portletui.tags 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * @author <a href="mailto:novotny@gridsphere.org">Jason Novotny</a>
003:         * @version $Id: ActionTag.java 6400 2007-12-06 14:41:00Z docentt $
004:         */package org.gridsphere.provider.portletui.tags;
005:
006:        import org.gridsphere.portlet.impl.PortletURLImpl;
007:        import org.gridsphere.portlet.impl.SportletProperties;
008:        import org.gridsphere.portletcontainer.DefaultPortletAction;
009:        import org.gridsphere.portletcontainer.DefaultPortletPhase;
010:        import org.gridsphere.portletcontainer.DefaultPortletRender;
011:        import org.gridsphere.provider.portletui.beans.ImageBean;
012:        import org.gridsphere.provider.portletui.beans.ParamBean;
013:
014:        import javax.portlet.*;
015:        import javax.servlet.jsp.JspException;
016:        import javax.servlet.jsp.PageContext;
017:        import javax.servlet.jsp.tagext.TagData;
018:        import javax.servlet.jsp.tagext.TagExtraInfo;
019:        import javax.servlet.jsp.tagext.VariableInfo;
020:        import java.util.ArrayList;
021:        import java.util.Iterator;
022:        import java.util.List;
023:
024:        /**
025:         * The abstract <code>ActionTag</code> is used by other Action tags to contain <code>DefaultPortletAction</code>s
026:         * and possibly <code>ActionParamTag</code>s
027:         */
028:        public abstract class ActionTag extends BaseComponentTag {
029:
030:            protected String action = null;
031:            protected String render = null;
032:            protected String anchor = null;
033:            protected String var = null;
034:            protected String onClick = null;
035:            protected String onSubmit = null;
036:            protected String onMouseOver = null;
037:            protected String onMouseOut = null;
038:            protected String onReset = null;
039:            protected boolean useAjax = false;
040:
041:            protected boolean isSecure = false;
042:
043:            protected String windowState = null;
044:            protected String portletMode = null;
045:
046:            protected DefaultPortletPhase portletPhase = null;
047:            protected List<ParamBean> paramBeans = new ArrayList<ParamBean>();
048:            protected String label = null;
049:            protected String layout = null;
050:            protected ImageBean imageBean = null;
051:            protected boolean paramPrefixing = true;
052:
053:            public static class TEI extends TagExtraInfo {
054:
055:                public VariableInfo[] getVariableInfo(TagData tagData) {
056:                    VariableInfo vi[] = null;
057:                    String var = tagData.getAttributeString("var");
058:                    if (var != null) {
059:                        vi = new VariableInfo[1];
060:                        vi[0] = new VariableInfo(var, "java.lang.String", true,
061:                                VariableInfo.AT_BEGIN);
062:                    }
063:                    return vi;
064:                }
065:            }
066:
067:            /**
068:             * Sets the name of the variable to export as a RenderURL object
069:             *
070:             * @param var the name of the variable to export as a RenderURL object
071:             */
072:            public void setVar(String var) {
073:                this .var = var;
074:            }
075:
076:            /**
077:             * Returns the name of the exported RenderURL object
078:             *
079:             * @return the exported variable
080:             */
081:            public String getVar() {
082:                return var;
083:            }
084:
085:            /**
086:             * Sets the text that should be added at the end of generated URL
087:             *
088:             * @param anchor the action link key
089:             */
090:            public void setAnchor(String anchor) {
091:                this .anchor = anchor;
092:            }
093:
094:            /**
095:             * Returns the anchor used to identify text that should be added at the end of generated URL
096:             *
097:             * @return the anchor
098:             */
099:            public String getAnchor() {
100:                return anchor;
101:            }
102:
103:            /**
104:             * Returns the action specified by the onClick attribute
105:             *
106:             * @return the action specified by the onClick attribute
107:             */
108:            public String getOnClick() {
109:                return onClick;
110:            }
111:
112:            /**
113:             * Sets the action specified by the onClick attribute
114:             *
115:             * @param onClick the javascript action to perform
116:             */
117:            public void setOnClick(String onClick) {
118:                this .onClick = onClick;
119:            }
120:
121:            /**
122:             * Returns the action specified by the onReset attribute
123:             *
124:             * @return the action specified by the onReset attribute
125:             */
126:            public String getOnReset() {
127:                return onReset;
128:            }
129:
130:            /**
131:             * Sets the action specified by the onReset attribute
132:             *
133:             * @param onReset the javascript action to perform
134:             */
135:            public void setOnReset(String onReset) {
136:                this .onReset = onReset;
137:            }
138:
139:            /**
140:             * Returns the action specified by the onMouseOver attribute
141:             *
142:             * @return onMouseOver the javascript onMouseOver event
143:             */
144:            public String getOnMouseOver() {
145:                return onMouseOver;
146:            }
147:
148:            /**
149:             * Sets the action specified by the onMouseOver event
150:             *
151:             * @param onMouseOver the javascript onMouseOver event
152:             */
153:            public void setOnMouseOver(String onMouseOver) {
154:                this .onMouseOver = onMouseOver;
155:            }
156:
157:            /**
158:             * Returns the action specified by the onMouseOut attribute
159:             *
160:             * @return onMouseOver the javascript onMouseOut event
161:             */
162:            public String getOnMouseOut() {
163:                return onMouseOut;
164:            }
165:
166:            /**
167:             * Sets the action specified by the onMouseOut event
168:             *
169:             * @param onMouseOut the javascript onMouseOut event
170:             */
171:            public void setOnMouseOut(String onMouseOut) {
172:                this .onMouseOut = onMouseOut;
173:            }
174:
175:            /**
176:             * Returns the action specified by the onSubmit attribute
177:             *
178:             * @return the action specified by the onSubmit attribute
179:             */
180:            public String getOnSubmit() {
181:                return onSubmit;
182:            }
183:
184:            /**
185:             * Sets the action specified by the onSubmit attribute
186:             *
187:             * @param onSubmit the javascript action to perform
188:             */
189:            public void setOnSubmit(String onSubmit) {
190:                this .onSubmit = onSubmit;
191:            }
192:
193:            /**
194:             * Sets the label identified with the portlet component to link to
195:             *
196:             * @param label the action link key
197:             */
198:            public void setLabel(String label) {
199:                this .label = label;
200:            }
201:
202:            /**
203:             * Returns the label identified with the portlet component to link to
204:             *
205:             * @return the label
206:             */
207:            public String getLabel() {
208:                return label;
209:            }
210:
211:            /**
212:             * Returns the layout id that identifies a layout descriptor to target
213:             *
214:             * @return the layout id that identifies a layout descriptor to target
215:             */
216:            public String getLayout() {
217:                return layout;
218:            }
219:
220:            /**
221:             * Sets the layout id that identifies a layout descriptor to target
222:             *
223:             * @param layout the layout id that identifies a layout descriptor to target
224:             */
225:            public void setLayout(String layout) {
226:                this .layout = layout;
227:            }
228:
229:            /**
230:             * If secure is true, then use https, otherwise use http
231:             *
232:             * @param isSecure true if this actiontag is secure e.g. https, false otherwise
233:             */
234:            public void setSecure(boolean isSecure) {
235:                this .isSecure = isSecure;
236:            }
237:
238:            /**
239:             * Returns true if this actiontag is secure e.g. https, false otherwise
240:             *
241:             * @return true if this actiontag is secure, false otherwise
242:             */
243:            public boolean getSecure() {
244:                return isSecure;
245:            }
246:
247:            public void setPortletMode(String portletMode) {
248:                this .portletMode = portletMode;
249:            }
250:
251:            public String getPortletMode() {
252:                return portletMode;
253:            }
254:
255:            public void setWindowState(String windowState) {
256:                this .windowState = windowState;
257:            }
258:
259:            public String getWindowState() {
260:                return windowState;
261:            }
262:
263:            public void setAction(String action) {
264:                this .action = action;
265:            }
266:
267:            public String getAction() {
268:                return action;
269:            }
270:
271:            public String getRender() {
272:                return render;
273:            }
274:
275:            public void setRender(String render) {
276:                this .render = render;
277:            }
278:
279:            public void addParamBean(ParamBean paramBean) {
280:                paramBeans.add(paramBean);
281:            }
282:
283:            public void removeParamBean(ParamBean paramBean) {
284:                paramBeans.remove(paramBean);
285:            }
286:
287:            public List getParamBeans() {
288:                return paramBeans;
289:            }
290:
291:            public boolean isUseAjax() {
292:                return useAjax;
293:            }
294:
295:            public void setUseAjax(boolean useAjax) {
296:                this .useAjax = useAjax;
297:            }
298:
299:            protected String createURI(PortletURL url, boolean isAction)
300:                    throws JspException {
301:                // Builds a URI containing the actin and associated params
302:                RenderResponse res = (RenderResponse) pageContext.getAttribute(
303:                        SportletProperties.RENDER_RESPONSE,
304:                        PageContext.REQUEST_SCOPE);
305:                //RenderRequest req = (RenderRequest) pageContext.getAttribute(SportletProperties.RENDER_REQUEST, PageContext.REQUEST_SCOPE);
306:                // action is a required attribute except for FormTag
307:                if (label != null) {
308:                    res.setProperty("label", label);
309:                    ((PortletURLImpl) url).setLabel(label);
310:                }
311:                if (layout != null) {
312:                    ((PortletURLImpl) url).setLayout(layout);
313:                }
314:
315:                if (windowState != null) {
316:                    WindowState state = new WindowState(windowState);
317:                    try {
318:                        //System.err.println("set state to:" + state);
319:                        url.setWindowState(state);
320:                    } catch (WindowStateException e) {
321:                        throw new JspException(
322:                                "Unknown window state in renderURL tag: "
323:                                        + windowState);
324:                    }
325:                }
326:                if (portletMode != null) {
327:                    PortletMode mode = new PortletMode(portletMode);
328:                    try {
329:                        url.setPortletMode(mode);
330:                        //System.err.println("set mode to:" + mode + " url=" + url);
331:                    } catch (PortletModeException e) {
332:                        throw new JspException(
333:                                "Unknown portlet mode in renderURL tag: "
334:                                        + portletMode);
335:                    }
336:                }
337:
338:                String compId = (String) pageContext
339:                        .findAttribute(SportletProperties.GP_COMPONENT_ID);
340:
341:                if (action != null) {
342:                    if (compId == null) {
343:                        ((PortletURLImpl) url).setAction(action);
344:                        portletPhase = new DefaultPortletAction(action);
345:                    } else {
346:                        ((PortletURLImpl) url).setAction(compId + "%" + action);
347:                        portletPhase = new DefaultPortletAction(compId + "%"
348:                                + action);
349:                    }
350:                } else {
351:                    if (!isAction && render == null)
352:                        render = "";
353:                    if (null != render) {
354:                        if (compId == null) {
355:                            ((PortletURLImpl) url).setRender(render);
356:                            portletPhase = new DefaultPortletRender(render);
357:                        } else {
358:                            ((PortletURLImpl) url).setRender(compId + "%"
359:                                    + render);
360:                            portletPhase = new DefaultPortletRender(compId
361:                                    + "%" + render);
362:                        }
363:                    }
364:                }
365:
366:                /*
367:                else {
368:                    if (compId == null) {
369:                        // since action is NULL at this point, make it an empty string
370:                        action = "";
371:                        portletAction = new DefaultPortletAction(action);
372:                    } else {
373:                        portletAction = new DefaultPortletAction(compId + "%" + action);
374:                    }
375:                }
376:                 */
377:
378:                if (!paramBeans.isEmpty()) {
379:                    String id = createUniquePrefix(2);
380:                    Iterator it = paramBeans.iterator();
381:                    if (paramPrefixing) {
382:                        url.setParameter(SportletProperties.PREFIX, id);
383:                        portletPhase
384:                                .addParameter(SportletProperties.PREFIX, id);
385:                    }
386:                    while (it.hasNext()) {
387:                        ParamBean pbean = (ParamBean) it.next();
388:                        //System.err.println("have param bean name= " + pbean.getName() + " value= " + pbean.getValue());
389:                        if (paramPrefixing) {
390:                            url.setParameter(id + "_" + pbean.getName(), pbean
391:                                    .getValue());
392:                            portletPhase.addParameter(id + "_"
393:                                    + pbean.getName(), pbean.getValue());
394:                        } else {
395:                            url.setParameter(pbean.getName(), pbean.getValue());
396:                            portletPhase.addParameter(pbean.getName(), pbean
397:                                    .getValue());
398:                        }
399:                    }
400:                }
401:                //System.err.println("printing action  URL = " + url.toString());
402:                return url.toString();
403:            }
404:
405:            public String createActionURI() throws JspException {
406:                RenderResponse res = (RenderResponse) pageContext.getAttribute(
407:                        SportletProperties.RENDER_RESPONSE,
408:                        PageContext.REQUEST_SCOPE);
409:                return createURI(res.createActionURL(), true);
410:            }
411:
412:            public String createRenderURI() throws JspException {
413:                RenderResponse res = (RenderResponse) pageContext.getAttribute(
414:                        SportletProperties.RENDER_RESPONSE,
415:                        PageContext.REQUEST_SCOPE);
416:                return createURI(res.createRenderURL(), false);
417:            }
418:
419:            public void release() {
420:                super .release();
421:                action = null;
422:                anchor = null;
423:                var = null;
424:                onClick = null;
425:                onSubmit = null;
426:                onMouseOut = null;
427:                onMouseOver = null;
428:                useAjax = false;
429:                isSecure = false;
430:                windowState = null;
431:                portletMode = null;
432:                portletPhase = null;
433:                paramBeans.clear();
434:                label = null;
435:                layout = null;
436:                imageBean = null;
437:                paramPrefixing = true;
438:            }
439:
440:            /**
441:             * A string utility that produces a string composed of
442:             * <code>numChars</code> number of characters
443:             *
444:             * @param numChars the number of characters in the resulting <code>String</code>
445:             * @return the <code>String</code>
446:             */
447:            protected String createUniquePrefix(int numChars) {
448:                StringBuffer s = new StringBuffer();
449:                for (int i = 0; i <= numChars; i++) {
450:                    int nextChar = (int) (Math.random() * 62);
451:                    if (nextChar < 10) //0-9
452:                        s.append(nextChar);
453:                    else if (nextChar < 36) //a-z
454:                        s.append((char) (nextChar - 10 + 'a'));
455:                    else
456:                        s.append((char) (nextChar - 36 + 'A'));
457:                }
458:                return s.toString();
459:            }
460:
461:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.