Java Code Examples for javax.faces.context.ResponseWriter

The following are top voted examples for showing how to use javax.faces.context.ResponseWriter. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: myfaces-trinidad   File: ProcessChoiceBarRenderer.java   Source Code and License 6 votes vote down vote up
/**
  * @param context a <code>UIXRenderingContext</code>
  * @param valueAttri a <code>String</code> it is the value attribute  
  *  of the submit button 
  * @param nameAttri  a <code>String</code> it is the name attribute  
  *  of the submit button 
  *
  * This method renders an input element(type= submit) to submit the page.
  * The name attribute of this element is encoded with parameter name and
  * value pairs thus it would enable browsers to include the name of this 
  * element in its payLoad if it submits the page.
  *
  */
private void _renderSubmitButtonNonJSBrowser(
  UIXRenderingContext context,
  String         valueAttri,
  String         nameAttri
  ) throws IOException
{
  ResponseWriter writer = context.getResponseWriter();
  writer.startElement("input", null);
  renderAttribute(context, "type", "submit");
  renderAttribute(context, "value", valueAttri);
  renderAttribute(context, "name", nameAttri);
  renderStyleClassAttribute(context, 
        SkinSelectors.AF_COMMAND_BUTTON_STYLE_CLASS);
  writer.endElement("input");
}
 
Example 2
Project: myfaces-trinidad   File: DesktopTableRenderer.java   Source Code and License 6 votes vote down vote up
/**
 * renders the regular table column headers.
 */
protected final void renderRegularHeaders(FacesContext context, RenderingContext rc, TableRenderingContext tContext,
                                          UIComponent component, int physicalCol)
  throws IOException
{
  // this renders a whole bunch of <TH>...</TH> elements.
  // if there are columnGroups present, it will render some
  // </TR><TR><TH>...</TH> sequences.
  final ColumnData colData = tContext.getColumnData();
  _renderRegularColumns(context, tContext, component, physicalCol);
  int rowSpan = colData.getHeaderRowSpan();
  if (rowSpan > 1)
  {
    ResponseWriter writer = context.getResponseWriter();
    for (int i = 1; i < rowSpan; i++)
    {
      colData.setRowIndex(i);
      writer.endElement(XhtmlConstants.TABLE_ROW_ELEMENT);
      writer.startElement(XhtmlConstants.TABLE_ROW_ELEMENT, null);
      _renderRegularColumns(context, tContext, component, physicalCol);
    }
  }
}
 
Example 3
Project: myfaces-trinidad   File: XhtmlLafRenderer.java   Source Code and License 6 votes vote down vote up
/**
 * all data tables should call this one, so that a summary tag is written
 * out
 */
protected static void renderLayoutTableAttributes(
  UIXRenderingContext context,
  Object           cellpadding,
  Object           cellspacing,
  Object           border,
  Object           tableWidth,
  Object           summary
  ) throws IOException
{
  ResponseWriter writer = context.getResponseWriter();
  writer.writeAttribute("cellpadding", cellpadding, null);
  writer.writeAttribute("cellspacing", cellspacing, null);
  writer.writeAttribute("border", border, null);
  writer.writeAttribute("width", tableWidth, null);

  if (!isInaccessibleMode(context))
  {
    writer.writeAttribute("summary", summary, null);
  }
}
 
Example 4
Project: myfaces-trinidad   File: NavigationPaneRenderer.java   Source Code and License 6 votes vote down vote up
private void _writeOnclickProperty(
  RenderingContext rc,
  ResponseWriter   rw,
  UIXCommand       commandChild,
  boolean          actionSpecialCase,
  boolean          immediate,
  boolean          partialSubmit
  ) throws IOException
{
  if (actionSpecialCase)
  {
    String onclick = (String)_getCommandChildProperty(commandChild, "onclick");
    String script = _getAutoSubmitScript(rc, immediate, partialSubmit);
    rw.writeAttribute(
      "onclick", XhtmlUtils.getChainedJS(onclick, script, true), "onclick");
  }
  else // simple case, e.g. (destination != null)
  {
    _writeCommandChildProperty(rw, commandChild, "onclick");
  }
}
 
Example 5
Project: myfaces-trinidad   File: TestResponseWriter.java   Source Code and License 6 votes vote down vote up
@Override
public ResponseWriter cloneWithWriter(Writer writer)
{
  try
  {
    TestResponseWriter trw = new TestResponseWriter(writer, getContentType(),
                                                    getCharacterEncoding(),
                                                    _test,
                                                    _result);
    trw._depth = _depth;
    return trw;
  }
  catch (UnsupportedEncodingException e)
  {
    // this can't happen;  the character encoding should already
    // be legal.
    assert(false);
    throw new IllegalStateException();
  }
}
 
Example 6
Project: myfaces-trinidad   File: RepeatIdContextPropertyUINode.java   Source Code and License 6 votes vote down vote up
/**
 * 
 * render using the RepeatIdResponseWriter.
 * @param context
 * @param node
 * @throws IOException
 */
@Override
public void render(
  UIXRenderingContext context,
  UINode           node
  ) throws IOException
{
  ResponseWriter oldRW = RepeatIdResponseWriter.install(context.getFacesContext());
  try
  {
    super.render(context, node);
  }
  finally
  {
    RepeatIdResponseWriter.remove(context.getFacesContext(), oldRW);
  }
}
 
Example 7
Project: Multicentro_Mascotas   File: SentinelMenuRenderer.java   Source Code and License 6 votes vote down vote up
protected void encodeMarkup(FacesContext context, AbstractMenu abstractMenu)
/*     */     throws IOException
/*     */   {
/*  41 */     SentinelMenu menu = (SentinelMenu)abstractMenu;
/*  42 */     ResponseWriter writer = context.getResponseWriter();
/*  43 */     String clientId = menu.getClientId(context);
/*  44 */     String style = menu.getStyle();
/*  45 */     String styleClass = menu.getStyleClass();
/*  46 */     styleClass = "layout-menubar-container " + styleClass;
/*     */ 
/*  48 */     writer.startElement("ul", menu);
/*  49 */     if (shouldRenderId(null)) {
/*  50 */       writer.writeAttribute("id", clientId, "id");
/*     */     }
/*  52 */     writer.writeAttribute("class", styleClass, "styleClass");
/*  53 */     if (style != null) {
/*  54 */       writer.writeAttribute("style", style, "style");
/*     */     }
/*     */ 
/*  57 */     if (menu.getElementsCount() > 0) {
/*  58 */       encodeElements(context, menu, menu.getElements(), 0);
/*     */     }
/*     */ 
/*  61 */     writer.endElement("ul");
/*     */   }
 
Example 8
Project: myfaces-trinidad   File: RawTextRenderer.java   Source Code and License 6 votes vote down vote up
private void _renderText(
  UIXRenderingContext context,
  UINode           node,
  AttributeKey     attrKey
  ) throws IOException
{
  Object value = node.getAttributeValue(context, attrKey);
  if (value != null)
  {
    ResponseWriter writer = context.getResponseWriter();
    if (value instanceof char[])
    {
      char[] text = (char[]) value;
      writer.write(text, 0, text.length);
    }
    else
    {
      writer.write(value.toString());
    }
  }
}
 
Example 9
Project: myfaces-trinidad   File: GenericEntry.java   Source Code and License 6 votes vote down vote up
static private void _service(
  FacesContext context,
  String jspName) throws IOException
{
  // Prepare the view tree
  if (NEW_FRAME_REDIRECT_ENTRY.equals(jspName))
    FredJSP.service(context);
  else if (CALENDAR_DIALOG_ENTRY.equals(jspName))
    CalendarDialogJSP.service(context);
  else if (INLINE_DATE_PICKER_ENTRY.equals(jspName))
    InlineDatePickerJSP.service(context);
  else if (COLOR_PICKER_ENTRY.equals(jspName))
    ColorPickerJSP.service(context);
  else
  {
    assert(false);
  }

  // And render
  ResponseWriter rw = context.getResponseWriter();
  rw.startDocument();
  RenderUtils.encodeRecursive(context, context.getViewRoot());
  rw.endDocument();
}
 
Example 10
Project: myfaces-trinidad   File: SubTabBarRenderer.java   Source Code and License 6 votes vote down vote up
/**
 * Overrride to render in three passes.
 */
@Override
protected void renderContent(
  UIXRenderingContext context,
  UINode           node
  ) throws IOException
{
  // save the inital stauts
  boolean actualLinkStatus = LinkUtils.isSelected(context);
  ResponseWriter writer = context.getResponseWriter();

  LinkRenderer.setSaveModelDisabled(context, true);

  Integer selectedIndex = (Integer)SubTabBarUtils.getSelectedIndex(context);

  // save away the selected index
  context.setLocalProperty( _SELECTED_NODE_KEY, selectedIndex);

  // render pass 1 - row with rendered children
  writer.startElement(DIV_ELEMENT, null);
  super.renderContent(context, node);
  writer.endElement(DIV_ELEMENT);
  LinkRenderer.setSaveModelDisabled(context, false);
  // restore it back to original status
  LinkUtils.setSelected(context,actualLinkStatus);
}
 
Example 11
Project: myfaces-trinidad   File: PanelAccordionRenderer.java   Source Code and License 6 votes vote down vote up
/**
 *  Encodes the disclosed child.
 *
 *  Generates the required markup for the disclosed child.
 *
 * @param context the faces context object
 * @param component the UIComponent object
 * @param detailItem the UIXShowDetailItem thats disclosed
 * @param out the response writer object
 * @throws IOException when some issues while writing output
 */
private void _encodeDetailItem(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  UIXShowDetail    detailItem,
  ResponseWriter   out
  ) throws IOException
{
  out.startElement("table", component);
  out.writeAttribute("cellSpacing", "0", null);
  out.writeAttribute("cellPadding", "0", null);
  out.writeAttribute("summary", "", null);

  renderStyleClass(context, rc, getContentStyleClass());

  out.startElement("tr", component);
  out.startElement("td", component);

  encodeChild(context, detailItem);

  out.endElement("td");
  out.endElement("tr");

  out.endElement("table"); // Ending table for the contained child
}
 
Example 12
Project: tap17-muggl-javaee   File: MapRenderer.java   Source Code and License 6 votes vote down vote up
/**
 * <p>Encode the ending of this component.</p>
 *
 * @param context <code>FacesContext</code> for the current request
 * @param component <code>UIComponent</code> to be encoded
 * @throws java.io.IOException
 */
@Override
public void encodeEnd(FacesContext context, UIComponent component)
        throws IOException {
    if ((context == null) || (component == null)) {
        throw new NullPointerException();
    }

    MapComponent map = (MapComponent) component;
    ResponseWriter writer = context.getResponseWriter();

    writer.startElement("input", map);
    writer.writeAttribute("type", "hidden", null);
    writer.writeAttribute("name", getName(context, map), "clientId");
    writer.endElement("input");
    writer.endElement("map");
}
 
Example 13
Project: ol3jsf   File: OSMLayer.java   Source Code and License 6 votes vote down vote up
@Override
public void encodeAll(FacesContext context) throws IOException {
	ResponseWriter writer = context.getResponseWriter();
	UIComponent parent = this;

	while (!(parent instanceof Map)) {
		parent = parent.getParent();
	}

	Map mapComponent = (Map) parent;
	String mapVar = mapComponent.getJsVariable();

	String isBaseLayer = getIsBaseLayer();
	String newLayer = "var newOsmLayer = new ol.layer.Tile({  source: new ol.source.OSM()});\n";
	String addLayer;

	if (isBaseLayer != null && isBaseLayer.equals("true")) {
		addLayer = "var layersCollection = " + mapVar + ".getLayers(); layersCollection.insertAt(0, newOsmLayer);\n";
	} else {
		addLayer = mapVar + ".addLayer(newOsmLayer);\n";
	}

	writer.write(newLayer + addLayer);
}
 
Example 14
Project: myfaces-trinidad   File: NavigationPaneRenderer.java   Source Code and License 6 votes vote down vote up
protected void appendIconAndText(
  FacesContext        context,
  RenderingContext    rc,
  ResponseWriter      rw,
  String              iconUri,
  Map<String, Object> itemData,
  boolean             isDisabled,
  boolean             isRtl
  ) throws IOException
{
  if ( (iconUri != null) && !isRtl )
  {
    _appendIcon(context, rw, iconUri, isRtl, rc);
  }
   _writeItemLink(context, rc, rw, itemData, isDisabled);
  if ( (iconUri != null) && isRtl )
  {
    _appendIcon(context, rw, iconUri, isRtl, rc);
  }
}
 
Example 15
Project: myfaces-trinidad   File: PanelBorderLayoutRenderer.java   Source Code and License 6 votes vote down vote up
private void _renderMarginSpacer(
  FacesContext     context,
  RenderingContext rc,
  Integer          rowSpan
  ) throws IOException
{
  ResponseWriter writer = context.getResponseWriter();

  writer.startElement("td", null);
  writer.writeAttribute("rowspan", rowSpan, null);
  Object spacerWidth = rc.getSkin().getProperty(
     SkinProperties.AF_PANEL_BORDER_LAYOUT_SPACER_WIDTH);
  if (spacerWidth != null)
    renderSpacer(context, rc, spacerWidth.toString(), "0");
  writer.endElement("td");
}
 
Example 16
Project: myfaces-trinidad   File: BodyRenderer.java   Source Code and License 6 votes vote down vote up
@Override
protected void encodeAll(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean
  ) throws IOException
{
  ResponseWriter writer = context.getResponseWriter();
  writer.startElement("body", component);
  renderId(context, component);
  renderAllAttributes(context, rc, component, bean);
  super.encodeAll(context, rc, component, bean);

  // Output a version comment at the bottom of the body
  _writeVersionInformation(context, rc);
}
 
Example 17
Project: myfaces-trinidad   File: BodyRenderer.java   Source Code and License 6 votes vote down vote up
@Override
protected void renderPPRSupport(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean
  ) throws IOException
{
  super.renderPPRSupport(context, rc, component, bean);
  if (getFirstClickPassed(component, bean))
  {
    ResponseWriter writer = context.getResponseWriter();
    writer.startElement("script", null);
    renderScriptDeferAttribute(context, rc);
    renderScriptTypeAttribute(context, rc);
    writer.writeText("var _pprFirstClickPass=true;", null);
    writer.endElement("script");
  }
}
 
Example 18
Project: myfaces-trinidad   File: NavigationPathRenderer.java   Source Code and License 6 votes vote down vote up
private void _renderStartOfLink(
  UIXRenderingContext context,
  boolean      vertical,
  boolean      isLastChild) throws IOException
{
  ResponseWriter writer = context.getResponseWriter();

  if (vertical)
  {
    writer.startElement(DIV_ELEMENT, null);
  }

  // Breadcrumbs wrap within a page depending on the size of the
  // browser window. The wrap occurs to the right of the greater-than
  // symbol that follows after the breadcrumb text string,
  // and not within the text string itself.
  writer.startElement(XhtmlLafConstants.NO_BREAK_ELEMENT, null);
}
 
Example 19
Project: myfaces-trinidad   File: SkinPregenerationService.java   Source Code and License 6 votes vote down vote up
private static ResponseWriter _getResponseWriter(FacesContext context)
  throws IOException
{
  ExternalContext external  = context.getExternalContext();
  String contentType = "text/html";
  String encoding = "UTF-8";

  external.setResponseContentType(contentType);
  external.setResponseCharacterEncoding(encoding);
  
  ResponseWriter rw = context.getRenderKit().createResponseWriter(
    external.getResponseOutputWriter(),
    contentType,
    encoding);
  
  context.setResponseWriter(rw);
  
  return rw;
}
 
Example 20
Project: myfaces-trinidad   File: SimpleInputNumberSpinboxRenderer.java   Source Code and License 6 votes vote down vote up
/**
 * render the spinboxes after the text field. Render these even if
 * they are disabled.
 * @param context
 * @param rc
 * @param component
 * @param bean
 * @throws IOException
 */
@Override
protected void renderAfterTextField(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean
  ) throws IOException
{
  ResponseWriter rw = context.getResponseWriter();
  rw.startElement("td", component);
  rw.writeAttribute("align", "center", null);
  rw.writeAttribute("valign", "middle", null);

  renderStyleClass(context, rc, "af|inputNumberSpinbox::spinbox-cell");
  // use css to put in a space.???
  renderIcon(context, rc, component, bean);
  rw.endElement("td");
  rw.endElement("tr");
  rw.endElement("table");
}
 
Example 21
Project: myfaces-trinidad   File: ShowDetailItemRenderer.java   Source Code and License 6 votes vote down vote up
@Override
protected void encodeAll(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean
  ) throws IOException
{
  ResponseWriter rw = context.getResponseWriter();
  rw.startElement("span", component);
  renderId(context, component);
  renderAllAttributes(context, rc, component, bean);

  if (getDisclosed(component, bean))
  {
    encodeAllChildren(context, component);
  }
  rw.endElement("span");
}
 
Example 22
Project: myfaces-trinidad   File: GlobalHeaderRenderer.java   Source Code and License 6 votes vote down vote up
@Override
public void render(
  UIXRenderingContext context,
  UINode           node
  )throws IOException
{
  if ( getVisibleIndexedChildCount(context, node) < 1 )
  {
    ResponseWriter writer = context.getResponseWriter();

    // write out the horizontal rule
    writer.startElement("hr", node.getUIComponent());
    super.renderAttributes(context, node);
    writer.writeAttribute("size", "2", null);
    writer.endElement("hr");
    return;
  }

  super.render(context, node);
}
 
Example 23
Project: myfaces-trinidad   File: SimpleInputDateRenderer.java   Source Code and License 6 votes vote down vote up
@Override
protected void outputScriptletContent(
  FacesContext context,
  RenderingContext arc)
  throws IOException
{
  // get the tzOffset for the current date. I will compare this with
  // the tzOffset for the current data in javascript, and use it to
  // manipulate the formatted datefield's value so that it shows the

  // localeContext's timeZone, and not the time zone on the browser.
  TimeZone tz = arc.getLocaleContext().getTimeZone();
  int tzOffsetMinutes = tz.getOffset(System.currentTimeMillis())/(1000*60);
  ResponseWriter writer = context.getResponseWriter();
  writer.writeText("var _uixLocaleTZ=", null);
  writer.writeText(String.valueOf(tzOffsetMinutes), null);
  writer.writeText(";", null);
}
 
Example 24
Project: myfaces-trinidad   File: SelectRangeChoiceBarRenderer.java   Source Code and License 6 votes vote down vote up
/**
 * @todo GENERIC FIX: need to use renderURIAttribute() in Icon
 *  code to output the Icon URL.  But that'll break a zillion
 *  renderkit tests.
 */
private void _renderArrow(
  FacesContext     context,
  RenderingContext rc,
  Icon             icon,
  boolean          isNext,
  String           onclick
  ) throws IOException
{
  ResponseWriter writer = context.getResponseWriter();
  if (onclick != null)
  {
    writer.startElement("a", null);
    writer.writeURIAttribute("href", "#", null);
    writer.writeAttribute("onclick", onclick, null);
  }

  boolean isEnabled = (onclick != null);
  String titleKey = getIconTitleKey(isNext, isEnabled);
  String title = rc.getTranslatedString(titleKey);
  OutputUtils.renderIcon(context, rc, icon, title, null);

  if (onclick != null)
    writer.endElement("a");
}
 
Example 25
Project: myfaces-trinidad   File: PPRResponseWriter.java   Source Code and License 6 votes vote down vote up
public ResponseWriter cloneWithWriter(Writer writer)
{
  PPRResponseWriter ppr = new PPRResponseWriter(
    getResponseWriter().cloneWithWriter(writer),
    this);

  // BIG HACK: The JSF 1.1
  // ViewTag is going to clone the ResponseWriter so that
  // it can write its BodyContent out.  But that'll clone a
  // PPRResponseWriter, which then will adamantly refuse to write
  // out any content!  To "fix" this, we make the lousy assumption
  // that if we're being cloned, and our element depth is zero,
  // then we're probably being used in this way, and we should just
  // let everything through.
  // HOWEVER, in Facelets, cloneWithWriter() is called eaaaaarly.
  // Catch that by ignoring this unless we've at least had a call
  // to startDocument()
  _state.forceInsideTarget = (_state.documentStarted &&
                               (_state.elementDepth == 0));
  return ppr;
}
 
Example 26
Project: myfaces-trinidad   File: MenuListRenderer.java   Source Code and License 6 votes vote down vote up
@Override
protected void postrender(
  UIXRenderingContext context,
  UINode           node
)throws IOException
{
  ResponseWriter writer = context.getFacesContext().getResponseWriter();

  String style = PdaHtmlLafUtils.getStringAttributeValue(context,
                                                   node,
                                                   LIST_STYLE_ATTR);
  if (LIST_STYLE_LOWER_ALPHA.equals(style) ||
      LIST_STYLE_UPPER_ALPHA.equals(style) ||
      LIST_STYLE_DECIMAL.equals(style)
  )
  {
    writer.endElement("ol");
  }
  else
  {
    writer.endElement("ul");
  }
  super.postrender( context, node);
}
 
Example 27
Project: myfaces-trinidad   File: XhtmlLafRenderer.java   Source Code and License 6 votes vote down vote up
public static void writeAbsoluteImageURI(
  UIXRenderingContext context,
  String           attribute,
  String           uri) throws IOException
{
  if ((uri == null) || (uri.length() == 0))
    return;

  ResponseWriter writer = context.getResponseWriter();

  String encodedUri = getBaseImageURI(context) + uri;
  FacesContext facesContext = context.getFacesContext();
  if (facesContext != null)
    encodedUri = facesContext.getExternalContext().encodeResourceURL(encodedUri);
  writer.writeURIAttribute(attribute, encodedUri, null);
}
 
Example 28
Project: myfaces-trinidad   File: NavigationBarRenderer.java   Source Code and License 6 votes vote down vote up
private void _renderStartTableCell(
  UIXRenderingContext context,
  UINode           node,
  ResponseWriter   writer,
  boolean          renderAsTable,
  boolean          isBaseID
  ) throws IOException
{

  writer.startElement("td", null);
  if (!renderAsTable)
  {
    if (isBaseID)
    {
      renderID(context, node);
    }
  }
}
 
Example 29
Project: myfaces-trinidad   File: SimpleInputListOfValuesRenderer.java   Source Code and License 6 votes vote down vote up
@Override
protected void encodeAllAsNonElement(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean
  ) throws IOException
{
  ResponseWriter rw = context.getResponseWriter();
  boolean simple = getSimple(component, bean);
  if (simple)
  {
    rw.startElement("span", component);
    // put the outer style class here, like af_selectManyRadio, styleClass,
    // inlineStyle, 'state' styles like p_AFDisabled, etc.
    renderRootDomElementStyles(context, rc, component, bean);
  }
  super.encodeAllAsNonElement(context, rc, component, bean);
  if (simple)
    rw.endElement("span");
}
 
Example 30
Project: myfaces-trinidad   File: SimpleInputNumberSpinboxRenderer.java   Source Code and License 6 votes vote down vote up
/**
 * render the spinbox icons. <div>img</div><div>img</div>
 */
@Override
protected void renderIcon(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean
  ) throws IOException
{
  ResponseWriter rw = context.getResponseWriter();
  // render increment spinbox image
  rw.startElement("div", component);
  _renderSpinboxIcon(context, rc, component, bean, rw, true);
  rw.endElement("div");

  // render decrement spinbox image
  rw.startElement("div", component);
  _renderSpinboxIcon(context, rc, component, bean, rw, false);
  rw.endElement("div");
}
 
Example 31
Project: ctsms   File: TagCloudRenderer.java   Source Code and License 6 votes vote down vote up
protected void encodeMarkup(FacesContext context, TagCloud tagCloud) throws IOException {
	ResponseWriter writer = context.getResponseWriter();
	TagCloudModel model = tagCloud.getModel();
	String styleClass = tagCloud.getStyleClass();
	String style = tagCloud.getStyle();
	styleClass = styleClass == null ? TagCloud.STYLE_CLASS : TagCloud.STYLE_CLASS + " " + styleClass;
	writer.startElement("div", tagCloud);
	writer.writeAttribute("id", tagCloud.getClientId(context), "id");
	writer.writeAttribute("class", styleClass, "styleClass");
	if (style != null)
		writer.writeAttribute("style", style, "style");
	writer.startElement("ul", null);
	for (TagCloudItem item : model.getTags()) {
		writer.startElement("li", null);
		writer.writeAttribute("class", "ctsms-tagcloud-strength-" + item.getStrength(), null);
		String onclick = item.getOnclick();
		if (onclick != null && onclick.length() > 0) {
			writer.writeAttribute("onclick", onclick, null);
		}
		writer.writeText(item.getLabel(), null);
		writer.endElement("li");
	}
	writer.endElement("ul");
	writer.endElement("div");
}
 
Example 32
Project: myfaces-trinidad   File: FormRenderer.java   Source Code and License 6 votes vote down vote up
private static void _renderSubmitFormCheck(
  FacesContext     context,
  RenderingContext rc
  ) throws IOException
{
  // if scripting isn't supported, no need to do the rest
  if (!supportsScripting(rc))
    return;

  ResponseWriter writer = context.getResponseWriter();
  writer.startElement("script", null);
  renderScriptDeferAttribute(context, rc);
  // Bug #3426092:
  // render the type="text/javascript" attribute in accessibility mode
  renderScriptTypeAttribute(context, rc);

  writer.writeText("_submitFormCheck();", null);
  writer.endElement("script");
}
 
Example 33
Project: myfaces-trinidad   File: GoLinkRenderer.java   Source Code and License 5 votes vote down vote up
@Override
public void encodeEnd(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      comp,
  FacesBean        bean
  ) throws IOException
{
  ResponseWriter rw = context.getResponseWriter();
  rw.endElement("a");
}
 
Example 34
Project: myfaces-trinidad   File: PanelPartialRootRenderer.java   Source Code and License 5 votes vote down vote up
private static void _renderPartialBlocking(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component
  ) throws IOException
{
  if (PartialPageUtils.supportsBlocking(rc))
  {
    ResponseWriter writer = context.getResponseWriter();

    writer.startElement("div",  component);

    writer.writeAttribute("id", _PARTIAL_DIV_ID,
                          null);
    writer.writeAttribute("onclick",
                          _PARTIAL_DIV_CLICK_HANDLER, null);
    writer.writeAttribute("style",
                          _PARTIAL_DIV_STYLE, null);
    writer.writeAttribute("onkeydown", _PARTIAL_DIV_EAT_KEY_HANDLER, null);
    writer.writeAttribute("onkeyup", _PARTIAL_DIV_EAT_KEY_HANDLER, null);
    writer.writeAttribute("onmousedown", _PARTIAL_DIV_EAT_KEY_HANDLER, null);
    writer.writeAttribute("onmouseup", _PARTIAL_DIV_EAT_KEY_HANDLER, null);
    writer.writeAttribute("onkeypress", _PARTIAL_DIV_EAT_KEY_HANDLER, null);

    writer.endElement("div");
  }
}
 
Example 35
Project: myfaces-trinidad   File: TableLayoutRenderer.java   Source Code and License 5 votes vote down vote up
@Override
protected void encodeAll(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean
  ) throws IOException
{
  ResponseWriter rw = context.getResponseWriter();
  rw.startElement("table", component);
  renderId(context, component);
  renderAllAttributes(context, rc, component, bean);
  renderHAlign(context, rc, getHalign(component, bean));
  // TODO: if TABLES_CAP_ADVANCED and TABLES_CAP_ADVANCED_ATTRS
  // are both false, don't render cell padding, cell spacing, or border

  // Normally, you would think tableLayout would be a layout table. But this component also allows
  // the assignment of a summary, which is usually only present on a data table (and is set to ""
  // for a layout table). So, based on whether there is a summary attribute or not, we'll render as
  // either a data or layout table.
  Object summary = getSummary(component, bean);
  if (summary.equals(""))
  {
    OutputUtils.renderLayoutTableAttributes(context, rc, getCellPadding(component, bean),
      getCellSpacing(component, bean), getBorderWidth(component, bean),
      getWidth(component, bean));
  }
  else
  {
    OutputUtils.renderDataTableAttributes(context, rc, getCellPadding(component, bean),
      getCellSpacing(component, bean), getBorderWidth(component, bean),
      getWidth(component, bean), getSummary(component, bean));
  }

  encodeAllChildren(context, component);

  rw.endElement("table");
}
 
Example 36
Project: ol3jsf   File: WMSLayer.java   Source Code and License 5 votes vote down vote up
@Override
public void encodeAll(FacesContext context) throws IOException {
	ResponseWriter writer = context.getResponseWriter();
	UIComponent parent = this;

	while (!(parent instanceof Map)) {
		parent = parent.getParent();
	}

	Map mapComponent = (Map) parent;
	String mapVar = mapComponent.getJsVariable();

	String url = getUrl();
	String layer = getLayer();
	String name = getName();

	String newLayer = "var newLayer = new ol.layer.Image({"
			+ "		     title: '" + name + "', "
			+ "		     source: new ol.source.ImageWMS({url: '" + url + "',  "
			+ "            params: {'LAYERS': '" + layer
			+ "                  ', 'VERSION': '1.1.1'}," 
			+ "            serverType: 'geoserver' "
		    + "          }) "
			+ "        });\n";

	writer.write(newLayer + mapVar + ".addLayer(newLayer);\n");
}
 
Example 37
Project: myfaces-trinidad   File: SimpleSelectBooleanRenderer.java   Source Code and License 5 votes vote down vote up
/**
 * Renders the node text
 */
protected void renderText(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean,
  boolean          renderAccessKeys,
  boolean          renderID,
  String           text,
  char             accessKey
  ) throws IOException
{

  if (text != null)
  {
    ResponseWriter writer = context.getResponseWriter();

    writer.startElement("span", component);
    if (renderID)
      renderId( context, component);

    if (renderAccessKeys && supportsAccessKeys(rc))
    {
      // hightlight any access keys with an underline
      AccessKeyUtils.renderAccessKeyText(context, text, accessKey,
                                         SkinSelectors.AF_ACCESSKEY_STYLE_CLASS);
    }
    else
    {
      // output the text directly since we have no access key
      writer.writeText(text, null);
    }

    writer.endElement("span");
  }
}
 
Example 38
Project: myfaces-trinidad   File: BorderLayoutRenderer.java   Source Code and License 5 votes vote down vote up
/**
 * Renders one of the inner nodes.
 */
private void _renderInnerNode(
  UIXRenderingContext context,
  UINode           node,
  UINode           innerNode,
  String           innerNodeName
  ) throws IOException
{
  ResponseWriter writer = context.getResponseWriter();

  writer.startElement("td", null);
  writer.writeAttribute("width", "100%", null);
  renderNamedChild(context, node, innerNode, innerNodeName);
  writer.endElement("td");
}
 
Example 39
Project: myfaces-trinidad   File: IndentingResponseWriter.java   Source Code and License 5 votes vote down vote up
public IndentingResponseWriter(
  ResponseWriter decorated,
  int spacesPerLevel)
{
  super(decorated);
  _spacesPer = spacesPerLevel;
  _isHtml = _HTML_TYPES.contains(decorated.getContentType());
}
 
Example 40
Project: myfaces-trinidad   File: PanelBorderLayoutRenderer.java   Source Code and License 5 votes vote down vote up
private boolean _renderMiddleFacet(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  String           middleFacetName,
  Integer          rowSpan,
  boolean          startTableRow,
  boolean          renderRightFacets
  ) throws IOException
{
  ResponseWriter writer = context.getResponseWriter();
  UIComponent middleFacet = getFacet(component, middleFacetName);
  if (middleFacet != null)
  {
    if (startTableRow)
      writer.startElement("tr", null);

    _renderInnerFacet(context, middleFacet);

    if (renderRightFacets)
      _renderRightFacets(context, rc, component, rowSpan);

    writer.endElement("tr");
    return true;
  }
  return false;
}