예제 #1
0
 protected ToolComponent findParentTool(ComponentWrapper parent) {
   UIComponent parentComponent = parent.getComponent();
   while (!(parentComponent instanceof ToolComponent) && parentComponent != null) {
     parentComponent = parentComponent.getParent();
   }
   return (ToolComponent) parentComponent;
 }
예제 #2
0
  public ComponentWrapper startElement(
      FacesContext context,
      ComponentWrapper parent,
      String uri,
      String localName,
      String qName,
      Attributes attributes)
      throws IOException {
    UIViewRoot root = context.getViewRoot();
    HtmlOutputLink link =
        (HtmlOutputLink) context.getApplication().createComponent(HtmlOutputLink.COMPONENT_TYPE);
    link.setId(root.createUniqueId());
    parent.getComponent().getChildren().add(link);

    link.setTarget("_parent");
    ToolCategoryComponent parentCategoryComponent = findParentCategory(parent);
    ToolComponent parentComponent = findParentTool(parent);

    if (parentComponent.getPage() != null) {
      // Resolve the site_type of the form /portal/category/<siteId>/<categoryKey>/<optionalToolId>
      String url =
          parentCategoryComponent.getContext()
              + "/category/"
              + parentCategoryComponent.getSiteId()
              + "/"
              + parentCategoryComponent.getToolCategory().getKey()
              + "/"
              + parentComponent.getPage().getId();
      link.setValue(url);
    }
    return new ComponentWrapper(parent, link, this);
  }