[jboss-jira] [JBoss JIRA] Reopened: (JBPORTAL-1316) PortletTagHandler : bug and patch / portlet in layout page

Antoine Herzog (JIRA) jira-events at lists.jboss.org
Sun Mar 18 14:32:40 EDT 2007


     [ http://jira.jboss.com/jira/browse/JBPORTAL-1316?page=all ]

Antoine Herzog reopened JBPORTAL-1316:
--------------------------------------

             
After use of the TagHandler, I notice a problem : when the window is not declared in the page (not found in the list of windows), then, the last one in the list shows instead. (a very dirty page show up... )

here under the same patch of code, with the check "wIdFound".
nd better logs if not found.

if you want to apply it before general release....

to replace from "String windowID = null;" to the end of method :

		String windowID = null;
		boolean wIdFound = false;
		// we have the windowName (which is the window name), but we need the
		// window id
		Map portletContexts = page.getWindowContextMap();
		for (Iterator i = portletContexts.keySet().iterator(); i.hasNext();) {
			windowID = (String) i.next();
			WindowContext portletContext = (WindowContext) portletContexts
					.get(windowID);
			if (windowName.equals(portletContext.getWindowName())) {
				wIdFound = true;
				if (log.isDebugEnabled()) {
					log.debug("found the portlet to render: " + windowName);
				}
				break;
			}
		}

		if (!wIdFound) {
			log
					.warn("can't find the window id of the window name on this page. Page=["
							+ page.getPageName()
							+ "] and Window=["
							+ windowName
							+ "]. This window won't be shown in page.");
			return;
		}
		if (page.getWindowContext(windowID) == null) {
			log.warn("no such window on this page. Page [" + page.getPageName()
					+ "] Window name [" + windowName + "]" + "] Window Id ["
					+ windowID + "]");
			return;
		}

		WindowContext windowContext = page.getWindowContext(windowID);
		RenderContext renderContext = (RenderContext) request
				.getAttribute(LayoutConstants.ATTR_RENDERCONTEXT);

		renderContext = renderContext.getContext(windowContext);

		try {
			renderContext.render();
			out.write(renderContext.getMarkupFragment().toString());
			out.flush();
		} catch (RenderException e) {
			throw new JspException(e);
		}
	}


> PortletTagHandler : bug and patch / portlet in layout page
> ----------------------------------------------------------
>
>                 Key: JBPORTAL-1316
>                 URL: http://jira.jboss.com/jira/browse/JBPORTAL-1316
>             Project: JBoss Portal
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: Portal Theme
>    Affects Versions: 2.6.CR1, 2.4.2 Final
>         Environment: JBPortal 2.4.1
>            Reporter: Antoine Herzog
>         Assigned To: Thomas Heute
>            Priority: Minor
>             Fix For: 2.6.CR1
>
>   Original Estimate: 1 hour
>  Remaining Estimate: 1 hour
>
> The PortletTagHandler do nothing.
> Can't show a window with this tag in the layout jsp file.
> (the "region" tag works, but this special "portlet" tag to show only one window, without the region relation, does not work).
> the bug : the page.getWindowContext(windowID) needs the window id.
> in the code, it is used with the window Name : page.getWindowContext(windowName)
> todo : rewrite the code so it uses the window ID. 
> The patch : replace the code with the one here under.
> In the doTag() method, from :
>       if (page.getWindowContext(windowName) == null)
>       {
>          log.debug("no such window on this page. Page [" + page.getPageName() + "] Window [" + windowName + "]");
>          return;
>       }
> .../...
> To : the end of the method.
> Working code :
> 		String windowID = null;
> 		// we have the windowName (which is the window name), but we need the
> 		// window id
> 		Map portletContexts = page.getWindowContextMap();
> 		for (Iterator i = portletContexts.keySet().iterator(); i.hasNext();) {
> 			windowID = (String) i.next();
> 			WindowContext portletContext = (WindowContext) portletContexts
> 					.get(windowID);
> 			if (windowName.equals(portletContext.getWindowName())) {
> 				if (log.isDebugEnabled()) {
> 					log.debug("found the portlet to render: " + windowName);
> 				}
> 				break;
> 			}
> 		}
> 		if (windowID == null) {
> 			log
> 					.warn("can't find the window id of the window name on this page. Page ["
> 							+ page.getPageName()
> 							+ "] Window ["
> 							+ windowName
> 							+ "]. This window won't be shown in page.");
> 			return;
> 		}
> 		if (page.getWindowContext(windowID) == null) {
> 			log.warn("no such window on this page. Page [" + page.getPageName()
> 					+ "] Window name [" + windowName + "]" + "] Window Id ["
> 					+ windowID + "]");
> 			return;
> 		}
> 		WindowContext windowContext = page.getWindowContext(windowID);
> 		RenderContext renderContext = (RenderContext) request
> 				.getAttribute(LayoutConstants.ATTR_RENDERCONTEXT);
> 		renderContext = renderContext.getContext(windowContext);
> 		try {
> 			renderContext.render();
> 			out.write(renderContext.getMarkupFragment().toString());
> 			out.flush();
> 		} catch (RenderException e) {
> 			throw new JspException(e);
> 		}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list