org.apache.myfaces.custom.dialog
Class ModalDialogRenderer

java.lang.Object
  extended by javax.faces.render.Renderer
      extended by org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer
          extended by org.apache.myfaces.custom.dialog.ModalDialogRenderer

public class ModalDialogRenderer
extends org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer

Renderer for the s:modalDialog component.

This component works in one of two different ways:

It is the page author's responsibility to have some other HTML control on the page whose "onclick" attribute contains javascript to invoke the "show" method of the modal dialog. Component property "dialogVar" specifies the name of a global javascript variable to be created, and its "show" method can be invoked to display the popup.

The Dojo library uses css tricks to make the DIV component act like a modal window.


Field Summary
static java.lang.String DIV_ID_PREFIX
           
static java.lang.String RENDERER_TYPE
           
 
Constructor Summary
ModalDialogRenderer()
           
 
Method Summary
 void encodeBegin(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Writes a DIV opening tag, plus javascript to make sure that the Dojo library is initialised.
 void encodeChildren(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent uiComponent)
          Override normal "encodeChildren" method to render the necessary dynamic parts of this component as well as the children.
 void encodeEnd(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Writes a DIV closing tag, plus javascript to declare the global "dialogVar" object that can be invoked to show the modal dialog.
 boolean getRendersChildren()
           
protected  boolean isRenderCloseButton(ModalDialog dlg)
           
 
Methods inherited from class org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer
getActionUrl, getChildCount, getChildren, getClientId, renderId, shouldRenderId, toUri
 
Methods inherited from class javax.faces.render.Renderer
convertClientId, decode, getConvertedValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RENDERER_TYPE

public static final java.lang.String RENDERER_TYPE
See Also:
Constant Field Values

DIV_ID_PREFIX

public static final java.lang.String DIV_ID_PREFIX
See Also:
Constant Field Values
Constructor Detail

ModalDialogRenderer

public ModalDialogRenderer()
Method Detail

encodeBegin

public void encodeBegin(javax.faces.context.FacesContext context,
                        javax.faces.component.UIComponent component)
                 throws java.io.IOException
Writes a DIV opening tag, plus javascript to make sure that the Dojo library is initialised.

Overrides:
encodeBegin in class javax.faces.render.Renderer
Throws:
java.io.IOException

encodeEnd

public void encodeEnd(javax.faces.context.FacesContext context,
                      javax.faces.component.UIComponent component)
               throws java.io.IOException
Writes a DIV closing tag, plus javascript to declare the global "dialogVar" object that can be invoked to show the modal dialog.

Overrides:
encodeEnd in class javax.faces.render.Renderer
Throws:
java.io.IOException

getRendersChildren

public boolean getRendersChildren()
Overrides:
getRendersChildren in class javax.faces.render.Renderer

encodeChildren

public void encodeChildren(javax.faces.context.FacesContext facesContext,
                           javax.faces.component.UIComponent uiComponent)
                    throws java.io.IOException
Override normal "encodeChildren" method to render the necessary dynamic parts of this component as well as the children.

If the user specified a titleBar facet, then that is rendered as the "window decoration" for the popup window. Otherwise if the user specified a dialogTitle, then a standard "window decoration" is rendered.

Then if the user did NOT specify a content page to be loaded into the popup, then the rest of the child components are rendered as normal.

But if the user DID specify a content page to be loaded, then an empty IFrame is rendered (javascript will be used to load it later), and the rendering of the child components is delayed until the encodeEnd method. TODO: why is child component rendering delayed?

Overrides:
encodeChildren in class javax.faces.render.Renderer
Throws:
java.io.IOException
See Also:
Renderer.encodeChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent)

isRenderCloseButton

protected boolean isRenderCloseButton(ModalDialog dlg)


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.