Package org.apache.myfaces.trinidad.component

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


    UIXRenderingContext context,
    UINode           node
    ) throws IOException
  {
    boolean initialLinkSelectedStatus = LinkUtils.isSelected(context);
    UIXHierarchy component = getHierarchyBase(context, node);
    if (component != null)
    {
      UINode stamp = getStamp(context, node);
      if(stamp != null)
      {
        // Save the current key
        Object oldPath = component.getRowKey();
        boolean isNewPath = setNewPath(context, node, component);

        if (isNewPath)
        {
          int size = component.getRowCount();
          int rowIndex = component.getRowIndex();
          boolean needsSeparator = false;

          for (int i = 0; i < size; i++)
          {

            component.setRowIndex(i);
            boolean rendered = isRendered(context, stamp);

            if (rendered)
            {

              if (needsSeparator)
                renderBetweenNodes(context, node);
              else
                needsSeparator = true;

              renderStamp(context, stamp, i==rowIndex);
            }

          }

          if (getVisibleIndexedChildCount(context, node) > 0)
            renderBetweenNodes(context, node);

          // Restore the old path
          component.setRowKey(oldPath);
        }
      }
    }

    super.renderContent(context, node);
View Full Code Here


  {
    final String name =
      (String) node.getAttributeValue(context, UIConstants.ID_ATTR);
    assert name != null;
   
    UIXHierarchy tree = getTree(context, node);
    Object oldPath = tree.getRowKey();
    try
    {
      boolean continueRendering = setInitialPath(context, node, tree);
      if (!continueRendering)
        return;
 
      _renderContent(context, node, tree, name);
    }
    finally
    {
      tree.setRowKey(oldPath);
    }
  }
View Full Code Here

    BoundValue isExpandable = new BoundValue()
    {
      public Object getValue(UIXRenderingContext rc)
      {
        UINode uinode = rc.getAncestorNode(1);
        UIXHierarchy tree = (UIXHierarchy) ((UIComponentUINode) uinode).getUIComponent();
        return tree.isContainer()
          ? Boolean.TRUE
          : Boolean.FALSE;
      }
    };
View Full Code Here

  protected UIXHierarchy getTree(
    UIXRenderingContext context,
    UINode           node)
  {
    UINode pageNode = context.getParentContext().getAncestorNode(0);
    UIXHierarchy component = (UIXHierarchy) pageNode.getUIComponent();    
    return component;   
  }
View Full Code Here

  {
    Object newPath = context.getLocalProperty(0, _NEW_PATH_KEY, null);

    if (newPath != null)
    {
      UIXHierarchy component = getHierarchyBase(context, node);
      Object oldPath = component.getRowKey();
      component.setRowKey(newPath);
      UINode stamp = getStamp(context, node);
      int size = component.getRowCount();

      for (int i = 0; i < size; i++)
      {
        component.setRowIndex(i);
        renderChild(context, stamp);
      }

      component.setRowKey(oldPath);
    }

    super.renderContent(context, node);
  }
View Full Code Here

  protected void prerender(
    UIXRenderingContext context,
    UINode           node
    ) throws IOException
  {
    UIXHierarchy component = getHierarchyBase(context, node);
    UINode stamp = getStamp(context, node);

    if(stamp != null)
    {
      Object oldPath = component.getRowKey();
      boolean isNewPath = setNewPath(context, node, component);
      if (isNewPath)
      {
        Object newPath = component.getRowKey();
        context.setLocalProperty(_NEW_PATH_KEY, newPath);
        component.setRowKey(oldPath);

        // add core.js
        XhtmlLafUtils.addLib(context, "_commandChoice()");
        renderPreChoice(context, node);
        CommandNavigationItemRenderer.setNavigationItemRendererType(context,
View Full Code Here

    UINode           node
    ) throws IOException
  {

    Object newPath = context.getLocalProperty(0, _NEW_PATH_KEY, null);
    UIXHierarchy component = getHierarchyBase(context, node);
    Object oldPath = component.getRowKey()// Save the current key
    component.setRowKey(null);
    String nameString =
              BaseLafUtils.getStringAttributeValue(context, node, NAME_ATTR);
    String idString =
              BaseLafUtils.getStringAttributeValue(context, node, ID_ATTR);

    component.setRowKey(newPath);
    URLEncoder encoder = context.getURLEncoder();

    String eventKey  = encoder.encodeParameter(EVENT_PARAM);
    String sourceKey = encoder.encodeParameter(SOURCE_PARAM);
    String valueKey  = encoder.encodeParameter(VALUE_PARAM);
    String sizeKey   = encoder.encodeParameter(SIZE_PARAM);
    String partialTargetsKey = encoder.encodeParameter(PARTIAL_TARGETS_PARAM);

    // Get any partial targets - encoded in String form
    String partialTargets = _getPartialTargets(context, node);

    int totalItems = component.getRowCount();

    int selectedIndex = component.getRowIndex();

    if (totalItems <= 0)
    {
      component.setRowKey(oldPath);
      return;
    }

    int currentIndex = component.getRowIndex();
    UIComponent stamp = component.getFacet(UIXProcess.NODE_STAMP_FACET);
    int backButtonIndex = ProcessUtils.getBackIndex(component,
                                                    stamp,
                                                    currentIndex);
    int nextButtonIndex = ProcessUtils.getNextIndex(component,
                                                    stamp,
                                                    currentIndex);

    boolean showBackButton = backButtonIndex != ProcessUtils.NO_INDEX;
    boolean showNextButton = nextButtonIndex != ProcessUtils.NO_INDEX;

    // bail if no buttons shown
    if (!showBackButton && !showNextButton)
    {
      component.setRowKey(oldPath);
      return;
    }

    // get form name (#1308799)
    String formName = XhtmlLafUtils.getParentFormName(context);


    // If we don't support navigation (e.g., printable pages),
    // lie and claim we support scripting (even though we probably don't).
    // This will give us the highest fidelity output - that is,
    // we avoid creating submit buttons.
    boolean supportsScripting = (supportsScripting(context) ||
                                 !supportsNavigation(context));
    if (supportsScripting)
    {
      // render hidden fields to hold the form data
      _renderHiddenFields( context,
                          formName,
                          eventKey,
                          sourceKey,
                          valueKey,
                          sizeKey,
                          partialTargetsKey,
                          partialTargets);
    }

    UINode backButton = null;

    // set up the back button
    if (showBackButton)
    {
      BoundValue buttonTextandAccessKeyBV =
                           new SkinTranslatedBoundValue( _SINGLE_BACK_TEXT_KEY);


      Object buttonTextBV = new AccessKeyBoundValue(buttonTextandAccessKeyBV,
                                                    false);

      Object buttonAccessKeyBV = new AccessKeyBoundValue(
                                                    buttonTextandAccessKeyBV,
                                                    true);

      if (supportsScripting)
      {
        component.setRowIndex(backButtonIndex);
        boolean immediate = Boolean.TRUE.equals(
                          stamp.getAttributes().get(UIXCommand.IMMEDIATE_KEY));
        Object destination = stamp.getAttributes().get("destination");
        component.setRowIndex(currentIndex);

        backButton = createSingleItemSubmitButton(
                                true,
                                buttonTextBV,
                                buttonAccessKeyBV,
                                destination,
                                ProcessUtils.getSubmitScriptCall(
                                    context,
                                    formName,
                                    eventKey,
                                    sourceKey,
                                    nameString,
                                    valueKey,
                                    selectedIndex - 1,
                                    sizeKey,
                                    0,
                                    !immediate,
                                    null,
                                    null));
      }
      else
      {
        backButton = ProcessUtils.createSubmitButton(context,
                                                     buttonTextBV,
                                                     buttonAccessKeyBV,
                                                     null,
                                                     formName,
                                                     false,
                                                     eventKey,
                                                     sourceKey,
                                                     nameString,
                                                     valueKey,
                                                     selectedIndex - 1,
                                                     sizeKey,
                                                     0);
      }
    }

    UINode nextButton = null;

     // set up the next button
    if (showNextButton)
    {

      String buttonTextKey = ((totalItems == 2)
                              ? _SINGLE_CONTINUE_TEXT_KEY
                              : _SINGLE_NEXT_TEXT_KEY);

      BoundValue buttonTextandAccessKeyBV =
                           new SkinTranslatedBoundValue(buttonTextKey);


      Object buttonTextBV = new AccessKeyBoundValue( buttonTextandAccessKeyBV,
                                                     false);

      Object buttonAccessKeyBV = new AccessKeyBoundValue(
                                                      buttonTextandAccessKeyBV,
                                                      true);

      // 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)
      String buttonID = _getIDForFocus(context, node);


      // set the destination
      if (supportsScripting)
      {
        component.setRowIndex(nextButtonIndex);
        boolean immediate = Boolean.TRUE.equals(
                          stamp.getAttributes().get(UIXCommand.IMMEDIATE_KEY));
        Object destination = stamp.getAttributes().get("destination");
        component.setRowIndex(currentIndex);

        MutableUINode mutableNextButton =
        createSingleItemSubmitButton(false,
                                     buttonTextBV,
                                     buttonAccessKeyBV,
                                     destination,
                                     ProcessUtils.getSubmitScriptCall(
                                        context,
                                        formName,
                                        eventKey,
                                        sourceKey,
                                        nameString,
                                        valueKey,
                                        selectedIndex + 1,
                                        sizeKey,
                                        1,
                                        !immediate, null, null));
        if (buttonID != null)
        {
          mutableNextButton.setID(buttonID);
        }
        nextButton = mutableNextButton;
      }
      else
      {

        nextButton = ProcessUtils.createSubmitButton(context,
                                                     buttonTextBV,
                                                     buttonAccessKeyBV,
                                                     buttonID,
                                                     formName,
                                                     false,
                                                     eventKey,
                                                     sourceKey,
                                                     nameString,
                                                     valueKey,
                                                     selectedIndex + 1,
                                                     sizeKey,
                                                     1);
      }

      context.setLocalProperty(_NEXT_BUTTON_KEY, nextButton);

    }

    // start the rendering
    ResponseWriter writer = context.getResponseWriter();
    boolean renderAsTable = _renderAsTable(context, node);

    if (renderAsTable)
    {
      writer.startElement("table", NodeUtils.getUIComponent(context, node));
      renderLayoutTableAttributes(context, "0", null);
      String uniqueId = UniqueCompositeId.getId(idString, null);
      writer.writeAttribute("id", uniqueId, null);
      writer.startElement("tr", null);
    }
    // we only want to render the ID in the "td" if renderAsTable is false.
    // render the base ID the first time only, then we render the subIDs.
    _renderStartTableCell(context, node, writer, renderAsTable, true);

    // don't render back button on first step
    if (showBackButton)
    {

      backButton.render(context);
      writer.endElement("td");

      _renderSpacerCell(context);
      // we only want to render the ID in the "td" if renderAsTable is false.
      // render the subID.
      _renderStartTableCell(context, node, writer, renderAsTable, false);

    }

    //
    // create the label and render it
    //
    writer.writeAttribute(NOWRAP_ATTRIBUTE, Boolean.TRUE, null);
    component.setRowKey(oldPath);
  }
View Full Code Here

    UIXRenderingContext context,
    UINode           node
    ) throws IOException
  {

    UIXHierarchy component = getHierarchyBase(context, node);
    UINode stamp = getStamp(context, node);

    if(stamp != null)
    {

      // Save the current key
      Object oldPath = component.getRowKey();
      boolean isNewPath = setNewPath(context, node, component);
      if (isNewPath)
      {

        int size = component.getRowCount();
        int rowIndex = component.getRowIndex();

        for (int i = 0; i < size; i++)
        {
          component.setRowIndex(i);
          boolean isRendered =
              getBooleanAttributeValue(context, stamp, RENDERED_ATTR, true);
             
          if (isRendered)
            renderNode(context, stamp,i == rowIndex);
        }

        // Restore the old path
        component.setRowKey(oldPath);
      }
    }

    super.renderContent(context, node);
  }
View Full Code Here

  {
    Object newPath = context.getLocalProperty(0, _NEW_PATH_KEY, null);

    if (newPath != null)
    {
      UIXHierarchy component = getHierarchyBase(context, node);
      Object oldPath = component.getRowKey();
      component.setRowKey(newPath);
      UINode stamp = getStamp(context, node);
      int size = component.getRowCount();

      for (int i = 0; i < size; i++)
      {
        component.setRowIndex(i);
        renderChild(context, stamp);
      }

      component.setRowKey(oldPath);
    }

    super.renderContent(context, node);
  }
View Full Code Here

  protected void prerender(
    UIXRenderingContext context,
    UINode           node
    ) throws IOException
  {
    UIXHierarchy component = getHierarchyBase(context, node);
    UINode stamp = getStamp(context, node);

    if(stamp != null)
    {
      Object oldPath = component.getRowKey();
      boolean isNewPath = setNewPath(context, node, component);
      if (isNewPath)
      {
        // The postrender will only close out the DOM is newPath is non-null so we should only
        // prerender if newPath is also non-null.
        Object newPath = component.getRowKey();
        if (newPath != null)
        {
          context.setLocalProperty(_NEW_PATH_KEY, newPath);
          component.setRowKey(oldPath);

          // add core.js
          XhtmlLafUtils.addLib(context, "_commandChoice()");
          renderPreChoice(context, node);
          CommandNavigationItemRenderer.setNavigationItemRendererType(context,
View Full Code Here

TOP

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

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.