org.richfaces.renderkit.html.NotifyStackRenderer Maven / Gradle / Ivy
The newest version!
package org.richfaces.renderkit.html;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.richfaces.renderkit.RenderKitUtils;
import static org.richfaces.renderkit.RenderKitUtils.*;
import org.richfaces.renderkit.RenderKitUtils.Attributes;
import org.richfaces.renderkit.RenderKitUtils.ScriptHashVariableWrapper;
import org.richfaces.renderkit.html.NotifyStackRendererBase;
public class NotifyStackRenderer extends NotifyStackRendererBase {
private static final Attributes ATTRIBUTES_FOR_SCRIPT_HASH10 = attributes()
.generic("styleClass","styleClass")
.generic("position","position")
.generic("method","method")
.generic("direction","direction")
;
private static String convertToString(Object object)
{
return object != null ? object.toString() : "";
}
@Override
public void doEncodeEnd(ResponseWriter responseWriter, FacesContext facesContext, UIComponent component)
throws IOException
{
String clientId = component.getClientId(facesContext);
responseWriter.startElement("span", component);
responseWriter.writeAttribute("class","rf-ntf-stck",null);
{
String value = clientId;
if(null != value &&
value.length()>0
) {
responseWriter.writeAttribute("id",value,null);
}
}
responseWriter.startElement("script", component);
responseWriter.writeAttribute("type","text/javascript",null);
Map options = new LinkedHashMap();
addToScriptHash(options, facesContext, component, ATTRIBUTES_FOR_SCRIPT_HASH10, null);
{
Object text = "new RichFaces.ui.NotifyStack('" + convertToString(clientId) + "', " + convertToString(toScriptArgs(options)) + ");";
if (text != null) {
responseWriter.writeText(text, null);
}
}
responseWriter.endElement("script");
responseWriter.endElement("span");
}
}