Java Code Examples for javax.faces.component.UIComponent#isRendered()

The following examples show how to use javax.faces.component.UIComponent#isRendered() . 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 check out the related API usage on the sidebar.
Example 1
Source File: HideDivisionRenderer.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public void encodeChildren(FacesContext context, UIComponent component)
	throws IOException
{
  if (!component.isRendered())
  {
    return;
  }

  Iterator children = component.getChildren().iterator();
  while (children.hasNext()) {
    UIComponent child = (UIComponent) children.next();
    if(!((child instanceof org.sakaiproject.tool.messageforums.jsf.BarLinkComponent)||
        (child instanceof HtmlOutputText)))
    {
      child.encodeBegin(context);
      child.encodeChildren(context);
      child.encodeEnd(context);
    }
  }
}
 
Example 2
Source File: BadgeRenderer.java    From BootsFaces-OSP with 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 3
Source File: AnchorReferenceRenderer.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * <p>Faces render output method to output script tag.</p>
   * <p>Method Generator: org.sakaiproject.tool.assessment.devtoolsRenderMaker</p>
 *
 *  @param context   <code>FacesContext</code> for the current request
 *  @param component <code>UIComponent</code> being rendered
 *
 * @throws IOException if an input/output error occurs
 */
public void encodeBegin(FacesContext context, UIComponent component)
  throws IOException
{

  if (!component.isRendered())
  {
    return;
  }

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

  ResponseWriter writer = context.getResponseWriter();
  String contextPath = context.getExternalContext()
    .getRequestContextPath();
  writer.write("<a name=\"" + name +  "\"/>");
}
 
Example 4
Source File: OpenStreetMapRenderer.java    From BootsFaces-OSP with 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 5
Source File: DebugRenderer.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public void encodeBegin(FacesContext context, UIComponent component) throws IOException
{
	if (!component.isRendered()) return;

	ResponseWriter writer = context.getResponseWriter();
	writer.write("<xmp>");
	writer.write("***** DEBUG TAG RENDER OUTPUT *****\n\n");

	dumpJSFVariable("applicationScope", context);
	dumpJSFVariable("sessionScope", context);
	dumpJSFVariable("requestScope", context);
	dumpJSFVariable("toolScope", context);
	dumpJSFVariable("toolConfig", context);
	dumpJSFVariable("param", context);
	writer.write("</xmp>");
}
 
Example 6
Source File: HideDivisionRenderer.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
* <p>Faces render output method .</p>
* <p>Method Generator: org.sakaiproject.tool.assessment.devtoolsRenderMaker</p>
*
*  @param context   <code>FacesContext</code> for the current request
*  @param component <code>UIComponent</code> being rendered
*
* @throws IOException if an input/output error occurs
*/
 public void encodeBegin(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);
     }

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

     writer.write("<" + BARTAG + " onclick=\"javascript:showHideDiv('" + id +
       "', '" +  RESOURCE_PATH + "');\" class=\"" + BARSTYLE + "\">");
     writer.write("  <img id=\"" + id + "__img_hide_division_" + "\" alt=\"" +
        title + "\"");
     writer.write("    src=\""   + BARIMG + "\" style=\"" + CURSOR + "\" />");
     writer.write("  " + title + "");
     writer.write("</"+ BARTAG + ">");
     writer.write("<div \" style=\"display:none\" " +
                  " id=\"" + id + "__hide_division_" + "\">");
 }
 
Example 7
Source File: NavLinkRenderer.java    From BootsFaces-OSP with Apache License 2.0 5 votes vote down vote up
/**
 * Find all parameters to include by looking at nested uiparams and params of
 * navigation case
 */
protected Map<String, List<String>> getParams(NavigationCase navCase, AbstractNavLink button) {
	Map<String, List<String>> params = new LinkedHashMap<String, List<String>>();

	// UIParams
	for (UIComponent child : ((UIComponent) button).getChildren()) {
		if (child.isRendered() && (child instanceof UIParameter)) {
			UIParameter uiParam = (UIParameter) child;

			if (!uiParam.isDisable()) {
				List<String> paramValues = params.get(uiParam.getName());
				if (paramValues == null) {
					paramValues = new ArrayList<String>();
					params.put(uiParam.getName(), paramValues);
				}

				paramValues.add(String.valueOf(uiParam.getValue()));
			}
		}
	}

	// NavCase Params
	Map<String, List<String>> navCaseParams = navCase.getParameters();
	if (navCaseParams != null && !navCaseParams.isEmpty()) {
		for (Map.Entry<String, List<String>> entry : navCaseParams.entrySet()) {
			String key = entry.getKey();

			// UIParams take precedence
			if (!params.containsKey(key)) {
				params.put(key, entry.getValue());
			}
		}
	}

	return params;
}
 
Example 8
Source File: CarouselControlRenderer.java    From BootsFaces-OSP with Apache License 2.0 5 votes vote down vote up
public void myEncodeBegin(FacesContext context, UIComponent component) throws IOException {
	if (!component.isRendered()) {
		return;
	}
	CarouselControl carouselControl = (CarouselControl) component;
	ResponseWriter rw = context.getResponseWriter();
	// String clientId = carouselControl.getClientId();

	/**
	 * <a class=
	 * "left carousel-control" href="#myCarousel" role="button" data-slide=
	 * "prev"> <span class=
	 * "glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
	 * <span class="sr-only">Previous</span> </a>
	 */

	// put custom code here
	// Simple demo widget that simply renders every attribute value
	rw.startElement("carouselControl", carouselControl);
	Tooltip.generateTooltip(context, carouselControl, rw);

	rw.writeAttribute("id", carouselControl.getId(), "id");
	Tooltip.activateTooltips(context, carouselControl);
	AJAXRenderer.generateBootsFacesAJAXAndJavaScript(context, carouselControl, rw, false);

	UIComponent parent = carouselControl.getParent();
	rw.writeAttribute("href", "#" + parent.getClientId(), "href");
	rw.writeAttribute("role", "button", "role");

	String direction = carouselControl.getDirection();
	rw.writeAttribute("data-slide", direction, "data-slide");
	String styleClass = direction + " carousel-control";
	if (null != carouselControl.getStyleClass())
		styleClass += " " + carouselControl.getStyleClass();
	rw.writeAttribute("styleClass", styleClass, "styleClass");

	rw.writeAttribute("style", carouselControl.getStyle(), "style");
}
 
Example 9
Source File: DynaTableRenderer.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * <p>Faces render output method .</p>
 * <p>Encode end of table.</p>
 *
 *  @param context   <code>FacesContext</code> for the current request
 *  @param component <code>UIComponent</code> being rendered
 *
 * @throws IOException if an input/output error occurs
 */
public void encodeEnd(FacesContext context, UIComponent component) throws
  IOException
{
  if (!component.isRendered())
  {
    return;
  }
  ResponseWriter writer = context.getResponseWriter();
  writer.endElement("table");
}
 
Example 10
Source File: RemoteCommandRenderer.java    From BootsFaces-OSP with Apache License 2.0 5 votes vote down vote up
/**
 * This methods generates the HTML code of the current b:remoteCommand.
 * @param context the FacesContext.
 * @param component the current b:remoteCommand.
 * @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;
	}
	RemoteCommand remoteCommand = (RemoteCommand) component;
	ResponseWriter rw = context.getResponseWriter();
	String clientId = remoteCommand.getClientId();

	String parameters=remoteCommand.getParameters();
	String parametersAsJson=null;
	if (null != parameters && parameters.length()>0) {
		parametersAsJson = "";
		String[] params = parameters.split(",");
		for (String p: params) {
			p=p.trim();
			parametersAsJson += "'" + p + "':" + p + ",";
		}
		parametersAsJson=parametersAsJson.substring(0, parametersAsJson.length()-1);
	}
	StringBuilder call = AJAXRenderer.generateAJAXCall(context, remoteCommand, null, parametersAsJson);
	String name = remoteCommand.getName();
	if (null == name) {
		throw new FacesException("b:remoteCommand: Please define the name of the JavaScript function calling the Java backend.");
	}
		
	rw.startElement("script", component);
	rw.writeAttribute("id", clientId, null);
	String c = call.toString().replace("callAjax(this,", "callAjax(document.getElementById('" + clientId + "'),");
	if (parameters!=null) {
		rw.append("function " + name + "(" + parameters + ", event){" + c + "}");
	} else {
		rw.append("function " + name + "(event){" + c + "}");
	}
	rw.endElement("script");

}
 
Example 11
Source File: ToolBarRenderer.java    From sakai with 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 12
Source File: DialogContentRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
    boolean rendered = component.isRendered();
    if(!rendered) {
        return;
    }
    ResponseWriter w = context.getResponseWriter();

    writeButtonBar(context, w, (UIDialogContent)component);
}
 
Example 13
Source File: RendererUtil.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Helper method for recursively encoding a component.
 * @param context the given FacesContext
 * @param component the UIComponent to render
 * @throws IOException
 */
public static void encodeRecursive(FacesContext context,
  UIComponent component) throws IOException
{
  if (!component.isRendered())
  {
    return;
  }

  component.encodeBegin(context);

  if (component.getRendersChildren())
  {
    component.encodeChildren(context);
  }
  else
  {
    Iterator iter = component.getChildren().iterator();

    while (iter.hasNext())
    {
      UIComponent child = (UIComponent) iter.next();
      encodeRecursive(context, child);
    }
  }
  component.encodeEnd(context);
}
 
Example 14
Source File: WellRenderer.java    From BootsFaces-OSP with Apache License 2.0 5 votes vote down vote up
/**
 * This methods generates the HTML code of the current b:well.
 * <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:well.
 * @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;
	}
	Well well = (Well) component;
	ResponseWriter rw = context.getResponseWriter();
	String clientId = well.getClientId();

	String sz = well.getSize();

	rw.startElement("div", well);
	rw.writeAttribute("id", clientId, "id");
	String style = well.getStyle();
	if (null != style) {
		rw.writeAttribute("style", style, null);
	}
	String styleClass = well.getStyleClass();
	if (null == styleClass)
		styleClass = "";
	else
		styleClass = " " + styleClass;
	styleClass += Responsive.getResponsiveStyleClass(well, false);
	Tooltip.generateTooltip(context, well, rw);

	if (sz != null) {
		rw.writeAttribute("class", "well well-" + sz + styleClass, "class");
	} else {
		rw.writeAttribute("class", "well" + styleClass, "class");
	}
	beginDisabledFieldset(well, rw);
	
	Object value = well.getValue();
	if (null != value) {
		rw.writeText(String.valueOf(value), null);
	}
}
 
Example 15
Source File: HierPvtMsgDataTableRender.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * <p>
 * Return an Iterator over the <code>UIColumn</code> children of the
 * specified <code>UIData</code> that have a <code>rendered</code>
 * property of <code>true</code>.
 * </p>
 * 
 * @param data
 *            <code>UIData</code> for which to extract children
 */
private Iterator getColumns(UIData data) {

	List results = new ArrayList();
	Iterator kids = data.getChildren().iterator();
	while (kids.hasNext()) {
		UIComponent kid = (UIComponent) kids.next();
		if ((kid instanceof UIColumn) && kid.isRendered()) {
			results.add(kid);
		}
	}
	return (results.iterator());

}
 
Example 16
Source File: DataTableRenderer.java    From ctsms with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void encodeThead(FacesContext context, DataTable table) throws IOException {
	ResponseWriter writer = context.getResponseWriter();
	ColumnGroup group = table.getColumnGroup("header");
	writer.startElement("thead", null);
	encodeFacet(context, table, table.getHeader(), DataTable.HEADER_CLASS, "th");
	if (table.isPaginator() && !table.getPaginatorPosition().equalsIgnoreCase("bottom")) {
		encodePaginatorMarkup(context, table, "top", "th", org.primefaces.component.api.UIData.PAGINATOR_TOP_CONTAINER_CLASS);
	}
	if (group != null && group.isRendered()) {
		for (UIComponent child : group.getChildren()) {
			if (child.isRendered() && child instanceof Row) {
				Row headerRow = (Row) child;
				writer.startElement("tr", null);
				for (UIComponent headerRowChild : headerRow.getChildren()) {
					if (headerRowChild.isRendered()
							&& headerRowChild instanceof Column
							&& ColumnManagementBean.isVisible((Column) headerRowChild)) {
						encodeColumnHeader(context, table, (Column) headerRowChild);
					}
				}
				writer.endElement("tr");
			}
		}
	} else {
		writer.startElement("tr", null);
		writer.writeAttribute("role", "row", null);
		for (Column column : table.getColumns()) {
			if (column.isRendered()
					&& ColumnManagementBean.isVisible(column)) {
				if (column instanceof Columns) {
					encodeColumnsHeader(context, table, (Columns) column);
				} else {
					encodeColumnHeader(context, table, column);
				}
			}
		}
		writer.endElement("tr");
	}
	writer.endElement("thead");
}
 
Example 17
Source File: OpenStreetMapRenderer.java    From BootsFaces-OSP with Apache License 2.0 4 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 encodeEnd(FacesContext context, UIComponent component) throws IOException {
	if (!component.isRendered()) {
		return;
	}
	OpenStreetMap openStreetMap = (OpenStreetMap) component;
	ResponseWriter rw = context.getResponseWriter();
	String clientIdRaw = openStreetMap.getClientId();
	String clientId = clientIdRaw.replace(":", "");

	rw.endElement("div");

	rw.startElement("script", component);
	rw.writeText("var " + clientId + "_map = L.map('" + clientIdRaw + "', {center: [" + openStreetMap.getCenter()
			+ "], zoom: " + openStreetMap.getZoom() + ", layers: L.tileLayer('" + openStreetMap.getUrlTemplate()
			+ "', {id: 'osm', attribution: '" + openStreetMap.getAttribution() + "', maxZoom: "
			+ openStreetMap.getMaxZoom() + ", minZoom: " + openStreetMap.getMinZoom() + "}), dragging:"
			+ openStreetMap.isDragging() + ", zoomControl:" + openStreetMap.isZoomControl() + " });", null);
	rw.writeText("if('" + openStreetMap.getMarker() + "')", null);
	rw.writeText("{", null);
	rw.writeText("var " + clientId + "_marker = L.marker([" + openStreetMap.getMarker()
			+ "],{icon: new L.Icon({iconSize: [25, 41], iconAnchor: [25, 41], popupAnchor: [-12, -45], iconUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/"+openStreetMap.LEAFLET_VERSION+"/images/marker-icon.png', shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/"+openStreetMap.LEAFLET_VERSION+"/images/marker-shadow.png'})}).addTo("
			+ clientId + "_map);", null);
	rw.writeText("if('" + openStreetMap.getPopupMsg() + "')", null);
	rw.writeText(clientId + "_marker.bindPopup('" + openStreetMap.getPopupMsg() + "');", null);
	rw.writeText("}", null);
	rw.writeText("if(!" + openStreetMap.isZoomGlobal() + ")", null);
	rw.writeText("{", null);
	rw.writeText(clientId + "_map.touchZoom.disable();", null);
	rw.writeText(clientId + "_map.doubleClickZoom.disable();", null);
	rw.writeText(clientId + "_map.scrollWheelZoom.disable();", null);
	rw.writeText(clientId + "_map.boxZoom.disable();", null);
	rw.writeText(clientId + "_map.keyboard.disable();", null);
	rw.writeText("}", null);
	rw.writeText("if(" + openStreetMap.isMiniMap() + ")", null);
	rw.writeText("{", null);
	rw.writeText("new L.Control.MiniMap(L.tileLayer('" + openStreetMap.getUrlTemplate() + "', {}), {", null);
	rw.writeText("toggleDisplay: true,", null);
	rw.writeText("zoomAnimation: true,", null);
	rw.writeText("position: '" + openStreetMap.getMiniMapPosition() + "',", null);
	rw.writeText("width: " + openStreetMap.getMiniMapWidth() + ",", null);
	rw.writeText("height: " + openStreetMap.getMiniMapWidth(), null);
	rw.writeText("}).addTo(" + clientId + "_map);", null);
	rw.writeText("}", null);
	rw.endElement("script");
}
 
Example 18
Source File: RowGroupDataTableRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void encodeInnerHtml(FacesContext facesContext, UIComponent component)throws IOException {

		UIData uiData = (UIData) component;
		ResponseWriter writer = facesContext.getResponseWriter();

		Styles styles = getStyles(uiData);
		
		int first = uiData.getFirst();
		int rows = uiData.getRows();
		int rowCount = uiData.getRowCount();
		if (rows <= 0)
		{
			rows = rowCount - first;
		}
		int last = first + rows;
		if (last > rowCount)
			last = rowCount;

		for (int i = first; i < last; i++)
		{
			uiData.setRowIndex(i);
			if (!uiData.isRowAvailable())
			{
                log.warn("Row is not available. Rowindex = " + i);
				return;
			}

			int columns = component.getChildCount();
			renderCategoryRow(i, columns, uiData, writer, i==first);

			beforeRow(facesContext, uiData);
			HtmlRendererUtils.writePrettyLineSeparator(facesContext);
			renderRowStart(facesContext, writer, uiData, styles, i);

			List children = component.getChildren();
			for (int j = 0, size = component.getChildCount(); j < size; j++)
			{
				UIComponent child = (UIComponent) children.get(j);
				if(child.isRendered())
				{
					encodeColumnChild(facesContext, writer, uiData, child, styles, j);
				}
			}
			renderRowEnd(facesContext, writer, uiData);

			afterRow(facesContext, uiData);
		}
	}
 
Example 19
Source File: PopupRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
   * <p>Faces render output method .</p>
   * <p>Method Generator: org.sakaiproject.tool.assessment.devtoolsRenderMaker</p>
   *
   *  @param context   <code>FacesContext</code> for the current request
   *  @param component <code>UIComponent</code> being rendered
   *
   * @throws IOException if an input/output error occurs
   */
  public void encodeBegin(FacesContext context, UIComponent component) throws
      IOException {

    if ( !component.isRendered())
    {
      return;
    }

    ResponseWriter writer = context.getResponseWriter();
    String id = (String) component.getClientId(context);
    String title = (String) RendererUtil.getAttribute(context, component, "title");
    String url = (String) RendererUtil.getAttribute(context, component, "url");
    String target = (String) RendererUtil.getAttribute(context, component, "target");
    String toolbar = (String) RendererUtil.getAttribute(context, component, "toolbar");
    String menubar = (String) RendererUtil.getAttribute(context, component, "menubar");
    String personalbar = (String) RendererUtil.getAttribute(context, component, "personalbar");
// temporary workaround ClassCastException
    String width = null;//(String) RendererUtil.getAttribute(context, component, "width");
    String height = null; //(String) RendererUtil.getAttribute(context, component, "height");
    String scrollbars = (String) RendererUtil.getAttribute(context, component, "scrollbars");
    String resizable = (String) RendererUtil.getAttribute(context, component, "resizable");

    if (title == null) {
      title = "     ";
    }
    if (target == null) {
      target = "sakai_popup"; /** todo: put in resource*/
    }
    if (width == null) {
      width = "650";
    }
    if (height == null) {
      height = "375";
    }
    toolbar = RendererUtil.makeSwitchString(toolbar, false, true, true, true, false, false);
    menubar = RendererUtil.makeSwitchString(menubar, false, true, true, true, false, false);
    personalbar = RendererUtil.makeSwitchString(personalbar, false, true, true, true, false, false);
    scrollbars = RendererUtil.makeSwitchString(scrollbars, false, true, true, true, false, false);
    resizable = RendererUtil.makeSwitchString(resizable, false, true, true, true, false, false);

    String buttonSwitch = (String) RendererUtil.getAttribute(context, component, "useButton");
    boolean useButton = Boolean.getBoolean(
        RendererUtil.makeSwitchString(buttonSwitch, false, true, true, false, false, false));

    if (useButton) {
      writer.write("<!-- DEBUG: useButton=true -->");
      writer.write("<input");
      writer.write("  id=\"" + id + "\"");
      writer.write("  type=\"button\"");
      writer.write("  title=\"" + title + "\"");
      writer.write("  value=\"" + title + "\"");
      writer.write("  onclick=\"window.open('" + url + "','" + target +
                   "', 'toolbar=" + toolbar + ",menubar=" + menubar +
                   ",personalbar=" +
                   personalbar + ",width=" + width + ",height=" + height +
                   ",scrollbars=" + scrollbars + ",resizable=" + resizable +
                   "');\" />");
    }
    else {

      writer.write("<!-- DEBUG: useButton=false -->");
      writer.write("<a");
      writer.write("  id=\"" + id + "\"");
      writer.write("  title=\"" + title + "\"");
      writer.write("  href=\"#\"");
      writer.write("  onclick=\"window.open('" + url + "','" + target +
                   "', 'toolbar=" + toolbar + ",menubar=" + menubar +
                   ",personalbar=" +
                   personalbar + ",width=" + width + ",height=" + height +
                   ",scrollbars=" + scrollbars + ",resizable=" + resizable +
                   "');\" >");
      writer.write(title);
    }

  }
 
Example 20
Source File: DataLineRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * We put all our processing in the encodeChildren method
 * @param context
 * @param component
 * @throws IOException
 */
public void encodeChildren(FacesContext context, UIComponent component)
  throws IOException
{
  if (!component.isRendered())
  {
    return;
  }

  String clientId = null;

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

  ResponseWriter writer = context.getResponseWriter();

  if (clientId != null)
  {
    writer.startElement("span", component);
    writer.writeAttribute("id", clientId, "id");
  }

  UIData data = (UIData) component;

  int first = data.getFirst();
  int rows = data.getRows();

  // this is a special separator attribute, not supported by UIData
  String separator = (String) component.getAttributes().get("separator");
  if (separator==null) separator="";

  for (int i = first, n = 0; n < rows; i++, n++)
  {
    data.setRowIndex(i);
    if (!data.isRowAvailable())
    {
      break;
    }

    // between any two iterations add separator if there is one
    if (i!=first) writer.write(separator);

    Iterator iter = data.getChildren().iterator();
    while (iter.hasNext())
    {
      UIComponent column = (UIComponent) iter.next();
      if (!(column instanceof UIColumn))
      {
        continue;
      }
      RendererUtil.encodeRecursive(context, column);
      }
    }
    if (clientId != null)
      {
      writer.endElement("span");
    }

  }