Author: sviluppatorefico
Date: 2009-07-22 19:04:01 -0400 (Wed, 22 Jul 2009)
New Revision: 13589
Modified:
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/theme/tag/RegionTagHandler.java
Log:
JBPORTAL-2430 it lets drag and drop and partial refresh in a region
Modified:
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/theme/tag/RegionTagHandler.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/theme/tag/RegionTagHandler.java 2009-07-22
23:03:30 UTC (rev 13588)
+++
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/theme/tag/RegionTagHandler.java 2009-07-22
23:04:01 UTC (rev 13589)
@@ -22,234 +22,254 @@
******************************************************************************/
package org.jboss.portal.theme.tag;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.PageContext;
+import javax.servlet.jsp.tagext.SimpleTagSupport;
+
import org.jboss.logging.Logger;
import org.jboss.portal.theme.LayoutConstants;
import org.jboss.portal.theme.Orientation;
import org.jboss.portal.theme.impl.JSPRendererContext;
+import org.jboss.portal.theme.impl.render.dynamic.DynaRenderOptions;
import org.jboss.portal.theme.render.RenderException;
import org.jboss.portal.theme.render.renderer.PageRendererContext;
import org.jboss.portal.theme.render.renderer.RegionRendererContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.JspWriter;
-import javax.servlet.jsp.PageContext;
-import javax.servlet.jsp.tagext.SimpleTagSupport;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-
/**
- * Tag handler for the region tag. <p>A region represents a subsection of a portal
page. A region can host several
- * portlets. The portlets can be arranged horizontally or vertically. The region tag
utilizes a render set to create the
- * markup around the individual portlets.</p>
- *
+ * Tag handler for the region tag.
+ * <p>
+ * A region represents a subsection of a portal page. A region can host several
+ * portlets. The portlets can be arranged horizontally or vertically. The region
+ * tag utilizes a render set to create the markup around the individual
+ * portlets.
+ * </p>
+ *
* @author <a href="mailto:mholzner@novell.com>Martin Holzner</a>
* @author <a href="mailto:roy@jboss.org>Roy Russo</a>
- * @version $LastChangedRevision$, $LastChangedDate$
+ * @version $LastChangedRevision$, $LastChangedDate: 2007-10-28 01:01:46
+ * +0200 (dom, 28 ott 2007) $
* @see org.jboss.portal.theme.PortalRenderSet
*/
-public class RegionTagHandler
- extends SimpleTagSupport
-{
- private static Logger log = Logger.getLogger(RegionTagHandler.class);
- //default to vertical
+public class RegionTagHandler extends SimpleTagSupport {
+ private static Logger log = Logger.getLogger(RegionTagHandler.class);
+ // default to vertical
- private Orientation regionOrientation;
- private String regionName = null;
- private String regionCssId = null;
+ private Orientation regionOrientation;
+ private String regionName = null;
+ private String regionCssId = null;
+ private String dndEnabled = null;
+ private String partialRefreshEnabled = null;
- /**
- * create the markup of this tag
- *
- * @throws JspException
- * @throws IOException
- */
- public void doTag() throws JspException, IOException
- {
- if (regionCssId == null)
- {
- regionCssId = regionName;
- }
- log.debug("rendering " + regionName + " [" + regionOrientation
+ "] cssId[" + regionCssId + "]");
+ /**
+ * create the markup of this tag
+ *
+ * @throws JspException
+ * @throws IOException
+ */
+ public void doTag() throws JspException, IOException {
+ if (regionCssId == null) {
+ regionCssId = regionName;
+ }
+ log.debug("rendering " + regionName + " [" + regionOrientation
+ + "] cssId[" + regionCssId + "]");
- // get page and region
- PageContext app = (PageContext)getJspContext();
- HttpServletRequest request = (HttpServletRequest)app.getRequest();
+ // get page and region
+ PageContext app = (PageContext) getJspContext();
+ HttpServletRequest request = (HttpServletRequest) app.getRequest();
- PageRendererContext page =
(PageRendererContext)request.getAttribute(LayoutConstants.ATTR_PAGE);
- JspWriter out = this.getJspContext().getOut();
- if (page == null)
- {
- out.write("<p bgcolor='red'>No page to
render!</p>");
- out.write("<p bgcolor='red'>The page to render (PageResult)
must be set in the request attribute '" +
- LayoutConstants.ATTR_PAGE + "'</p>");
- out.flush();
- return;
- }
+ PageRendererContext page = (PageRendererContext) request
+ .getAttribute(LayoutConstants.ATTR_PAGE);
+ JspWriter out = this.getJspContext().getOut();
+ if (page == null) {
+ out.write("<p bgcolor='red'>No page to render!</p>");
+ out
+ .write("<p bgcolor='red'>The page to render (PageResult) must be
set in the request attribute '"
+ + LayoutConstants.ATTR_PAGE + "'</p>");
+ out.flush();
+ return;
+ }
- final String cssId = regionCssId == null ? regionName : regionCssId;
- final Orientation orientation = this.regionOrientation == null ?
Orientation.DEFAULT : this.regionOrientation;
+ final String cssId = regionCssId == null ? regionName : regionCssId;
+ final Orientation orientation = this.regionOrientation == null ? Orientation.DEFAULT
+ : this.regionOrientation;
- if (page.getRegion(regionName) == null) // non-window display of content
- {
- // Create a dummy region obj, based on region name
- RegionRendererContext rrc = new RegionRendererContext()
- {
- public String getId()
- {
- return regionName;
- }
+ if (page.getRegion(regionName) == null) // non-window display of content
+ {
+ // Create a dummy region obj, based on region name
+ RegionRendererContext rrc = new RegionRendererContext() {
+ public String getId() {
+ return regionName;
+ }
- public Collection getWindows()
- {
- return Collections.EMPTY_LIST;
- }
+ public Collection getWindows() {
+ return Collections.EMPTY_LIST;
+ }
- public PageRendererContext getPage()
- {
- return null;
- }
+ public PageRendererContext getPage() {
+ return null;
+ }
- public Orientation getOrientation()
- {
- return orientation;
- }
+ public Orientation getOrientation() {
+ return orientation;
+ }
- public String getCSSId()
- {
- return cssId;
- }
+ public String getCSSId() {
+ return cssId;
+ }
- public String getProperty(String name)
- {
- return null;
- }
+ public String getProperty(String name) {
+ return null;
+ }
- public Map getProperties()
- {
- return Collections.EMPTY_MAP;
- }
- };
+ public Map getProperties() {
+ return Collections.EMPTY_MAP;
+ }
+ };
- JSPRendererContext renderContext =
(JSPRendererContext)request.getAttribute(LayoutConstants.ATTR_RENDERCONTEXT);
- try
- {
- PrintWriter pw = new PrintWriter(out);
- renderContext.setWriter(pw);
- renderContext.render(rrc);
- pw.flush();
- }
- catch (RenderException e)
- {
- throw new JspException(e);
- }
- }
- else
- {
- // window-centric display of content
- JSPRendererContext renderContext =
(JSPRendererContext)request.getAttribute(LayoutConstants.ATTR_RENDERCONTEXT);
- if (renderContext == null)
- {
- log.debug("no render context available in request");
- return;
- }
+ JSPRendererContext renderContext = (JSPRendererContext) request
+ .getAttribute(LayoutConstants.ATTR_RENDERCONTEXT);
+ try {
+ PrintWriter pw = new PrintWriter(out);
+ renderContext.setWriter(pw);
+ renderContext.render(rrc);
+ pw.flush();
+ } catch (RenderException e) {
+ throw new JspException(e);
+ }
+ } else {
+ // window-centric display of content
+ JSPRendererContext renderContext = (JSPRendererContext) request
+ .getAttribute(LayoutConstants.ATTR_RENDERCONTEXT);
+ if (renderContext == null) {
+ log.debug("no render context available in request");
+ return;
+ }
- final RegionRendererContext region = page.getRegion(regionName);
- RegionRendererContext rrc = new RegionRendererContext()
- {
- public String getId()
- {
- return region.getId();
- }
+ final RegionRendererContext region = page.getRegion(regionName);
+ RegionRendererContext rrc = new RegionRendererContext() {
+ public String getId() {
+ return region.getId();
+ }
- public Collection getWindows()
- {
- return region.getWindows();
- }
+ public Collection getWindows() {
+ return region.getWindows();
+ }
- public Orientation getOrientation()
- {
- return orientation;
- }
+ public Orientation getOrientation() {
+ return orientation;
+ }
- public String getCSSId()
- {
- return cssId;
- }
+ public String getCSSId() {
+ return cssId;
+ }
- public String getProperty(String name)
- {
- return region.getProperty(name);
- }
+ public String getProperty(String name) {
+ return region.getProperty(name);
+ }
- public Map getProperties()
- {
- return region.getProperties();
- }
- };
- try
- {
- PrintWriter pw = new PrintWriter(out);
- renderContext.setWriter(pw);
- renderContext.render(rrc);
- pw.flush();
- }
- catch (RenderException e)
- {
- throw new JspException(e);
- }
+ public Map getProperties() {
+ return region.getProperties();
+ }
+ };
+
+ if (dndEnabled != null)
+ rrc.getProperties().put(DynaRenderOptions.DND_ENABLED,
+ dndEnabled);
+
+ if (partialRefreshEnabled != null)
+ rrc.getProperties().put(DynaRenderOptions.PARTIAL_REFRESH_ENABLED,
+ partialRefreshEnabled);
+
+ try {
+ PrintWriter pw = new PrintWriter(out);
+ renderContext.setWriter(pw);
+ renderContext.render(rrc);
+ pw.flush();
+ } catch (RenderException e) {
+ throw new JspException(e);
+ }
- log.debug("done rendering page region [" + regionName +
"]");
- }
- }
+ log.debug("done rendering page region [" + regionName + "]");
+ }
+ }
- // ------ attribute handlers
+ // ------ attribute handlers
- /**
- * Attribute handler for the orientation attribute of this tag
- *
- * @param orientation the orientation attribute value set in the hosting jsp
- */
- public void setOrientation(String orientation)
- {
- if (orientation == null)
- {
- log.error("no null value allowed");
- }
+ /**
+ * Attribute handler for the orientation attribute of this tag
+ *
+ * @param orientation
+ * the orientation attribute value set in the hosting jsp
+ */
+ public void setOrientation(String orientation) {
+ if (orientation == null) {
+ log.error("no null value allowed");
+ }
- try
- {
- this.regionOrientation = Orientation.parse(orientation);
- }
- catch (IllegalArgumentException e)
- {
- log.error(e);
- this.regionOrientation = Orientation.DEFAULT;
- }
- }
+ try {
+ this.regionOrientation = Orientation.parse(orientation);
+ } catch (IllegalArgumentException e) {
+ log.error(e);
+ this.regionOrientation = Orientation.DEFAULT;
+ }
+ }
- /**
- * Attribute handler for the region name attribute of this tag
- *
- * @param regionName the name of the region this tag should render the markup for
- */
- public void setRegionName(String regionName)
- {
- this.regionName = regionName;
- }
+ /**
+ * Attribute handler for the region name attribute of this tag
+ *
+ * @param regionName
+ * the name of the region this tag should render the markup for
+ */
+ public void setRegionName(String regionName) {
+ this.regionName = regionName;
+ }
- /**
- * Attribute handler for the region id attribute of this tag <p>The region Id
can be used as the value of the id
- * attribute of the region container tag. In case of the DivRenderer render set, this
is the id attribute of the div
- * tag that represents this region on the page.</p>
- *
- * @param regionID the id attribute value to set for this tag
- */
- public void setRegionID(String regionID)
- {
- this.regionCssId = regionID;
- }
+ /**
+ * Attribute handler for the region id attribute of this tag
+ * <p>
+ * The region Id can be used as the value of the id attribute of the region
+ * container tag. In case of the DivRenderer render set, this is the id
+ * attribute of the div tag that represents this region on the page.
+ * </p>
+ *
+ * @param regionID
+ * the id attribute value to set for this tag
+ */
+ public void setRegionID(String regionID) {
+ this.regionCssId = regionID;
+ }
+
+ /**
+ * Attribute handler for the drag and drop of this tag
+ * <p>
+ * This field enables drag and drop on a chosen region
+ * </p>
+ *
+ * @param dndEnabled
+ * it can be true or false
+ */
+ public void setDndEnabled(String dndEnabled) {
+ this.dndEnabled = dndEnabled;
+ }
+
+ /**
+ * Attribute handler for the partial refresh of this tag
+ * <p>
+ * This field enables partial refresh on a chosen region
+ * </p>
+ *
+ * @param partialRefreshEnabled
+ * it can be true or false
+ */
+ public void setPartialRefreshEnabled(String partialRefreshEnabled) {
+ this.partialRefreshEnabled = partialRefreshEnabled;
+ }
}
Show replies by date