Author: amarkhel
Date: 2008-07-24 11:44:47 -0400 (Thu, 24 Jul 2008)
New Revision: 9770
Modified:
trunk/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererBase.java
Log:
Fix bug RF 3946 Add check if context menu have parent with id - otherwise throw exception
Modified:
trunk/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererBase.java
===================================================================
---
trunk/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererBase.java 2008-07-24
15:32:29 UTC (rev 9769)
+++
trunk/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererBase.java 2008-07-24
15:44:47 UTC (rev 9770)
@@ -42,6 +42,7 @@
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.resource.InternetResource;
import org.richfaces.component.UIContextMenu;
+import org.richfaces.component.util.HtmlUtil;
import org.richfaces.renderkit.TemplateEncoderRendererBase;
import org.xml.sax.ContentHandler;
@@ -105,15 +106,39 @@
protected void doEncodeBegin(ResponseWriter writer, FacesContext context,
UIComponent component) throws IOException {
+ ensureParentPresent(component);
writer.startElement(HTML.DIV_ELEM, component);
writer.writeAttribute(HTML.id_ATTRIBUTE, component.getClientId(context),
"id");
}
+
+ private void ensureParentPresent(UIComponent component) {
+ UIComponent parent = component.getParent();
+ if (parent != null) {
+ if (HtmlUtil.shouldWriteId(parent)) {
+ return;
+ } else {
+ throw new FacesException(
+ "Context menu cannot be attached to the component with id = "
+ + parent.getId()
+ + ", because a client identifier of the component won't be rendered onto
the page. Please, set the identifier.");
+ }
+ } else {
+ throw new FacesException(
+ "Parent component is null for ContextMenu "
+ + component.getId());
+ }
+ }
/**
- * Perform validation of the contextMenu configuration. Throws FacesException in case
validation fails.
- * @param clientId - id of the component
- * @param name - component name
- * @param attachTiming - timing options
+ * Perform validation of the contextMenu configuration. Throws
+ * FacesException in case validation fails.
+ *
+ * @param clientId -
+ * id of the component
+ * @param name -
+ * component name
+ * @param attachTiming -
+ * timing options
*/
protected void checkValidity(String clientId, String name, String attachTiming) {
if (!ON_LOAD.equals(attachTiming) && !IMMEDIATE.equals(attachTiming)
&& !ON_AVAILABLE.equals(attachTiming)) {
Show replies by date