示例#1
0
  public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
    if (logger.isLoggable(Level.FINER)) {
      logger.log(Level.FINER, "Begin encoding children " + component.getId());
    }
    // suppress rendering if "rendered" property on the component is
    // false.
    if (!component.isRendered()) {
      if (logger.isLoggable(Level.FINE)) {
        logger.fine(
            "End encoding component "
                + component.getId()
                + " since "
                + "rendered attribute is set to false ");
      }
      return;
    }

    // Render our children recursively
    Iterator kids = getChildren(component);
    while (kids.hasNext()) {
      encodeRecursive(context, (UIComponent) kids.next());
    }
    if (logger.isLoggable(Level.FINER)) {
      logger.log(Level.FINER, "End encoding children " + component.getId());
    }
  }
示例#2
0
  public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
    if (context == null || component == null) {
      // PENDING - i18n
      throw new NullPointerException("'context' and/or 'component is null");
    }

    // suppress rendering if "rendered" property on the component is
    // false.
    if (!component.isRendered()) {
      if (logger.isLoggable(Level.FINE)) {
        logger.fine(
            "End encoding component "
                + component.getId()
                + " since "
                + "rendered attribute is set to false ");
      }
      return;
    }

    ResponseWriter writer = context.getResponseWriter();
    writer.endElement("groupbox");
    writer.writeText("\n", null);

    if (logger.isLoggable(Level.FINER)) {
      logger.log(Level.FINER, "End encoding component " + component.getId());
    }
  }
  public static UIComponent findPersistent(
      FacesContext context, ServletRequest req, UIComponent parent, String id) throws Exception {
    if (context == null) context = FacesContext.getCurrentInstance();

    BodyContent body = null;

    if (parent == null) {
      UIComponentClassicTagBase parentTag =
          (UIComponentClassicTagBase) req.getAttribute("caucho.jsf.parent");

      parent = parentTag.getComponentInstance();

      body = parentTag.getBodyContent();
    }

    if (parent != null) {
      List<UIComponent> children = parent.getChildren();
      int size = children.size();

      String prevId = null;
      for (int i = 0; i < size; i++) {
        UIComponent child = children.get(i);

        if (id.equals(child.getId())) {
          if (body != null) addVerbatim(parent, prevId, body);

          return child;
        }

        if (child.getId() != null) prevId = child.getId();
      }
    }

    return null;
  }
  public void encodeBegin(FacesContext context, UIComponent component) throws IOException {

    if (!component.isRendered()) {
      return;
    }

    ResponseWriter writer = context.getResponseWriter();
    String jsfId = (String) RendererUtil.getAttribute(context, component, "id");
    String id = jsfId;

    if (component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) {
      id = component.getClientId(context);
    }

    String title = (String) RendererUtil.getAttribute(context, component, "title");
    Object tmpFoldStr = RendererUtil.getAttribute(context, component, "hideByDefault");
    String key = (String) RendererUtil.getAttribute(context, component, "key");

    writer.write("<fieldset>");
    writer.write("<legend>");
    writer.write(
        "<a role='button' data-toggle='collapse' aria-expanded='true' aria-target='"
            + id
            + "' href='#"
            + id
            + "' data-target=\"[id='"
            + id
            + "']\">"
            + title
            + "</a>");
    writer.write("</legend>");

    writer.write("<div class='collapse in' " + " id=\"" + id + "\">");
  }
  public void encodeEnd(FacesContext context, UIComponent component) throws IOException {

    if ((context == null) || (component == null)) {
      throw new NullPointerException(
          Util.getExceptionMessageString(Util.NULL_PARAMETERS_ERROR_MESSAGE_ID));
    }
    if (!component.isRendered()) {
      if (log.isTraceEnabled()) {
        log.trace(
            "No encoding necessary "
                + component.getId()
                + " since "
                + "rendered attribute is set to false ");
      }
      return;
    }
    UIData data = (UIData) component;
    data.setRowIndex(-1);
    ResponseWriter writer = context.getResponseWriter();

    // Render the ending of this table
    writer.endElement("table");
    writer.writeText("\n", null);
    if (log.isTraceEnabled()) {
      log.trace("End encoding component " + component.getId());
    }
  }
  /**
   * Faces render output method .
   *
   * <p>Method Generator: org.sakaiproject.tool.assessment.devtools.RenderMaker
   *
   * @param context <code>FacesContext</code> for the current request
   * @param component <code>UIComponent</code> being rendered
   * @throws IOException if an input/output error occurs
   */
  public void encodeEnd(FacesContext context, UIComponent component) throws IOException {

    if (!component.isRendered()) {
      return;
    }

    ResponseWriter writer = context.getResponseWriter();

    String clientId = null;

    if (component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) {
      clientId = component.getClientId(context);
    }

    if (clientId != null) {
      writer.startElement("span", component);
      writer.writeAttribute("id", clientId, "id");
    }

    Map attrMap = component.getAttributes();

    writer.write("\n");
    writer.write("\n<script language=\"javascript\">");
    writer.write("\n// Timer Bar - Version 1.0");
    writer.write("\n// Based on Script by Brian Gosselin of http://scriptasylum.com");
    writer.write("\n  var loadedcolor='gray' ;            // PROGRESS BAR COLOR");

    writer.write("\n  var unloadedcolor='green';         // COLOR OF UNLOADED AREA");

    writer.write("\n  var bordercolor='navy';            // COLOR OF THE BORDER");
    writer.write(
        "\n  var barheight = " + attrMap.get("height") + "; // HEIGHT OF PROGRESS BAR IN PIXELS");
    writer.write("\n  var barwidth = " + attrMap.get("width") + "; // WIDTH OF THE BAR IN PIXELS");
    writer.write(
        "\n  var waitTime = " + attrMap.get("wait") + "; // NUMBER OF SECONDS FOR PROGRESSBAR");
    writer.write(
        "\n  var loaded = " + attrMap.get("elapsed") + "*10; // TENTHS OF A SECOND ELAPSED");
    writer.write("\n// THE FUNCTION BELOW CONTAINS THE ACTION(S) TAKEN ONCE BAR REACHES 100.");
    writer.write("\n");
    writer.write("\n  var action = function()");
    writer.write("\n {");
    writer.write("\n   " + attrMap.get("expireScript") + ";");
    writer.write("\n  alert(\"" + attrMap.get("expireMessage") + "\");");
    writer.write("\n }");
    writer.write("\n");
    writer.write("\n</script>");
    writer.write(
        "\n<script language=\"javascript\" src=\""
            + "/"
            + RESOURCE_PATH
            + "/"
            + SCRIPT_PATH
            + "\"></script>");
    writer.write("\n");

    if (clientId != null) {
      writer.endElement("span");
    }
  }
  /**
   * Faces render output method .
   *
   * <p>Method Generator: org.sakaiproject.tool.assessment.devtoolsRenderMaker
   *
   * @param context <code>FacesContext</code> for the current request
   * @param component <code>UIComponent</code> being rendered
   * @throws IOException if an input/output error occurs
   */
  public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
    ResourceLoader rb =
        new ResourceLoader("org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages");
    ResponseWriter writer = context.getResponseWriter();
    String contextPath = context.getExternalContext().getRequestContextPath();

    Object value = null;
    if (component instanceof UIInput) {
      value = ((UIInput) component).getSubmittedValue();
    }
    if (value == null && component instanceof ValueHolder) {
      value = ((ValueHolder) component).getValue();
    }
    String valString = "";
    if (value != null) {
      valString = value.toString();
    }

    String size = (String) component.getAttributes().get("size");
    if (size == null) {
      size = "20";
    }

    String jsfId = (String) component.getAttributes().get("id");
    String id = jsfId;

    if (component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) {
      id = component.getClientId(context);
    }

    writer.write("");
    writer.write("<input ");
    writer.write("");
    writer.write("  value=\"" + valString + "\" ");
    writer.write("  type=\"" + TYPE + "\" ");
    writer.write("  size=\"" + size + "\" ");
    writer.write("  name=\"" + id + "\"");
    writer.write("  id=\"" + id + "\" />&#160;");
    writer.write("<img ");
    writer.write("  style=\"" + CURSORSTYLE + "\" ");
    writer.write("  height=\"" + HEIGHT + "\" ");
    writer.write("  width=\"" + WIDTH + "\"");
    writer.write("  src=\"" + contextPath + "/images/sel.gif\" ");
    writer.write("  border=\"0\"");
    writer.write("  alt=\"" + rb.getString("cp_CLICKALT") + "\" ");
    writer.write("  id=\"_colorPickerPop_" + id + "\"");
    writer.write(
        "  onclick=\"javascript:TCP.popup("
            + "document.getElementById('"
            + id
            + "'),'','"
            + contextPath
            + "/jsf/widget/colorpicker/')\" />");
    writer.write("&#160;");
  }
示例#8
0
    /**
     * Handle the add.
     *
     * @param context the Faces context.
     * @param component the UI component to add to the list as an ADD.
     */
    private void handleAdd(FacesContext context, UIComponent component) {
      if (!component.isTransient() && !hasTransientAncestor(component)) {
        if (component.getParent() != null && component.getParent().isInView()) {
          String id = component.getId();

          /*
           * Since adding a component, can mean you are really reparenting
           * it, we need to make sure the OLD clientId is not cached, we do
           * that by setting the id.
           */
          if (id != null) {
            component.setId(id);
          }

          if (component.getParent().getFacets().containsValue(component)) {
            Map facets = component.getParent().getFacets();
            Iterator entries = facets.entrySet().iterator();
            while (entries.hasNext()) {
              Map.Entry entry = (Map.Entry) entries.next();
              if (entry.getValue() == component) {
                incrementDynamicChildCount(component.getParent());
                component.clearInitialState();
                component
                    .getAttributes()
                    .put(DYNAMIC_COMPONENT, component.getParent().getChildren().indexOf(component));
                ComponentStruct struct = new ComponentStruct();
                struct.action = ComponentStruct.ADD;
                struct.facetName = entry.getKey().toString();
                struct.parentClientId = component.getParent().getClientId(context);
                struct.clientId = component.getClientId(context);
                struct.id = component.getId();
                handleAddRemoveWithAutoPrune(component, struct);
              }
            }
          } else {
            incrementDynamicChildCount(component.getParent());
            component.clearInitialState();
            component
                .getAttributes()
                .put(DYNAMIC_COMPONENT, component.getParent().getChildren().indexOf(component));
            ComponentStruct struct = new ComponentStruct();
            struct.action = ComponentStruct.ADD;
            struct.parentClientId = component.getParent().getClientId(context);
            struct.clientId = component.getClientId(context);
            struct.id = component.getId();
            handleAddRemoveWithAutoPrune(component, struct);
          }
        }
      }
    }
示例#9
0
  @Override
  public void decode(FacesContext context, UIComponent component, ClientBehavior behavior) {
    if (null == context || null == component || null == behavior) {
      throw new NullPointerException();
    }

    if (!(behavior instanceof AjaxBehavior)) {
      // TODO: use MessageUtils for this error message?
      throw new IllegalArgumentException(
          "Instance of javax.faces.component.behavior.AjaxBehavior required: " + behavior);
    }

    AjaxBehavior ajaxBehavior = (AjaxBehavior) behavior;

    // First things first - if AjaxBehavior is disabled, we are done.
    if (ajaxBehavior.isDisabled()) {
      return;
    }

    component.queueEvent(createEvent(context, component, ajaxBehavior));

    if (logger.isLoggable(Level.FINE)) {
      logger.fine("This command resulted in form submission " + " AjaxBehaviorEvent queued.");
      logger.log(Level.FINE, "End decoding component {0}", component.getId());
    }
  }
  /**
   * Method that triggers when a section is selected
   *
   * @param event ValueChangeEvent object
   * @throws AbortProcessingException
   */
  public void selectedSection(ValueChangeEvent event) throws AbortProcessingException {
    if ((secObjMap == null) || (secObjMap.size() == 0)) return;

    UIInput sec_Selected = (UIInput) event.getComponent();

    if (((Boolean) sec_Selected.getValue()).booleanValue() == true) count++;
    else count--;
    if (sec_Selected.getParent() != null) {
      UIColumn secColumn = (UIColumn) sec_Selected.getParent();
      List<UIComponent> secChildren = secColumn.getChildren();
      if ((secChildren != null) && (secChildren.size() > 0)) {
        for (Iterator itr = secChildren.listIterator(); itr.hasNext(); ) {
          UIComponent comp = (UIComponent) itr.next();
          if (comp.getId().equals("hacksecid")) {
            UIInput hiddenSec = (UIInput) comp;
            if (selectedSecIds == null) {
              selectedSecIds = new ArrayList();
            }
            selectedSecIds.add((Integer) hiddenSec.getValue());
          }
        }
      }
    }
    if ((selectedSecIds != null) && (selectedSecIds.size() > 0)) {
      sectionSelected = true;
    }
    if ((selectedSecIds != null) && (selectedSecIds.size() == 1)) {
      selectedModId = ((SecModObj) secObjMap.get(selectedSecIds.get(0))).getModuleId();
    }
    return;
  }
 public UIComponent findSharedDataPagerParent() {
   String dataId = getFor();
   if (dataId != null) {
     UIComponent data = findComponent(dataId);
     if (data instanceof FacesDataIterator) {
       UIComponent dataParent = data;
       while (dataParent != null) {
         UIComponent pagerParent = getParent();
         while (pagerParent != null) {
           if (pagerParent == dataParent) {
             // Need to check that the shared parent has a user set Id as components
             // with autogenerated Id's are not guaranteed to generate output
             // that is capable of being partially refreshed.
             while (dataParent != null) {
               if (HtmlUtil.isUserId(dataParent.getId())) {
                 break;
               }
               if (dataParent instanceof UIForm) {
                 // Form always generate an ID, even when it is auto-generated.
                 break;
               }
               dataParent = dataParent.getParent();
             }
             return dataParent;
           }
           pagerParent = pagerParent.getParent();
         }
         dataParent = dataParent.getParent();
       }
     }
   }
   return null;
 }
  /** Will add the specified type - value metadata as a property to the selected resource. */
  public void processAction(ActionEvent actionEvent) throws AbortProcessingException {
    UIComponent comp = actionEvent.getComponent();
    String id = comp.getId();
    UIComponent superParent = comp;
    WebDAVCategories realCategories = null;
    while (superParent.getParent() != null) {
      superParent = superParent.getParent();
      if (superParent instanceof WebDAVCategories) {
        realCategories = (WebDAVCategories) superParent;
      }
    }

    if (realCategories == null) {
      realCategories = (WebDAVCategories) superParent.findComponent(getId());
    }

    if (id.equalsIgnoreCase(getAddButtonId())) {
      //	Add a category to the list of selectable categories
      //	This is input for adding a category
      HtmlInputText newCategoryInput =
          (HtmlInputText) comp.getParent().findComponent(getAddCategoryInputId());

      String newCategoryName = newCategoryInput.getValue().toString();
      CategoryBean.getInstance().addCategory(newCategoryName);
      if (realCategories != null) {
        realCategories.reset();
      }
      return;
    } else if (id.equalsIgnoreCase(getSaveButtonId())) {
      realCategories.saveCategoriesSettings();
    }
  }
示例#13
0
  private void setupElementAndChildren(
      FacesContext context, UIComponent component, String targetId, Set excluded)
      throws IOException {

    if (component != null) {
      List list = component.getChildren();
      if (list != null) {
        for (int i = 0; i < list.size(); i++) {
          Object child = list.get(i);
          if (child instanceof UIComponent) {
            setupElementAndChildren(context, (UIComponent) child, targetId, excluded);
          }
        }
      }

      if (component instanceof UIInput
          && (excluded == null || !excluded.contains(component.getId()))) {

        String secondArgument =
            Utils.hasContent(targetId) ? ", document.getElementById('" + targetId + "')" : ", null";
        component
            .getAttributes()
            .put("onkeypress", "return tabOnEnter(event" + secondArgument + ");");
      }
    }
  }
示例#14
0
  protected boolean shouldWriteId(UIComponent component) {
    String id = component.getId();

    return (null != id)
        && (!id.startsWith(UIViewRoot.UNIQUE_ID_PREFIX)
            || ((component instanceof ClientBehaviorHolder)
                && !((ClientBehaviorHolder) component).getClientBehaviors().isEmpty()));
  }
示例#15
0
  /**
   * @param points This parameter should be the {@link IntegrationPoint}s to include in the order in
   *     which you want to include them if that matters (i.e. use <code>SortedSet</code>).
   */
  public static void includeIntegrationPoints(
      FacesContext ctx, UIComponent root, Set<IntegrationPoint> points) {
    if (points == null) {
      // Do nothing...
      return;
    }
    if (root == null) {
      // No root is specified, search whole page
      root = ctx.getViewRoot();
    }

    // Iterate
    IntegrationPoint point;
    Iterator<IntegrationPoint> it = null;
    int lastSize = 0;
    int currSize = points.size();
    String parentId = null;
    String lastParentId = null;
    while (currSize != lastSize) {
      // Stop loop by comparing previous size
      lastSize = currSize;
      it = points.iterator();
      lastParentId = "";
      UIComponent parent = root;

      // Iterate through the IntegrationPoints
      while (it.hasNext()) {
        point = it.next();

        // Optimize for multiple plugins for the same parent
        parentId = point.getParentId();
        // Resolve any EL that may be used in identifying the parent ID
        parentId = (String) ComponentUtil.getInstance(ctx).resolveValue(ctx, null, root, parentId);
        if ((parentId == null) || !parentId.equals(lastParentId)) {
          // New parent (or root -- null)
          parent = getIntegrationPointParent(ctx, root, point);
        }
        if (parent == null) {
          // Didn't find the one specified!
          // FIXME: log FINE!  Note this may not be a problem, keep iterating to see if we find it
          // later.
          // System.out.println("The specified parentId (" + parentId + ") was not found!");
          lastParentId = null;
          continue;
        }
        lastParentId = parent.getId();

        // Add the content
        includeIntegrationPoint(ctx, parent, point);

        // We found the parent, remove from our list of IPs to add
        it.remove();
      }

      // Get the set size to see if we have any left to process
      currSize = points.size();
    }
  }
示例#16
0
 /**
  * Gets the base naming container from anchor.
  *
  * <p>Gets out of suggestion box as it's a naming container and we can't get components out of it
  * with a relative path => take above first found container.
  *
  * @since 5.3.1
  */
 public static UIComponent getBase(UIComponent anchor) {
   // init base to given component in case there's no naming container for it
   UIComponent base = anchor;
   UIComponent container = anchor.getNamingContainer();
   if (container != null) {
     UIComponent supContainer = container.getNamingContainer();
     if (supContainer != null) {
       container = supContainer;
     }
   }
   if (container != null) {
     base = container;
   }
   if (log.isDebugEnabled()) {
     log.debug(String.format("Resolved base '%s' for anchor '%s'", base.getId(), anchor.getId()));
   }
   return base;
 }
  @Override
  protected Object[] getJsValidatorParametersAsString(FacesContext context, UIComponent component) {
    Object[] args = {component.getId()};
    FacesMessage message =
        MessageUtil.getMessage(
            context, FacesMessage.SEVERITY_ERROR, UIInput.REQUIRED_MESSAGE_ID, args);

    return new String[] {message.getSummary(), message.getDetail()};
  }
 public void testFixedChildren() {
   Iterator iterator = table.fixedChildren();
   assertTrue(iterator.hasNext());
   int i = 0;
   while (iterator.hasNext()) {
     UIComponent kid = (UIComponent) iterator.next();
     assertEquals("h" + i, kid.getId());
     i++;
   }
 }
示例#19
0
  public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
    if (logger.isLoggable(Level.FINER)) {
      logger.log(Level.FINER, "Begin encoding component " + component.getId());
    }
    // suppress rendering if "rendered" property on the component is
    // false.
    if (!component.isRendered()) {
      if (logger.isLoggable(Level.FINE)) {
        logger.fine(
            "End encoding component "
                + component.getId()
                + " since "
                + "rendered attribute is set to false ");
      }
      return;
    }

    String style = (String) component.getAttributes().get("style"),
        styleClass = (String) component.getAttributes().get("styleClass"),
        captionClass = (String) component.getAttributes().get("captionClass"),
        captionLabel = (String) component.getAttributes().get("captionLabel");
    ResponseWriter writer = context.getResponseWriter();

    writer.writeText("\n", null);
    writer.startElement("groupbox", component);
    writeIdAttributeIfNecessary(context, writer, component);
    if (styleClass != null) {
      writer.writeAttribute("class", styleClass, "styleClass");
    }
    if (style != null) {
      writer.writeAttribute("style", style, "style");
    }
    if (captionLabel != null) {
      writer.writeText("\n", null);
      writer.startElement("caption", component);
      writer.writeAttribute("label", captionLabel, "captionLabel");
      if (captionClass != null) {
        writer.writeAttribute("class", captionClass, "captionClass");
      }
      writer.endElement("caption");
    }
    writer.writeText("\n", null);
  }
示例#20
0
  public static UIComponent findComponent(UIComponent base, String id) {
    if (id.equals(base.getId())) return base;

    UIComponent kid = null;
    UIComponent result = null;
    Iterator<UIComponent> kids = base.getFacetsAndChildren();
    while (kids.hasNext() && (result == null)) {
      kid = (UIComponent) kids.next();
      if (id.equals(kid.getId())) {
        result = kid;
        break;
      }
      result = findComponent(kid, id);
      if (result != null) {
        break;
      }
    }
    return result;
  }
  private static void addChild(UIComponent parent, String prevId, UIComponent child) {
    if (parent != null) {
      List<UIComponent> children = parent.getChildren();
      int size = children.size();
      boolean hasPrev = prevId == null;

      int i = 0;
      for (; i < size; i++) {
        UIComponent oldChild = children.get(i);

        if (hasPrev && oldChild.getId() != null) {
          children.add(i, child);

          return;
        } else if (prevId != null && prevId.equals(oldChild.getId())) hasPrev = true;
      }

      parent.getChildren().add(child);
    }
  }
示例#22
0
 /**
  * Handle the remove.
  *
  * @param context the Faces context.
  * @param component the UI component to add to the list as a REMOVE.
  */
 private void handleRemove(FacesContext context, UIComponent component) {
   if (!component.isTransient() && !hasTransientAncestor(component)) {
     if (component.isInView()) {
       decrementDynamicChildCount(component.getParent());
       ComponentStruct struct = new ComponentStruct();
       struct.action = ComponentStruct.REMOVE;
       struct.clientId = component.getClientId(context);
       struct.id = component.getId();
       handleAddRemoveWithAutoPrune(component, struct);
     }
   }
 }
  protected boolean shouldDecode(UIComponent component) {

    if (Util.componentIsDisabledOrReadonly(component)) {
      if (logger.isLoggable(Level.FINE)) {
        logger.log(
            Level.FINE,
            "No decoding necessary since the component {0} is disabled or read-only",
            component.getId());
      }
      return false;
    }
    return true;
  }
示例#24
0
 private UIComponent getComponent(String componentId, UIComponent parent) {
   if (componentId.equals(parent.getId())) {
     return parent;
   }
   Iterator<UIComponent> kids = parent.getFacetsAndChildren();
   while (kids.hasNext()) {
     UIComponent kid = kids.next();
     UIComponent found = getComponent(componentId, kid);
     if (found != null) {
       return found;
     }
   }
   return null;
 }
  protected boolean shouldEncode(UIComponent component) {

    // suppress rendering if "rendered" property on the component is
    // false.
    if (!component.isRendered()) {
      if (logger.isLoggable(Level.FINE)) {
        logger.log(
            Level.FINE,
            "End encoding component {0} since rendered attribute is set to false",
            component.getId());
      }
      return false;
    }
    return true;
  }
  protected boolean shouldEncodeChildren(UIComponent component) {

    // suppress rendering if "rendered" property on the component is
    // false.
    if (!component.isRendered()) {
      if (logger.isLoggable(Level.FINE)) {
        logger.log(
            Level.FINE,
            "Children of component {0} will not be encoded since this component's rendered attribute is false",
            component.getId());
      }
      return false;
    }
    return true;
  }
  /**
   * @param component the component of interest
   * @return true if this renderer should render an id attribute.
   */
  protected boolean shouldWriteIdAttribute(UIComponent component) {

    // By default we only write the id attribute if:
    //
    // - We have a non-auto-generated id, or...
    // - We have client behaviors.
    //
    // We assume that if client behaviors are present, they
    // may need access to the id (AjaxBehavior certainly does).

    String id;
    return (null != (id = component.getId())
        && (!id.startsWith(UIViewRoot.UNIQUE_ID_PREFIX)
            || ((component instanceof ClientBehaviorHolder)
                && !((ClientBehaviorHolder) component).getClientBehaviors().isEmpty())));
  }
 @Override
 public Object getAsObject(FacesContext context, UIComponent component, String value) {
   if (value == null || value.equals("") || value.equals("...")) {
     return new Object();
   }
   try {
     return Integer.valueOf(value);
   } catch (Exception ex) {
     throw new ConverterException(
         "Não foi possível aplicar conversão de item com valor ["
             + value
             + "] no componente ["
             + component.getId()
             + "]",
         ex);
   }
 }
示例#29
0
 /**
  * Add a sub component to a UI component.
  *
  * <p>Since 6.0, does not the set the component as rendered anymore.
  *
  * @param context
  * @param parent
  * @param child
  * @param defaultChildId
  * @return child comp
  */
 public static UIComponent hookSubComponent(
     FacesContext context, UIComponent parent, UIComponent child, String defaultChildId) {
   // build a valid id using the parent id so that it's found everytime.
   String childId = child.getId();
   if (defaultChildId != null) {
     // override with default
     childId = defaultChildId;
   }
   // make sure it's set
   if (childId == null) {
     childId = context.getViewRoot().createUniqueId();
   }
   // reset client id
   child.setId(childId);
   child.setParent(parent);
   return child;
 }
  @SuppressWarnings("rawtypes")
  @Override
  public Object getAsObject(FacesContext context, UIComponent component, String value) {
    if (value == null || value.equals("")) return null;

    try {
      Long id = Long.valueOf(value);
      Collection items = (Collection) component.getAttributes().get("itens");
      return findById(items, id);
    } catch (Exception ex) {
      throw new ConverterException(
          "Não foi possível aplicar conversão de item com valor ["
              + value
              + "] no componente ["
              + component.getId()
              + "]",
          ex);
    }
  }