Package org.apache.myfaces.trinidad.component

Examples of org.apache.myfaces.trinidad.component.UIXShowDetail


    }

    List<UIComponent> children = component.getChildren();
    int numChildren = children.size();
    UIComponent disclosedChild = null;
    UIXShowDetail renderableChild = null;

    for (int indxChild = 0; indxChild < numChildren ; indxChild++ )
    {
      UIComponent child =  children.get(indxChild);
      if (! (child instanceof UIXShowDetail) )
      {
        continue;
      }

      UIXShowDetail detailChild =  (UIXShowDetail) children.get(indxChild);

      if (detailChild.isRendered())
      {
        // Mark the first renderable child
        if (_isItemDisabled(detailChild))
        {
          continue;
        }
        if (renderableChild == null)
        {
          renderableChild = detailChild;
        }
        if (detailChild.isDisclosed())
        {
          disclosedChild = detailChild;
          // A diclosed child found. return.
          break;
        }
      }
    }

    // If we have a minimum of 1 disclosed child and none have been disclosed
    // yet, disclose the first rendered one:
    if ( (disclosedChild == null) && !getDiscloseNone(bean) &&
      (renderableChild != null) && !renderableChild.isDisclosedTransient())
    {
      renderableChild.setDisclosed(true);
    }

    ResponseWriter out = context.getResponseWriter();
    String compId = component.getClientId(context);

    out.startElement("div", component);

    renderId(context, component);
    renderAllAttributes(context, arc, bean);

    boolean discloseMany = getDiscloseMany(bean);
    boolean discloseNone = getDiscloseNone(bean);
    boolean disclosedFixed = false;
    if (discloseMany && !discloseNone) // must keep at least one item disclosed
    {
      // This is a special case where we must determine if we have to fix the
      // disclosure state of one of the items.
      int disclosedCount = 0;
      for (UIComponent child : (List<UIComponent>) component.getChildren())
      {
        if (!(child instanceof UIXShowDetail) ||
            !child.isRendered())
          continue;

        UIXShowDetail detailItem = (UIXShowDetail) child;
        if (detailItem.isDisclosed())
        {
          disclosedCount++;
          if (disclosedCount > 1)
          {
            break; // we have enough information at this point to stop counting
          }
        }
      }
      if (disclosedCount <= 1)
      {
        disclosedFixed = true;
      }
    }

    boolean childAlreadyRendered = false;
    for (UIComponent child : (List<UIComponent>) component.getChildren())
    {
      if (!(child instanceof UIXShowDetail) ||
          !child.isRendered())
        continue;
     
      UIXShowDetail detailItem = (UIXShowDetail) child;
      boolean disabled = _isItemDisabled(detailItem);
      String titleText = (String)
        detailItem.getAttributes().get(CoreShowDetailItem.TEXT_KEY.getName());
      boolean disclosed = detailItem.isDisclosed();

      if (childAlreadyRendered)
      {
        // The detail child should be disclosed only when all three criteria met
        // 1. is marked as disclosed
        // 2. is not disabled and
        // 3. if a child is not already disclosed. This occurs when more than
        //    one showDetail child has it's disclosed property set to true.
        disclosed = false;
      }

      // Header renderer section.
      out.startElement("div", detailItem);

      String detailItemId = detailItem.getClientId(context);
      String itemStyleClass;
      if (disabled)
        itemStyleClass = getHeaderDisabledStyleClass();
      else if (disclosed)
        itemStyleClass = getHeaderExpandedStyleClass();
      else
        itemStyleClass = getHeaderCollapsedStyleClass();
       
      renderStyleClass(context, arc, itemStyleClass);

      // Render the toolbar component, if any (we use float to keep
      // the toolbar on the right - or left, in RTL languages - so
      // it has to be rendered first)
      UIComponent toolbar = getFacet(detailItem,
                                     CoreShowDetailItem.TOOLBAR_FACET);
      if (toolbar != null)
      {
        out.startElement("div", detailItem);
        renderStyleClass(context, arc, SkinSelectors.AF_PANELACCORDION_TOOLBAR_STYLE_CLASS);
        encodeChild(context, toolbar);
        out.endElement("div");
      }

      out.startElement("a", null);
      out.writeAttribute("name", detailItemId, null);

      renderStyleClass(context, arc,
                       disabled
                         ? getLinkDisabledStyleClass()
                         : getLinkEnabledStyleClass());

      // If the child is disclosable and enabled...
      boolean disclosable =
        discloseNone || (! disclosed) || (discloseMany && !disclosedFixed);
      if ( disclosable && (! disabled) )
      {
        boolean isImmediate = detailItem.isImmediate();
        String event = disclosed ? "hide" : "show";
        String onClickHandler = _getFormSubmitScript(component,
                                                     arc,
                                                     event,
                                                     detailItemId,
View Full Code Here


        if (comp == event.getComponent())
          continue;

        if (comp instanceof UIXShowDetail)
        {
          UIXShowDetail showDetail = (UIXShowDetail) comp;
          // Queue an event to hide the currently expanded showDetail
          if (showDetail.isDisclosed())
            (new DisclosureEvent(showDetail, false)).queue();
        }
      }
    }
    super.queueEvent(event);
View Full Code Here

      if (! (child instanceof UIXShowDetail) )
      {
        continue;
        // Can't do any thing with non-showDetail children.
      }
      UIXShowDetail detailItem = (UIXShowDetail) child;

      String childClientId = child.getClientId(context);
      out.startElement("tr", component);
      out.startElement("td", component);

      boolean isRTL = BaseLafUtils.isRightToLeft(rCtx);
      if (isRTL)
      {
        out.writeAttribute("align", "right", null);
      }
      else
      {
        out.writeAttribute("align", "left", null);
      }
      out.writeAttribute("valign", "top", null);
      out.writeAttribute("nowrap", Boolean.TRUE, null);

      out.startElement("span", component);
      out.writeAttribute("id",
                         childClientId + _RADIO_SPAN_SUFFIX_ID_CONST,
                         null);

      Boolean disabledObj =
        (Boolean) detailItem.getAttributes().get(
          UIConstants.DISABLED_ATTR.getAttributeName());
      boolean disabled = false; // by default is enabled.
      if (disabledObj != null)
      {
        disabled = disabledObj.booleanValue();
      }

      if (! disclosedChildId.equals(childClientId) && (! disabled) )
      {
        boolean isImmediate = detailItem.isImmediate();
        String submitJS = _getRadioSubmitJS(component,
                                            rCtx,
                                            formName,
                                            compId,
                                            childClientId,
                                            isImmediate);
        //PH:onclick javascript handler for a HTML SPAN element is not supported
        //on PIE, IE Mobile or Blackberry 4.0. Therefore, create onclick
        //javascript for non-PDAs only.
        if(!CoreRenderer.isPDA(RenderingContext.getCurrentInstance()))
          out.writeAttribute("onclick", submitJS, null);
      }

      // render the radio button now
      out.startElement("input", component);
      out.writeAttribute("id", childClientId, null);
      out.writeAttribute("value", childClientId, null);
      out.writeAttribute("name", compId, null);
       
      //PH: onclick javascript handler for an INPUT element is supported on a
      //PDA. Therefore, create javascript for onclick on an INPUT element
      //instead of a SPAN element.
      if(CoreRenderer.isPDA(RenderingContext.getCurrentInstance()))
      {
         boolean isImmediate = detailItem.isImmediate();
         String submitJS = _getRadioSubmitJS(component,
                                             rCtx,
                                             formName,
                                             compId,
                                             childClientId,
                                             isImmediate);
         out.writeAttribute("onclick", submitJS, null);
      }
     
      if (disabled)
      {
        out.writeAttribute("disabled", Boolean.TRUE, null);
      }

      out.writeAttribute("type", "radio", null);
      if (disclosedChildId.equals(childClientId) )
      {
        out.writeAttribute("checked", Boolean.TRUE, null);
      }
      out.endElement("input");

      out.startElement("label", component);
      out.writeAttribute("for", childClientId, null);

      Character accessChar =
        (Character) detailItem.getAttributes().get("accessKey");
      if (accessChar != null)
      {
        out.writeAttribute("accessKey", accessChar.toString(), null);
      }

      out.startElement("span", component);

      String radioSpanClass = getFieldTextClass();
      if (disabled)
      {
        radioSpanClass = SkinSelectors.AF_FIELD_TEXT_DISABLED_STYLE_CLASS;
      }
      XhtmlLafRenderer.renderStyleClassAttribute(rCtx,
                                                 radioSpanClass);

      writeLabel(out,
                 detailItem,
                 (String) detailItem.getAttributes().get("text"));

      out.endElement("span");
      out.endElement("label");
      out.endElement("span");
      out.endElement("td");
View Full Code Here

        if (comp == event.getComponent())
          continue;

        if (comp instanceof UIXShowDetail)
        {
          UIXShowDetail showDetail = (UIXShowDetail) comp;
          // Queue an event to hide the currently expanded showDetail
          if (showDetail.isDisclosed())
            (new DisclosureEvent(showDetail, false)).queue();
        }
      }
    }
    super.queueEvent(event);
View Full Code Here

      UIComponent   component,
      VisitCallback visitCallback)
    {
      if (component instanceof UIXShowDetail)
      {
        UIXShowDetail showDetail = (UIXShowDetail)component;
        if (_isShowDetailForCurrentComponent(showDetail))
        {
          if (_foundItemToRender || !isChildSelected(showDetail))
          {
            // We already visited the one to be shown
View Full Code Here

    boolean oneIsDisclosed = false;
    for (int i=0; i<childCount; i++)
    {
      if (children.get(i) instanceof UIXShowDetail)
      {
        UIXShowDetail child =  (UIXShowDetail) children.get(i);
        if (child.isDisclosed())
        {
          oneIsDisclosed = true;
          break;
        }
      } else
      {
        _LOG.warning("ONLY_SHOWDETAILITEM_ALLOWED_AS_PANELTABBED_CHILD");
      }
    }

    // OK, nothing's selected: pick the first non-disabled item
    if (!oneIsDisclosed)
    {
      for (int i=0; i<childCount; i++)
      {
        if (children.get(i) instanceof UIXShowDetail)
        {
          UIXShowDetail child =  (UIXShowDetail) children.get(i);
          if (!child.isRendered())
            continue;

          Object disabled = child.getAttributes().get("disabled");
          if (Boolean.TRUE.equals(disabled))
            continue;
         
          if (!child.isDisclosedTransient())
          {
            child.setDisclosed(true);
          }
          break;
        }
      }
    }
View Full Code Here

    while (children.hasNext())
    {
      UIComponent child = children.next();
      if (child instanceof UIXShowDetail)
      {
        UIXShowDetail detailItem = (UIXShowDetail) child;

        Boolean disabledObj =
          (Boolean) detailItem.getAttributes().get("disabled");

        boolean disabled = false; // by default is enabled.
        if (disabledObj != null)
        {
          disabled = disabledObj.booleanValue();
        }

        if (disabled)
        {
          // MSDN DHTML Reference says disabled not supported for option element
          // hence don't render disabled options at all to be consistent
          // across browsers. See Bug 4561967.
          continue;
        }

        String childTitle = (String) detailItem.getAttributes().get("text");
        String childClientId = child.getClientId(context);

        out.startElement("option", component);
        out.writeAttribute("id", childClientId, null);
        if (childClientId.equals(disclosedChildId))
View Full Code Here

      if (! (child instanceof UIXShowDetail) )
      {
        continue;
        // Can't do any thing with non-showDetail children.
      }
      UIXShowDetail detailItem = (UIXShowDetail) child;

      String childClientId = child.getClientId(context);
      out.startElement("tr", component);
      out.startElement("td", component);

      boolean isRTL = BaseLafUtils.isRightToLeft(rCtx);
      if (isRTL)
      {
        out.writeAttribute("align", "right", null);
      }
      else
      {
        out.writeAttribute("align", "left", null);
      }
      out.writeAttribute("valign", "top", null);
      out.writeAttribute("nowrap", Boolean.TRUE, null);

      out.startElement("span", component);
      out.writeAttribute("id",
                         childClientId + _RADIO_SPAN_SUFFIX_ID_CONST,
                         null);

      Boolean disabledObj =
        (Boolean) detailItem.getAttributes().get(
          UIConstants.DISABLED_ATTR.getAttributeName());
      boolean disabled = false; // by default is enabled.
      if (disabledObj != null)
      {
        disabled = disabledObj.booleanValue();
      }

      if (! disclosedChildId.equals(childClientId) && (! disabled) )
      {
        boolean isImmediate = detailItem.isImmediate();
        String submitJS = _getRadioSubmitJS(component,
                                            rCtx,
                                            formName,
                                            compId,
                                            childClientId,
                                            isImmediate);
        //PH:onclick javascript handler for a HTML SPAN element is not supported
        //on PIE, IE Mobile or Blackberry 4.0. Therefore, create onclick
        //javascript for non-PDAs only.
        if(!CoreRenderer.isPDA(RenderingContext.getCurrentInstance()))
          out.writeAttribute("onclick", submitJS, null);
      }

      // render the radio button now
      out.startElement("input", component);
      out.writeAttribute("id", childClientId, null);
      out.writeAttribute("value", childClientId, null);
      out.writeAttribute("name", compId, null);
       
      //PH: onclick javascript handler for an INPUT element is supported on a
      //PDA. Therefore, create javascript for onclick on an INPUT element
      //instead of a SPAN element.
      if(CoreRenderer.isPDA(RenderingContext.getCurrentInstance()))
      {
         boolean isImmediate = detailItem.isImmediate();
         String submitJS = _getRadioSubmitJS(component,
                                             rCtx,
                                             formName,
                                             compId,
                                             childClientId,
                                             isImmediate);
         out.writeAttribute("onclick", submitJS, null);
      }
     
      if (disabled)
      {
        out.writeAttribute("disabled", Boolean.TRUE, null);
      }

      out.writeAttribute("type", "radio", null);
      if (disclosedChildId.equals(childClientId) )
      {
        out.writeAttribute("checked", Boolean.TRUE, null);
      }
      out.endElement("input");

      out.startElement("label", component);
      out.writeAttribute("for", childClientId, null);

      Character accessChar =
        (Character) detailItem.getAttributes().get("accessKey");
      if (accessChar != null)
      {
        out.writeAttribute("accessKey", accessChar.toString(), null);
      }

      out.startElement("span", component);

      String radioSpanClass = getFieldTextClass();
      if (disabled)
      {
        radioSpanClass = SkinSelectors.AF_FIELD_TEXT_DISABLED_STYLE_CLASS;
      }
      XhtmlLafRenderer.renderStyleClassAttribute(rCtx,
                                                 radioSpanClass);

      writeLabel(out,
                 detailItem,
                 (String) detailItem.getAttributes().get("text"));

      out.endElement("span");
      out.endElement("label");
      out.endElement("span");
      out.endElement("td");
View Full Code Here

  {
    _LOG.entering("ShowOneListRendererBase", "encodeBegin");
    List<UIComponent> children = component.getChildren();
    int numChildren = children.size();
    UIComponent disclosedChild = null;
    UIXShowDetail renderableChild = null;

    for (int indxChild = 0; indxChild < numChildren ; indxChild++ )
    {
      UIComponent child = children.get(indxChild);
      if (! (child instanceof UIXShowDetail) )
      {
        continue;
      }

      UIXShowDetail detailChild = (UIXShowDetail) children.get(indxChild);

      if (detailChild.isRendered())
      {
        // Mark the first renderable child
        Object disabled =
          detailChild.getAttributes().get(
            UIConstants.DISABLED_ATTR.getAttributeName());
        if (Boolean.TRUE.equals(disabled))
        {
          continue;
        }
        if (renderableChild == null)
        {
          renderableChild = detailChild;
        }
        if (detailChild.isDisclosed())
        {
          disclosedChild = detailChild;
        }
      }
    }
View Full Code Here

      }

      // only CoreShowDetailItem children are rendered. Rest are ignored.
      if ( (child instanceof UIXShowDetail))
      {
        UIXShowDetail detailChild = (UIXShowDetail) child;
        if (detailChild.isDisclosed())
        {
          returnId = detailChild.getClientId(context);
          break;
        }
      }
    }
    return returnId;
View Full Code Here

TOP

Related Classes of org.apache.myfaces.trinidad.component.UIXShowDetail

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.