コード例 #1
0
  /**
   * Return a <code>MarinerURL</code> (or null) for any non-cacheable urls.
   *
   * @param requestContext the mariner request context
   * @param assetGroup the assetgroup
   * @param asset the asset
   * @return a mariner url or null if none can be computed.
   * @throws RepositoryException if a repository exception occurs.
   */
  protected MarinerURL computeNoncacheableURL(
      MarinerRequestContext requestContext, AssetGroup assetGroup, Asset asset)
      throws RepositoryException {

    // If the asset is a DynamicVisualAsset and the encoding is TV then the
    // asset url consists of the device specific tv channel prefix and the
    // value appended if it is set. If the tv channel prefix is not valid in
    // a url then we have problems.
    if (asset.getClass() == DynamicVisualAsset.class) {
      DynamicVisualAsset dynamicVisualAsset = (DynamicVisualAsset) asset;
      if (dynamicVisualAsset.getEncoding() == DynamicVisualAsset.TV) {
        MarinerPageContext marinerPageContext =
            ContextInternals.getMarinerPageContext(requestContext);
        InternalDevice device = marinerPageContext.getDevice();

        String tvChannelPrefix = device.getTVChannelPrefix();
        String url = tvChannelPrefix;
        String value = dynamicVisualAsset.getValue();
        if (value != null) {
          url += value;
        }
        return new MarinerURL(url);
      }
    }
    return null;
  }
コード例 #2
0
  // javadoc inherited
  protected void writeMenuItem(DOMOutputBuffer outputBuffer, MenuItem menuItem)
      throws ProtocolException {

    InternalDevice device = pageContext.getDevice();
    boolean isAccesskeyPrefixKeyNeeded =
        !device.getBooleanPolicyValue(
            DevicePolicyConstants.SUPPORTS_WML_ACCESSKEY_AUTOMAGIC_NUMBER_DISPLAY);

    // Extract the href from the menu item.
    LinkAssetReference reference = menuItem.getHref();
    String href = reference.getURL();

    // Extract the text from the menu item.
    String text = menuItem.getText();

    // Add the dummy access key prefix to the text if necessary.
    if (isAccesskeyPrefixKeyNeeded) {
      text = AccesskeyConstants.DUMMY_ACCESSKEY_VALUE_STRING + " " + text;
    }

    // Report what we are about to do for debugging.
    if (logger.isDebugEnabled()) {
      logger.debug("writing numeric shortcut menu item with href=" + href + ", text=" + text);
    }

    // Open the annotation element.
    // @todo 2005060816 annotate child with style information if it's not inherited from the parent
    Element annotator =
        outputBuffer.openStyledElement(AccesskeyConstants.ACCESSKEY_ANNOTATION_ELEMENT, menuItem);

    // Open the anchor element.
    Element anchor = outputBuffer.openElement("a");

    // Copy attributes into the anchor element.
    menuRendererContext.writeTitleAttribute(anchor, menuItem);
    anchor.setAttribute("href", href);
    // Add the dummy accesskey attribute as well.
    anchor.setAttribute("accesskey", AccesskeyConstants.DUMMY_ACCESSKEY_VALUE_STRING);

    // Write out the menu text as the content of the link.
    outputBuffer.appendEncoded(text);

    // Close the anchor element.
    outputBuffer.closeElement(anchor);

    // Close the annotation element.
    outputBuffer.closeElement(annotator);

    // Add BR to force hardcoded vertical alignment.
    // This is compatible with actual Openwave numeric shortcut rendering
    // which is always vertical.
    // NOTE: This means that the mariner-menu-orientation style is ignored.
    outputBuffer.addStyledElement("br", menuItem);
  }