Java Code Examples for javax.faces.context.ResponseWriter

The following examples show how to use javax.faces.context.ResponseWriter. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
@Override
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
    if (!component.isRendered()) {
        return;
    }

    // Get the response renderer
    ResponseWriter writer = context.getResponseWriter();

    // Do not render if it is not needed
    if (AjaxUtil.isAjaxNullResponseWriter(writer)) {
        return;
    }

    // And write the value
    if (component instanceof UIDojoWidgetBase) {
        endTag(context, writer, (UIDojoWidgetBase) component);
    }
}
 
Example 2
@Override
protected void writeOneColumnRows(FacesContext context, ResponseWriter w, FormLayout c, UIComponent parent, ComputedFormData formData) throws IOException {
    List<UIComponent> children = TypedUtil.getChildren(parent);
    for(UIComponent child: children) {
        if(!child.isRendered()) {
            continue;
        }
        if(child instanceof UIFormLayoutRow) {
            newLine(w);
            writeFormRow(context, w, c, formData, (UIFormLayoutRow)child);
        } else {
            if( !(child instanceof FormLayout) ){
                writeChildRows(context, w, c, child, formData);
            }// do not recurse through FormLayout descendants
        }
    }
}
 
Example 3
Source Project: BootsFaces-OSP   Source File: OpenStreetMapRenderer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * This methods generates the HTML code of the current b:openStreetMap.
 * <code>encodeBegin</code> generates the start of the component. After the, the
 * JSF framework calls <code>encodeChildren()</code> to generate the HTML code
 * between the beginning and the end of the component. For instance, in the case
 * of a panel component the content of the panel is generated by
 * <code>encodeChildren()</code>. After that, <code>encodeEnd()</code> is called
 * to generate the rest of the HTML code.
 *
 * @param context   the FacesContext.
 * @param component the current b:openStreetMap.
 * @throws IOException thrown if something goes wrong when writing the HTML
 *                     code.
 */
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
	
	if (!component.isRendered()) {
		return;
	}
	OpenStreetMap openStreetMap = (OpenStreetMap) component;

	ResponseWriter rw = context.getResponseWriter();
	String clientId = openStreetMap.getClientId();

	rw.startElement("div", openStreetMap);
	rw.writeAttribute("id", clientId, "id");
	rw.writeAttribute("style", "width:" + openStreetMap.getWidth() + "; height:" + openStreetMap.getHeight(), null);

}
 
Example 4
private void encodeMonthRow(ResponseWriter writer, Calendar date, Locale locale) throws IOException {
    // writer.startElement("tr", this);
    // writer.startElement("td", this);
    writer.startElement("caption", this);
    writer.writeAttribute("style", "font-weight: 600; background: #bbb", null);
    writer.writeAttribute("class", "text-center", null);
    // writer.writeAttribute("colspan", 6, null);

    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm", locale);
    DateFormatSymbols dfs = sdf.getDateFormatSymbols();
    writer.write((dfs.getMonths())[date.get(Calendar.MONTH)]);

    writer.endElement("caption");
    // writer.endElement("td");
    // writer.endElement("tr");
}
 
Example 5
Source Project: XPagesExtensionLibrary   Source File: DojoGridRenderer.java    License: Apache License 2.0 6 votes vote down vote up
protected void emitColumn(FacesContext context, ResponseWriter writer, UIDojoDataGridColumn c) throws IOException {
    if(!c.isRendered()) {
        return;
    }
    JSUtil.writeln(writer);
    writer.startElement("th", c); // $NON-NLS-1$
    
    Map<String,String> attrs = DojoRendererUtil.createMap(context);
    DojoRendererUtil.addDojoHtmlAttributes(attrs,"field",c.getField()); // $NON-NLS-1$
    DojoRendererUtil.addDojoHtmlAttributes(attrs,"width",c.getWidth()); // $NON-NLS-1$
    DojoRendererUtil.addDojoHtmlAttributes(attrs,"cellType",c.getCellType()); // $NON-NLS-1$
    DojoRendererUtil.addDojoHtmlAttributes(attrs,"formatter",c.getFormatter()); // $NON-NLS-1$
    DojoRendererUtil.addDojoHtmlAttributes(attrs,"get",c.getGet()); // $NON-NLS-1$
    DojoRendererUtil.addDojoHtmlAttributes(attrs,"options",c.getOptions()); // $NON-NLS-1$
    DojoRendererUtil.addDojoHtmlAttributes(attrs,"editable",c.isEditable()); // $NON-NLS-1$
    DojoRendererUtil.addDojoHtmlAttributes(attrs,"hidden",c.isHidden()); // $NON-NLS-1$
    DojoRendererUtil.writeDojoHtmlAttributesMap(context,attrs);
    
    String title = c.getLabel();
    if(StringUtil.isNotEmpty(title)) {
        writer.writeText(title, "label"); // $NON-NLS-1$
    }

    writer.endElement("th"); // $NON-NLS-1$
}
 
Example 6
Source Project: sakai   Source File: RendererUtil.java    License: Educational Community License v2.0 6 votes vote down vote up
/**
 * Renders a script that includes an external JavaScript that gets added to
 * the document through a document.write() if a gatekeeper value is NOT set.
 * This effectively makes the script inclusion a per request JavaScript
 * singleton.
 * 
 * @param writer
 *            the ResponseWriter
 * @param gateKey
 *            for key value pair
 * @param gateValue
 *            value for key value pair for gatekeeper
 * @param contextBasePath
 *            the web app with the script
 * @param scriptPath
 *            the webapp-relative path
 * @throws IOException
 */
public static void writeSmartExternalScripts(ResponseWriter writer, String gateKey,
        String gateValue, String contextBasePath, String[] scriptPaths) throws IOException
{
    writer.write("<script>");
    writer.write("  if (typeof window['" + gateKey + "'] == '" + gateValue + "')");
    writer.write("  {");

    for (int i = 0; i < scriptPaths.length; i++)
    {
        writer.write("    document.write(");
        writer.write("   \"<\" + \"script src='/'\" + "
                + contextBasePath + " +");
        writer.write("   \"'" + scriptPaths[i] + "'><\" + \"/script>);");
    }

    writer.write("   var " + gateKey + " = '" + gateValue + "';");

    writer.write("  }");
    writer.write("</script>");
    writer.write("");
    writer.write("");
}
 
Example 7
Source Project: XPagesExtensionLibrary   Source File: PagerSizesRenderer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void writePagerContent(FacesContext context, ResponseWriter w, AbstractPager _pager, FacesDataIterator dataIterator) throws IOException {
    UIPagerSizes pager = (UIPagerSizes) _pager;
    w.startElement("div", null); // $NON-NLS-1$

    w.startElement("ul", null); // $NON-NLS-1$
    String styleClass = pager.getStyleClass();
    String pgClass = ExtLibUtil.concatStyleClasses("pagination", styleClass); // $NON-NLS-1$
    if (StringUtil.isNotEmpty(pgClass)) {
        w.writeAttribute("class", pgClass, null); // $NON-NLS-1$
    }

    String text = pager.getText();
    if (StringUtil.isEmpty(text)) {
        // "Show {0} items per page";
        text = com.ibm.xsp.extlib.controls.ResourceHandler.getString("PagerSizesRenderer.Show0itemsperpage"); //$NON-NLS-1$
    }
    int pos = text.indexOf("{0}"); //$NON-NLS-1$
    writerStartText(context, w, pager, dataIterator, text, pos);
    writerPages(context, w, pager, dataIterator, text, pos);
    writerEndText(context, w, pager, dataIterator, text, pos);
    w.endElement("ul"); // $NON-NLS-1$

    w.endElement("div"); // $NON-NLS-1$
}
 
Example 8
Source Project: XPagesExtensionLibrary   Source File: ForumPostRenderer.java    License: Apache License 2.0 6 votes vote down vote up
protected void writeAuthorName(FacesContext context, ResponseWriter w, UIForumPost c, UIComponent facet) throws IOException {
    if(facet==null) {
        return;
    }
    w.startElement("div", c); // $NON-NLS-1$
    String style = (String)getProperty(PROP_AUTHORNAMESTYLE);
    if(StringUtil.isNotEmpty(style)) {
        w.writeAttribute("style", style, null); // $NON-NLS-1$
    }
    String styleClass = (String)getProperty(PROP_AUTHORNAMECLASS);
    if(StringUtil.isNotEmpty(styleClass)) {
        w.writeAttribute("class", styleClass, null); // $NON-NLS-1$
    }
    FacesUtil.renderComponent(context, facet);
    w.endElement("div"); // $NON-NLS-1$
}
 
Example 9
Source Project: BootsFaces-OSP   Source File: SelectMultiMenuRenderer.java    License: Apache License 2.0 6 votes vote down vote up
/** Renders the select tag. */
protected void renderSelectTag(FacesContext context, ResponseWriter rw, String clientId, String name,
		SelectMultiMenu menu) throws IOException {
	renderSelectTag(rw, menu);
	renderSelectTagAttributes(rw, clientId, name, menu);
       AJAXRenderer.generateBootsFacesAJAXAndJavaScript(FacesContext.getCurrentInstance(), menu, rw, false);
	Object selectedOption = getValue2Render(context, menu);
	String[] optionList;
	if (selectedOption == null) {
		optionList = new String[0];
	} else if (!(selectedOption instanceof String)) {
		throw new FacesException("SelectMultiMenu only works with Strings!");
	} else {
		optionList = ((String) selectedOption).split(",");
	}
	renderOptions(context, rw, optionList, menu);

	renderInputTagEnd(rw);
}
 
Example 10
Source Project: BootsFaces-OSP   Source File: SwitchRenderer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * The b:switch and the b:selectBooleanCheckbox share most of their code.
 * This method allows to add extra attributes for the switch.
 * 
 * @param rw
 * @param selectBooleanCheckbox
 * @throws IOException
 */
protected void addAttributesForSwitch(ResponseWriter rw, SelectBooleanCheckbox selectBooleanCheckbox)
		throws IOException {
	Switch switchComponent = (Switch) selectBooleanCheckbox;
	writeAttribute(rw, "data-off-text", switchComponent.getOffText());
	writeAttribute(rw, "data-on-text", switchComponent.getOnText());
	writeAttribute(rw, "data-on-color", switchComponent.getOnColor());
	writeAttribute(rw, "data-off-color", switchComponent.getOffColor());
	if (switchComponent.isIndeterminate())
		writeAttribute(rw, "data-indeterminate", switchComponent.isIndeterminate());
	if (switchComponent.isInverse())
		writeAttribute(rw, "data-inverse", switchComponent.isInverse());
	writeAttribute(rw, "data-size", switchComponent.getSwitchsize());
	if (!switchComponent.isAnimate())
		writeAttribute(rw, "data-animate", switchComponent.isAnimate());
	if (switchComponent.isDisabled())
		writeAttribute(rw, "data-disabled", switchComponent.isDisabled());
	if (switchComponent.isReadonly())
		writeAttribute(rw, "data-readonly", switchComponent.isReadonly());
	writeAttribute(rw, "data-label-text", switchComponent.getLabelText());
	if (switchComponent.getHandleWidth() > 0)
		writeAttribute(rw, "data-handle-width", switchComponent.getHandleWidth());
	if (switchComponent.getLabelWidth() > 0)
		writeAttribute(rw, "data-label-width", switchComponent.getLabelWidth());
}
 
Example 11
Source Project: sakai   Source File: TocTreeRender.java    License: Educational Community License v2.0 6 votes vote down vote up
/** 
 * @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
 */
public void encodeBegin(FacesContext context, UIComponent component)
    throws IOException
{
  String jsLibraryUrl = "../js";
  ResponseWriter writer = context.getResponseWriter();
  writer.write("<script type=\"text/javascript\">var _editor_url = \""
      + jsLibraryUrl + "/\";</script>\n");
  writer.write("<script type=\"text/javascript\" src=\"" + jsLibraryUrl
      + "/divTree.js\"></script>\n");
  writer
      .write("<link href=\"../css/divTree.css\" type=\"text/css\" rel=\"stylesheet\">");

  UIData data = (UIData) component;
  Object value = data.getValue();
  Set categories = (Set) value;
  encodeRecursive(writer, categories);
}
 
Example 12
protected void writeSearchButton(FacesContext context, ResponseWriter w, UIApplicationLayout c, BasicApplicationConfigurationImpl configuration, SearchBar searchBar, ITree tree, boolean searchOptions) throws IOException {
     String submitSearch = "_xspAppSearchSubmit"; // $NON-NLS-1$
     
     w.startElement("div", c); // $NON-NLS-1$
     w.writeAttribute("class","input-group-btn",null); // $NON-NLS-1$ $NON-NLS-2$
     newLine(w);
     
     // Write the required script (done here because of Bootstrap 3 last-child selector on the input-group-btn)
     writeSearchScript(context, w, c, configuration, searchBar, tree, searchOptions);
     newLine(w);
    
     w.startElement("button",c); // $NON-NLS-1$
     w.writeAttribute("class","btn btn-default applayout-searchbtn",null); // $NON-NLS-1$ $NON-NLS-2$
     w.writeAttribute("onclick","javascript:"+submitSearch+"(); return false;",null); // $NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
     String searchLabel = com.ibm.xsp.extlib.controls.ResourceHandler.getString("AbstractApplicationLayoutRenderer.Search.1"); // $NON-NLS-1$
     w.writeAttribute("aria-label", searchLabel,null); // $NON-NLS-1$ 
     w.startElement("span",c); // $NON-NLS-1$
     w.writeAttribute("aria-hidden","true",null); // $NON-NLS-1$ $NON-NLS-2$
     w.writeAttribute("class", Resources.get().getIconClass("search"),null); // $NON-NLS-1$ $NON-NLS-2$
     w.endElement("span"); // $NON-NLS-1$
     w.endElement("button"); // $NON-NLS-1$
     
     w.endElement("div"); // $NON-NLS-1$
}
 
Example 13
Source Project: sakai   Source File: QuestionLinkRender.java    License: Educational Community License v2.0 6 votes vote down vote up
/** 
 * @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
 */
public void encodeBegin(FacesContext context, UIComponent component)
    throws IOException
{
  ResponseWriter writer = context.getResponseWriter();
  String showLink = (String) component.getAttributes().get("showLink");
  String URL = (String) component.getAttributes().get("URL");
  String message = (String) component.getAttributes().get("message");
  if ("true".equals(showLink))
  {
    writer.write("<a href=\"");
    writer.write(URL);
    writer.write("\" target=\"content\">");
    writer.write(message);
    writer.write("</a>");
  }
}
 
Example 14
@Override
   public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
       if (!component.isRendered()) {
           return;
       }

       // Get the response renderer
       ResponseWriter writer = context.getResponseWriter();

       // Do not render if it is not needed
       if (AjaxUtil.isAjaxNullResponseWriter(writer)) {
           return;
       }

       // And write the value
       if (component instanceof UIDojoWidgetBase) {
           writeTag(context, (UIDojoWidgetBase) component, writer);
       }
       
}
 
Example 15
Source Project: BootsFaces-OSP   Source File: BadgeRenderer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * This methods generates the HTML code of the current b:badge.
 *
 * @param context
 *            the FacesContext.
 * @param component
 *            the current b:badge.
 * @throws IOException
 *             thrown if something goes wrong when writing the HTML code.
 */
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
	if (!component.isRendered()) {
		return;
	}
	Badge badge = (Badge) component;
	ResponseWriter rw = context.getResponseWriter();
	String clientId = badge.getClientId();

	if (!component.isRendered()) {
		return;
	}
	String styleClass = badge.getStyleClass();
	String style=badge.getStyle();
	String val = getValue2Render(context, badge);

	generateBadge(context, badge, rw, clientId, styleClass, style, val, null);
}
 
Example 16
Source Project: BootsFaces-OSP   Source File: Tooltip.java    License: Apache License 2.0 6 votes vote down vote up
private static void verifyAndWriteTooltip(FacesContext context, ResponseWriter rw, String tooltip,
		String position, String container) throws IOException {
	if (null == position)
		position="bottom";
	boolean ok = "top".equals(position);
	ok |= "bottom".equals(position);
	ok |= "right".equals(position);
	ok |= "left".equals(position);
	ok |= "auto".equals(position);
	ok |= "auto top".equals(position);
	ok |= "auto bottom".equals(position);
	ok |= "auto right".equals(position);
	ok |= "auto left".equals(position);
	if (!ok) {
		position = "bottom";
		context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Wrong JSF markup",
				"Tooltip position must either be 'auto', 'top', 'bottom', 'left' or 'right'."));
	}
	rw.writeAttribute("data-toggle", "tooltip", null);
	rw.writeAttribute("data-placement", position, "data-placement");
	rw.writeAttribute("data-container", container, "data-container");
	rw.writeAttribute("title", tooltip, null);
}
 
Example 17
@Override
protected void renderChildren(FacesContext context, ResponseWriter writer, TreeContextImpl tree) throws IOException {
    int depth = tree.getDepth();
    if (depth == 1) {
        super.renderChildren(context, writer, tree);
    }
    else {
        if (tree.getNode().getType() != ITreeNode.NODE_LEAF) {
            DojoMenuRenderer r = new DojoMenuRenderer();
            String clientId = tree.getClientId(context, "ab", 1); // $NON-NLS-1$

            String mid = clientId + MENUID_SUFFIX; // $NON-NLS-1$
            r.setMenuId(mid);

            if (StringUtil.isNotEmpty(clientId)) {
                r.setConnectId(clientId);
            }

            r.setConnectEvent("onclick"); // $NON-NLS-1$
            r.render(context, writer, tree);
        }
    }
}
 
Example 18
public void encodeEnd(FacesContext context, UIComponent component) throws
  IOException {
    if (!component.isRendered()) {
      return;
    }

    ResponseWriter writer = context.getResponseWriter();

    String jsfId = (String) RendererUtil.getAttribute(context, component, "id");
    String id = jsfId;

    if (component.getId() != null &&
        !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
    {
      id = component.getClientId(context);
    }

    writer.write("</div>");

//    writer.write("<script type=\"text/javascript\">");
//    writer.write("  showHideDiv('" + id +
//        "', '" +  RESOURCE_PATH + "');");
//    writer.write("</script>");
  }
 
Example 19
Source Project: sakai   Source File: QuestionLinkRender.java    License: Educational Community License v2.0 6 votes vote down vote up
/** 
 * @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
 */
public void encodeBegin(FacesContext context, UIComponent component)
    throws IOException
{
  ResponseWriter writer = context.getResponseWriter();
  String showLink = (String) component.getAttributes().get("showLink");
  String URL = (String) component.getAttributes().get("URL");
  String message = (String) component.getAttributes().get("message");
  if ("true".equals(showLink))
  {
    writer.write("<a href=\"");
    writer.write(URL);
    writer.write("\" target=\"content\">");
    writer.write(message);
    writer.write("</a>");
  }
}
 
Example 20
@Override
    public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
        super.encodeBegin(context, component);
        ResponseWriter w = context.getResponseWriter();
        
        String clientId = component.getClientId(context);
        
        w.startElement("div", component); // $NON-NLS-1$
        w.writeAttribute("id", clientId, "id"); // $NON-NLS-1$ $NON-NLS-2$

        // Force the width/height to the parent
        w.writeAttribute("style", "width:100%;height:100%", null); // $NON-NLS-1$ $NON-NLS-2$
        
/*        
        UIDojoTabPane pane = (UIDojoTabPane)component.getParent();
        String style = pane.getContentStyle();
        if(StringUtil.isNotEmpty(style)) {
            w.writeAttribute("style", style, null); // $NON-NLS-1$
        }
        String styleClass = pane.getContentStyleClass();
        if(StringUtil.isNotEmpty(styleClass)) {
            w.writeAttribute("class", styleClass, null); // $NON-NLS-1$
        }
*/        
    }
 
Example 21
protected void writeTitleBarTabsArea(FacesContext context, ResponseWriter w, UIApplicationLayout c, BasicApplicationConfigurationImpl configuration) throws IOException {
    
    // OneUIv3: <nav aria-label="Tabs navigation" role="navigation">
    String titleBarNavTag = (String)getProperty(PROP_TITLEBARNAVTAG);
    if( StringUtil.isNotEmpty(titleBarNavTag) ){
        w.startElement(titleBarNavTag, null);
        // TODO should this be using DIV instead of NAV? the OneUI sample has:
        //<!-- nav is an HTML5 element. Use div if you are using HTML4. -->
        //<nav role="navigation toolbar" aria-label="[Tabs navigation]">
        //String titleBarNavAriaLabel = (String)getProperty(PROP_TITLEBARNAVARIALABEL);
        String titleBarNavAriaLabel = configuration.getTitleBarLabel();
        if( StringUtil.isNotEmpty(titleBarNavAriaLabel) ){
            w.writeAttribute("aria-label", titleBarNavAriaLabel, null); // $NON-NLS-1$
        }
        String titleBarNavRole = (String)getProperty(PROP_TITLEBARNAVROLE);
        if( StringUtil.isNotEmpty(titleBarNavRole) ){
            w.writeAttribute("role", titleBarNavRole, null); // $NON-NLS-1$
        }
        newLine(w);
    }
    
    // Write the tabs
    writeTitleBarTabs(context, w, c, configuration);
    
    // OneUIv3: </nav>
    if( StringUtil.isNotEmpty(titleBarNavTag) ){
        w.endElement(titleBarNavTag);
        newLine(w);
    }
}
 
Example 22
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
    UIWidgetContainer container = (UIWidgetContainer)component;
    if(!container.isRendered()) {
        return;
    }
    ResponseWriter w = context.getResponseWriter();
    writeMainFrame(context, w, container);
}
 
Example 23
@Override
protected void renderEntryNode(FacesContext context, ResponseWriter writer, TreeContextImpl tree) throws IOException {
    if(!tree.getNodeContext().isFirstNode()) {
        renderSeparator(context, writer, tree);
    }
    super.renderEntryNode(context, writer, tree);
}
 
Example 24
Source Project: XPagesExtensionLibrary   Source File: ForumViewRenderer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void writeContent(FacesContext context, ResponseWriter w, AbstractDataView c, ViewDefinition viewDef) throws IOException {
    if(DEBUG) {
        w.writeComment("Start ForumView content"); // $NON-NLS-1$
        newLine(w);
    }
    w.startElement("ul",c); // $NON-NLS-1$
    w.writeAttribute("id", c.getAjaxContainerClientId(context), null); // $NON-NLS-1$
    
    String style = (String)getProperty(PROP_MAINLISTSTYLE);
    if(StringUtil.isNotEmpty(style)) {
        w.writeAttribute("style", style, null); // $NON-NLS-1$
    }
    String styleClass = (String)getProperty(PROP_MAINLISTCLASS);
    if(StringUtil.isNotEmpty(styleClass)) {
        w.writeAttribute("class", styleClass, null); // $NON-NLS-1$
    }
    newLine(w);
    
    // And the rows
    int first = c.getFirst();
    int count = c.getRows();
    writeRows(context, w, c, viewDef, first, count);
    
    w.endElement("ul"); // $NON-NLS-1$
    newLine(w);
    if(DEBUG) {
        w.writeComment("End ForumView content"); // $NON-NLS-1$
        newLine(w);
    }
}
 
Example 25
Source Project: sakai   Source File: ToolBarRenderer.java    License: Educational Community License v2.0 5 votes vote down vote up
public void encodeBegin(FacesContext context, UIComponent component) throws IOException
{
    if(!component.isRendered()){
        //tool_bar tag is not to be rendered, return now
        return;
    }
    ResponseWriter writer = context.getResponseWriter();
    writer.write("<ul class=\"navIntraTool actionToolbar\">");
}
 
Example 26
@Override
protected void renderEntryItemContent(FacesContext context, ResponseWriter writer, TreeContextImpl tree, boolean enabled, boolean selected) throws IOException {
    boolean leaf = tree.getNode().getType()==ITreeNode.NODE_LEAF;
    if(leaf) {
        super.renderEntryItemContent(context, writer, tree, enabled, selected);
    } else {
        renderPopupButton(context, writer, tree, enabled, selected);
    }
}
 
Example 27
Source Project: XPagesExtensionLibrary   Source File: DataViewRenderer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void writeRows(FacesContext context, ResponseWriter w, AbstractDataView c, ViewDefinition viewDef, int first, int rows) throws IOException {
    super.writeRows(context, w, c, viewDef, first, rows);
    
    // Ensure that the current row is properly closed 
    closeOpenedRow(context, w, c, viewDef);
}
 
Example 28
Source Project: BootsFaces-OSP   Source File: DropButtonRenderer.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * This methods generates the HTML code of the current b:dropButton. <code>encodeBegin</code> generates the
 * start of the component. After the, the JSF framework calls <code>encodeChildren()</code> to generate the HTML
 * code between the beginning and the end of the component. For instance, in the case of a panel component the
 * content of the panel is generated by <code>encodeChildren()</code>. After that, <code>encodeEnd()</code> is
 * called to generate the rest of the HTML code.
 *
 * @param context the FacesContext.
 * @param component the current b:dropButton.
 * @throws IOException thrown if something goes wrong when writing the HTML code.
 */
@Override
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
	if (!component.isRendered()) {
		return;
	}
	DropButton dropButton = (DropButton) component;
	ResponseWriter rw = context.getResponseWriter();
	rw.endElement("ul");

	rw.endElement("div"); // btn-group
	Tooltip.activateTooltips(context, dropButton);
}
 
Example 29
private void encodeInput(FacesContext context, SketchPad sketchPad) throws IOException {
	ResponseWriter writer = context.getResponseWriter();
	String inputId = getInputId(sketchPad, context);
	writer.startElement("input", sketchPad);
	writer.writeAttribute("type", "hidden", null);
	writer.writeAttribute("id", inputId, null);
	writer.writeAttribute("name", inputId, null);
	Object value = getValue(context, sketchPad);
	if (value != null) {
		writer.writeAttribute("value", value.toString(), null);
	}
	writer.endElement("input");
}
 
Example 30
Source Project: BootsFaces-OSP   Source File: ColumnRenderer.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * This methods generates the HTML code of the current b:column.
 * <code>encodeBegin</code> generates the start of the component. After the,
 * the JSF framework calls <code>encodeChildren()</code> to generate the
 * HTML code between the beginning and the end of the component. For
 * instance, in the case of a panel component the content of the panel is
 * generated by <code>encodeChildren()</code>. After that,
 * <code>encodeEnd()</code> is called to generate the rest of the HTML code.
 *
 * @param context
 *            the FacesContext.
 * @param component
 *            the current b:column.
 * @throws IOException
 *             thrown if something goes wrong when writing the HTML code.
 */
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
	Column column = (Column) component;

	if (column.isRendered()) {
		ResponseWriter rw = context.getResponseWriter();

		String style = column.getStyle();
		String sclass = column.getStyleClass();

		rw.startElement("div", column);
		if (null != column.getDir()) {
			rw.writeAttribute("dir", column.getDir(), "dir");
		}

		if (this != null) {
			rw.writeAttribute("id", column.getClientId(), "id");
			Tooltip.generateTooltip(FacesContext.getCurrentInstance(), column, rw);
		}

		if (sclass == null) {
			sclass = Responsive.getResponsiveStyleClass(column).trim();
			if (sclass.length()==0) sclass=null;
		} else {
			sclass += Responsive.getResponsiveStyleClass(column);
		}
		rw.writeAttribute("class", sclass, "class");
		if (style != null) {
			rw.writeAttribute("style", style, "style");
		}
		beginDisabledFieldset(column, rw);
	}
}