當前位置: 首頁>>代碼示例>>Java>>正文


Java ResponseWriter.writeURIAttribute方法代碼示例

本文整理匯總了Java中javax.faces.context.ResponseWriter.writeURIAttribute方法的典型用法代碼示例。如果您正苦於以下問題:Java ResponseWriter.writeURIAttribute方法的具體用法?Java ResponseWriter.writeURIAttribute怎麽用?Java ResponseWriter.writeURIAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.faces.context.ResponseWriter的用法示例。


在下文中一共展示了ResponseWriter.writeURIAttribute方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: _renderArrow

import javax.faces.context.ResponseWriter; //導入方法依賴的package包/類
/**
 * @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");
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:30,代碼來源:SelectRangeChoiceBarRenderer.java

示例2: renderControlBarLink

import javax.faces.context.ResponseWriter; //導入方法依賴的package包/類
protected final void renderControlBarLink(FacesContext context, RenderingContext rc, String onclick,
                                          String translationKey, String id, boolean hasDivider)
  throws IOException
{
  ResponseWriter writer = context.getResponseWriter();
  writer.startElement("a", null);
  writer.writeAttribute(XhtmlConstants.ID_ATTRIBUTE, id, null);
  renderStyleClass(context, rc, SkinSelectors.NAV_BAR_ALINK_STYLE_CLASS);
  writer.writeAttribute("onclick", onclick, null);
  writer.writeURIAttribute("href", "#", null);

  Icon icon = rc.getIcon(getControlLinkIconName(translationKey));
  if (icon != null)
  {
    OutputUtils.renderIcon(context, rc, icon, rc.getTranslatedString(translationKey), null);
  }
  else
  {
    writer.writeText(rc.getTranslatedString(translationKey), null);
  }
  writer.endElement("a");

  if (hasDivider)
    writer.writeText(LINKS_DIVIDER_TEXT, null);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:26,代碼來源:DesktopTableRenderer.java

示例3: writeAbsoluteImageURI

import javax.faces.context.ResponseWriter; //導入方法依賴的package包/類
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);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:17,代碼來源:XhtmlLafRenderer.java

示例4: writeCacheImageURI

import javax.faces.context.ResponseWriter; //導入方法依賴的package包/類
protected static void writeCacheImageURI(
  UIXRenderingContext context,
  String           attribute,
  String           uri) throws IOException
{
  if ((uri == null) || (uri.length() == 0))
    return;

  ResponseWriter writer = context.getResponseWriter();
  String cachedImgURI = LafIconProvider.getCacheImageURI(context) + uri;
  FacesContext facesContext = context.getFacesContext();
  if(facesContext != null)
    cachedImgURI = facesContext.getExternalContext().encodeResourceURL(cachedImgURI);
  writer.writeURIAttribute(attribute,
                        cachedImgURI,
            null);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:18,代碼來源:HtmlLafRenderer.java

示例5: _renderLinkStart

import javax.faces.context.ResponseWriter; //導入方法依賴的package包/類
private void _renderLinkStart(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean,
  String           parameterString
  ) throws IOException
{
  ResponseWriter rw = context.getResponseWriter();
  if (!supportsNavigation(rc)) {
    rw.startElement("span", null);
  }
  else if (supportsScripting(rc))
  {
    String onclick = getOnclick(component, bean);
    rw.startElement("a", null);
    onclick = XhtmlUtils.getChainedJS(onclick, parameterString, true);
    rw.writeAttribute("onclick", onclick, null);
    rw.writeURIAttribute("href", "#", null);
  }
  // For Non-JavaScript browsers, render an input element(type=submit) to
  // submit the page. Encode the name attribute with the parameter name
  // and value thus it would enable the browsers to include the name of
  // this element in its payLoad if it submits the page.
  else
  {
    rw.startElement("input", null);
    rw.writeAttribute("type", "submit", null);
    rw.writeURIAttribute("name", parameterString, null);
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:32,代碼來源:ShowDetailRenderer.java

示例6: renderControlBarLink

import javax.faces.context.ResponseWriter; //導入方法依賴的package包/類
protected void renderControlBarLink(
  FacesContext     context,
  RenderingContext rc,
  String           onclick,
  String           translationKey,
  Icon             icon,
  String           id,
  boolean          hasDivider
  ) throws IOException
{
  ResponseWriter writer = context.getResponseWriter();
  writer.startElement("a", null);
  writer.writeAttribute(XhtmlConstants.ID_ATTRIBUTE, id, null);
  renderStyleClass(context, rc, SkinSelectors.NAV_BAR_ALINK_STYLE_CLASS);
  writer.writeAttribute("onclick", onclick, null);
  writer.writeURIAttribute("href", "#", null);
  if (icon != null)
  {
    OutputUtils.renderIcon(context, rc, icon, rc.getTranslatedString(translationKey),
                           null);
  } else
  {
    writer.writeText(rc.getTranslatedString(translationKey), null);
  }

  writer.endElement("a");

  if (hasDivider)
    writer.writeText(LINKS_DIVIDER_TEXT, null);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:31,代碼來源:TreeTableRenderer.java

示例7: _renderColorSwatch

import javax.faces.context.ResponseWriter; //導入方法依賴的package包/類
private void _renderColorSwatch(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean,
  boolean          editable
  ) throws IOException
{
  ResponseWriter writer = context.getResponseWriter();
  if (editable)
  {
    writer.startElement("a", component);
    writer.writeAttribute("onclick",
                          getLaunchOnclick(context, rc, component, bean),
                          null);
    writer.writeURIAttribute("href", "#", null);
  }

  writer.startElement("img", component);

  String id = _getColorSwatchId(rc);

  // Render the ID directly on the swatch image.
  writer.writeAttribute("id", id, null);

  // Render other image attrs
  writer.writeAttribute("align",
                        isScreenReaderMode(rc) ? "middle" : "absmiddle",
                        null);
  writer.writeAttribute("width", _CELL_SIZE, null);
  writer.writeAttribute("height", _CELL_SIZE, null);

  Color color = _getColorValue(component, bean);

  // Render the style attributes
  String inlineStyle = _getInlineStyleForColor(color);
  renderStyleClass(context, rc, SkinSelectors.COLOR_FIELD_SWATCH_STYLE_CLASS);
  writer.writeAttribute("style", inlineStyle, null);

  Object altText = null;

  if (color != null && color.getAlpha() == 0)
  {
    Icon icon = rc.getIcon(XhtmlConstants.COLOR_PALETTE_TRANSPARENT_ICON_NAME);
    if (icon != null)
    {
      // FIXME: this should happen with just rendering the Icon, *not*
      // by extracting the URI
      renderEncodedResourceURI(context, "src", icon.getImageURI(context, rc));
    }

    String key = editable ?
                  "af_inputColor.LAUNCH_PICKER_TIP" :
                  "af_chooseColor.TRANSPARENT";
    altText = rc.getTranslatedString(key);
  }
  else
  {
    String transparentURI = getBaseImageUri(context, rc) + TRANSPARENT_GIF;
    renderEncodedResourceURI(context, "src", transparentURI);

    if (editable)
      altText = rc.getTranslatedString("af_inputColor.LAUNCH_PICKER_TIP");
    else
      altText = "";
  }

  OutputUtils.renderAltAndTooltipForImage(context, rc, altText);

  writer.endElement("img");

  if (editable)
  {
    Icon overlay = rc.getIcon(SkinSelectors.AF_SELECT_INPUT_COLOR_SWATCH_OVERLAY_ICON_NAME);
    if (overlay != null)
      OutputUtils.renderIcon(context, rc, overlay, "", "middle");
    writer.endElement("a");
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:80,代碼來源:SimpleInputColorRenderer.java

示例8: _renderLink

import javax.faces.context.ResponseWriter; //導入方法依賴的package包/類
private void _renderLink(
   FacesContext     context,
   RenderingContext rc,
   boolean          isNext,
   String           onclick,
   int              records,
   String           id,
   String           source,
   long             value
   ) throws IOException
 {

   String text = getBlockString(rc, isNext, records);
   boolean isEnabled = ((onclick != null) && (records > 0));
   ResponseWriter writer = context.getResponseWriter();

   // if we have more than one record and browser is js capable then
   // render as a link
   if (isEnabled)
   {
     writer.startElement("a", null);
     writer.writeURIAttribute("href", "#", null);
     writer.writeAttribute("onclick", onclick, null);

     // The navBar needs its initial focus to be on the Next button,
     // according to the BLAF. Render a special id on the Next button
     // if this navBar is to have the initial focus. (unless it needs
     // initial focus, the Next button does not have an id on it)
     if (isNext)
     {
       String linkID = _getIDForFocus(rc, id);
       writer.writeAttribute("id", linkID, null);
     }

     renderStyleClass(context, rc, SkinSelectors.NAV_BAR_ALINK_STYLE_CLASS);
     writer.writeText(text, null);
     writer.endElement("a");
   }
   // if we don't have any record then just render as <span> element
   else if (records < 1)
   {
     writer.startElement("span", null);
     renderStyleClass(context, rc, SkinSelectors.NAV_BAR_ILINK_STYLE_CLASS);
     writer.writeText(text, null);
     writer.endElement("span");
   }

   // For Non-JavaScript browsers, render a submit element
   // (<input type = "submit"/> ). Encode the the name attribute with the
   // parameter name and value thus it would enable the browsers to
   // include the name of this element in its payLoad if it submits the

   else
   {
     String nameAttri = XhtmlUtils.getEncodedParameter
                                      (XhtmlConstants.SOURCE_PARAM)
                        + XhtmlUtils.getEncodedParameter(source)
                        + XhtmlUtils.getEncodedParameter
                                      (XhtmlConstants.EVENT_PARAM)
                        + XhtmlUtils.getEncodedParameter
                                      (XhtmlConstants.GOTO_EVENT)
                        + XhtmlUtils.getEncodedParameter
                                      (XhtmlConstants.VALUE_PARAM)
                        + IntegerUtils.getString(value);

     writer.startElement("input", null);
     writer.writeAttribute("type", "submit", null);
     writer.writeAttribute("name", nameAttri, null);
     writer.writeAttribute("value", text, "text");
     renderStyleClass(context, rc,
                 SkinSelectors.AF_COMMAND_BUTTON_STYLE_CLASS);

     // This style makes a button to appear as a link
     writer.writeAttribute("style",
       "border:none;background:inherit;text-decoration:underline;",null);
     writer.endElement("input");
   }

}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:80,代碼來源:SelectRangeChoiceBarRenderer.java

示例9: renderIcon

import javax.faces.context.ResponseWriter; //導入方法依賴的package包/類
protected void renderIcon(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean
  ) throws IOException
{
  String iconUri = getIcon(component, bean);
  Icon icon;

  if (iconUri == null)
  {
    icon = rc.getIcon(getButtonIconName());
    if ((icon == null) || icon.isNull())
      return;
  }
  else
  {
    icon = null;
  }

  String onclick = getLaunchOnclick(context,
                                    rc,
                                    component,
                                    bean);


  String buttonOnclick = getButtonOnclick(component, bean);
  if (buttonOnclick != null)
  {
    onclick = XhtmlUtils.getChainedJS(buttonOnclick, onclick, true);
  }

  ResponseWriter rw = context.getResponseWriter();
  rw.startElement("a", component);
  rw.writeURIAttribute("href", "#", null);
  rw.writeAttribute("onclick", onclick, null);

  String align = OutputUtils.getMiddleIconAlignment(rc);
  String title = getSearchDesc(component, bean);
  if (iconUri != null)
  {
    rw.startElement("img", null);
    rw.writeAttribute("border", "0", null);
    renderEncodedResourceURI(context, "src", iconUri);
    OutputUtils.renderAltAndTooltipForImage(context, rc, title);
    rw.writeAttribute("align", align, null);
    rw.endElement("img");
  }
  else
  {
    OutputUtils.renderIcon(context, rc, icon,
                           title, align);
  }

  rw.endElement("a");

}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:59,代碼來源:SimpleInputListOfValuesRenderer.java

示例10: _renderSpinboxIcon

import javax.faces.context.ResponseWriter; //導入方法依賴的package包/類
/**
 * render one of the spinbox icons: either the increment or decrement icon.
 * The <img> renders within <a> tags with onmousedown and onmouseup event
 * handlers which will call javascript to increment/decrement the input
 * value. If disabled, then do not render the <a> tags.
 */
private void _renderSpinboxIcon(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean,
  ResponseWriter   rw,
  boolean          increment
  ) throws IOException
{
  boolean disabled = getDisabled(component, bean);

  String styleClass =
    (increment) ?
      SkinSelectors.AF_INPUT_NUMBER_SPINBOX_INCREMENT_CELL :
      SkinSelectors.AF_INPUT_NUMBER_SPINBOX_DECREMENT_CELL;
  renderStyleClass(context, rc, styleClass);

  String iconName;

  if (!disabled)
  {
    iconName =
      (increment) ?
      SkinSelectors.AF_INPUT_NUMBER_SPINBOX_INCREMENT_ICON_NAME :
      SkinSelectors.AF_INPUT_NUMBER_SPINBOX_DECREMENT_ICON_NAME;
  }
  else
  {
    iconName =
      (increment) ?
      SkinSelectors.AF_INPUT_NUMBER_SPINBOX_INCREMENT_DISABLED_ICON_NAME :
      SkinSelectors.AF_INPUT_NUMBER_SPINBOX_DECREMENT_DISABLED_ICON_NAME;
  }

  Icon icon = rc.getIcon(iconName);
  if ((icon != null) && !icon.isNull())
  {
    // Render Link with onmousedown and onmouseup event handlers
    if (!disabled)
    {
      rw.startElement("a", component);
      rw.writeURIAttribute("href", "#", null);
      // this will keep the href from being executed.
      rw.writeAttribute("onclick", "return false;", null);

      String mouseDownScript =
         _getSpinboxScript(context, component, bean, increment);

      rw.writeAttribute("onmousedown", mouseDownScript, null);
      rw.writeAttribute("onmouseup",  _CLEAR_SPINBOX_JS, null);
      rw.writeAttribute("onmouseout",  _CLEAR_SPINBOX_JS, null);

    }

    // TODO resource bundle
    String altText;
    if (!disabled)
      altText = (increment) ? "increment" : "decrement";
    else
      altText = (increment) ? "increment disabled" : "decrement disabled";
    OutputUtils.renderIcon(context, rc, icon, altText, null);

    if (!disabled)
      rw.endElement("a");
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:73,代碼來源:SimpleInputNumberSpinboxRenderer.java

示例11: renderSelectDayAttributes

import javax.faces.context.ResponseWriter; //導入方法依賴的package包/類
protected void renderSelectDayAttributes(
  RenderingContext rc,
  FacesContext     context,
  String[]         keysAndValues,
  String           id,
  long             currTime,
  int              baseTZOffsetMinutes,
  boolean          isInline,
  boolean          isDesktop,
  String           destString
  ) throws IOException
{
  ResponseWriter writer = context.getResponseWriter();

  if (isDesktop)
  {
    TimeZone tz = rc.getLocaleContext().getTimeZone();
    int tzOffsetMinutes = tz.getOffset(currTime)/(1000*60);

    StringBuilder clickRef = new StringBuilder(30);
    writer.writeURIAttribute("href", "#", null);

    if (isInline)
    {
      clickRef.append("return _calsd(");

      // First argument is the ID of the calendar
      if (id == null)
        clickRef.append("null");
      else
      {
        clickRef.append("'");
        clickRef.append(id);
        clickRef.append("'");
      }

      clickRef.append(',');
    }
    else
    {
      clickRef.append("return _selectDate(");
    }

    clickRef.append(currTime);
    if (tzOffsetMinutes != baseTZOffsetMinutes)
      clickRef.append (", " + tzOffsetMinutes);
    clickRef.append(')');
    writer.writeAttribute("onclick", clickRef, null);
  }
  else
  {
    keysAndValues[1] = IntegerUtils.getString( currTime);
    assert(destString != null);
    String url = EncoderUtils.appendURLArguments(destString,
                                                 keysAndValues);
    renderEncodedActionURI(context, "href", url);
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:59,代碼來源:ChooseDateRenderer.java

示例12: renderImage

import javax.faces.context.ResponseWriter; //導入方法依賴的package包/類
static public void renderImage(
  FacesContext     context,
  RenderingContext arc,
  Object           absoluteUri,
  Object           width,
  Object           height,
  Object           id,
  Object           altText,
  UIComponent      comp,
  String           inlineStyle,
  String           styleClass
  ) throws IOException
{
  if (absoluteUri == null)
    return;

  ResponseWriter writer = context.getResponseWriter();

  writer.startElement("img", comp);
  writer.writeAttribute("id", id, null);
  // Run through the ExternalContext resource URL encoder
  absoluteUri = context.getExternalContext().encodeResourceURL(
    absoluteUri.toString());
  writer.writeURIAttribute("src", absoluteUri, null);

  renderAltAndTooltipForImage(context, arc, altText);

  if (width != null)
  {
    writer.writeAttribute("width", width, null);
  }

  if (height != null)
  {
    writer.writeAttribute("height", height, null);
  }

  if (inlineStyle != null)
  {
    writer.writeAttribute("style", inlineStyle, null);
  }
  
  if (styleClass != null)
  {
    CoreRenderer.renderStyleClass(context, arc, styleClass);
  }

  writer.endElement("img");
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:50,代碼來源:OutputUtils.java

示例13: writeLibImport

import javax.faces.context.ResponseWriter; //導入方法依賴的package包/類
/**
   * Write out a script element importing a library.
   * The given URL will only be written once to the page.
   */
  public static void writeLibImport(
    FacesContext     context,
    RenderingContext rc,
    Object           libURL) throws IOException
  {
    // check if it's already been written
    Map<Object, Object> props = rc.getProperties();
    if (props.containsKey(libURL)) { return; }

    // put the lib name in the property map so it won't be written out again
    props.put(libURL, Boolean.TRUE);

    ResponseWriter writer = context.getResponseWriter();

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

    // For portlets, we want to make sure that we only import
    // each script once.  Employ document.write() to achieve this
    // effect.  (Note that on Netscape 4.x this caused major
    // problems when resizing windows - but we're done with Netscape 4)
    libURL = context.getExternalContext().encodeResourceURL(libURL.toString());

//    if (XhtmlConstants.FACET_PORTLET.equals(rc.getOutputMode()))
//    {
//      if (rc.getProperties().get(_PORTLET_LIB_TABLE_KEY) == null)
//      {
//        rc.getProperties().put(_PORTLET_LIB_TABLE_KEY, Boolean.TRUE);
//        writer.writeText("var _uixJSL;" +
//                         "if(!_uixJSL)_uixJSL={};" +
//                         "function _addJSL(u)" +
//                         "{" +
//                           "if(!_uixJSL[u])" +
//                           "{" +
//                             "_uixJSL[u]=1;" +
//                             "document.write(\"<scrip\"+" +
//                                            "\"t src=\\\"\"+u+" +
//                                            "\"\\\"></scrip\"+" +
//                                            "\"t>\")" +
//                           "}" +
//                         "}",
//             null);
//      }
//      writer.writeText("_addJSL(\"", null);
//      writer.writeText(libURL, null);
//      writer.writeText("\")", null);
//    }
//    else
//    {
      // The "safe" case: just write out the source
      writer.writeURIAttribute("src", libURL, null);
//    }

    writer.endElement("script");
  }
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:63,代碼來源:XhtmlUtils.java

示例14: renderLink

import javax.faces.context.ResponseWriter; //導入方法依賴的package包/類
@Override
protected void renderLink(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      child,
  int              renderedCount,
  boolean          isLastChild
  ) throws IOException
{
  TreeTableRenderingContext ttrc = TreeTableRenderingContext.getInstance();
  UIXTreeTable tree = ttrc.getUIXTreeTable();
  ResponseWriter out = context.getResponseWriter();
  out.startElement("a", tree);
  out.writeURIAttribute("href", "#" , null);
  // put style classes on the links
  if (isLastChild)
  {
    renderStyleClass(
      context, rc,
      SkinSelectors.AF_TREE_TABLE_MP_SELECTED_STYLE_CLASS);
  }
  else
  {
    renderStyleClass(
      context, rc,
      SkinSelectors.AF_TREE_TABLE_MP_STEP_STYLE_CLASS);
  }
  Object oldPath = tree.getRowKey();
  Object focusRowKey = ttrc.getFocusRowKey();
  List<Object> focusPath = tree.getAllAncestorContainerRowKeys(focusRowKey);
  Object crumbPath = (renderedCount < focusPath.size())
    ? focusPath.get(renderedCount)
    : focusRowKey;
  try
  {
    tree.setRowKey(crumbPath);
    String onclick =
      TreeUtils.callJSFocusNode(tree, ttrc.getJSVarName());
    out.writeAttribute("onclick", onclick , null);
    super.renderLink(context, rc, child, renderedCount, isLastChild);
  }
  finally
  {
    tree.setRowKey(oldPath);
  }
  out.endElement("a");
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:48,代碼來源:TreeTableRenderer.java


注:本文中的javax.faces.context.ResponseWriter.writeURIAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。