Java Code Examples for javax.faces.context.ResponseWriter#endElement()

The following examples show how to use javax.faces.context.ResponseWriter#endElement() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DumpObjectRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
private void writeTitle(ResponseWriter w, UIDumpObject o) throws IOException {
    String s = HtmlUtil.toHTMLContentString(o.getTitle(), false, HtmlUtil.useHTML);
    if(StringUtil.isEmpty(s)) {
        s = HtmlUtil.toHTMLContentString(o.getObjectNames(), false, HtmlUtil.useHTML);
    }
    if(StringUtil.isEmpty(s)) {
        s = HtmlUtil.toHTMLContentString("Object Dump", false, HtmlUtil.useHTML); // $NLS-DumpObjectRenderer.ObjectDump-1$
    }
    w.startElement("tr", null); // $NON-NLS-1$
    w.writeAttribute("class", "xspDumpTR", null); // $NON-NLS-1$ $NON-NLS-2$
    
    w.startElement("th", null); // $NON-NLS-1$
    w.writeAttribute("class", "xspDumpTDTitle", null); // $NON-NLS-1$ $NON-NLS-2$
    w.writeAttribute("colspan", "2", null); // $NON-NLS-1$
    w.write(s);
    w.endElement("th"); // $NON-NLS-1$
    
    w.endElement("tr"); // $NON-NLS-1$
    newLine(w);
}
 
Example 2
Source File: HtmlComboBoxRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
@Override
protected void renderNode(FacesContext context, ResponseWriter writer, TreeContextImpl tree) throws IOException {
    // Generate a regular node
    boolean leaf = tree.getNode().getType()==ITreeNode.NODE_LEAF;
    if(leaf) {
        String label = tree.getNode().getLabel();
        String value = tree.getNode().getSubmitValue();
        writer.startElement("option", null); // $NON-NLS-1$
        if(StringUtil.isNotEmpty(value)) {
            writer.writeAttribute("value",value,null); // $NON-NLS-1$
        }
        boolean enabled = tree.getNode().isEnabled();
        if(!enabled) {
            writer.writeAttribute("disabled", "disabled", "disabled"); // $NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
        }
        boolean selected = tree.getNode().isSelected();
        if(selected) {
            writer.writeAttribute("selected", "selected", "selected"); // $NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
        }
        writer.writeText(label,"label"); // $NON-NLS-1$
        writer.endElement("option"); // $NON-NLS-1$
        JSUtil.writeln(writer);
    }
}
 
Example 3
Source File: AbstractApplicationLayoutRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
protected void writeLegal(FacesContext context, ResponseWriter w, UIApplicationLayout c, BasicApplicationConfigurationImpl configuration) throws IOException {
    w.startElement("table",c); // $NON-NLS-1$
    String legalTableClass = (String)getProperty(PROP_LEGALTABLECLASS);
    if( StringUtil.isNotEmpty(legalTableClass) ){
        w.writeAttribute("class",legalTableClass,null); // $NON-NLS-1$
    }
    String legalTableCellSpacing = (String)getProperty(PROP_LEGALTABLECELLSPACING);
    if( StringUtil.isNotEmpty(legalTableCellSpacing) ){
        w.writeAttribute("cellspacing",legalTableCellSpacing,null); // $NON-NLS-1$
    }
    String legalTableRole = (String)getProperty(PROP_LEGALTABLEROLE);
    if( StringUtil.isEmpty(legalTableRole) ){
        legalTableRole = "presentation"; // $NON-NLS-1$
    }
    w.writeAttribute("role",legalTableRole,null); // $NON-NLS-1$
   
    newLine(w);

    w.startElement("tr",c); newLine(w); // $NON-NLS-1$
    writeLegalLogo(context, w, c, configuration);       
    writeLegalText(context, w, c, configuration);       
    w.endElement("tr"); newLine(w); // $NON-NLS-1$
    
    w.endElement("table"); newLine(w); // $NON-NLS-1$
}
 
Example 4
Source File: PagerSizesRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
protected void writerLastPages(FacesContext context, ResponseWriter w, UIPagerSizes pager, FacesDataIterator dataIterator, String[] sizes, int idx) throws IOException {
        String tag = (String)getProperty(PROP_ITEMTAG);
        if(StringUtil.isNotEmpty(tag)) {
            w.startElement(tag, null);
//          String style = (String)getProperty(PROP_LASTSTYLE);
//          if(StringUtil.isNotEmpty(style)) {
//              w.writeAttribute("style", style,null);
//          }
//          String styleClass = (String)getProperty(PROP_LASTCLASS);
//          if(StringUtil.isNotEmpty(styleClass)) {
//              w.writeAttribute("class", styleClass,null);
//          }
        }
        writerItemContent(context, w, pager, dataIterator, sizes, idx);
        if(StringUtil.isNotEmpty(tag)) {
            w.endElement(tag);
        }
    }
 
Example 5
Source File: RendererUtil.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Given a List of SelectItems render the select options
 * 
 * @param out
 * @param items
 *            List of SelectItems
 * @param selected
 *            seelcted choice
 * @param clientId
 *            the id
 * @param styleClass
 *            the optional style class
 * @param component
 *            the component being rendered
 * @throws IOException
 */

public static void renderMenu(ResponseWriter out, List items, int selected, String clientId,
        String styleClass, UIComponent component) throws IOException
{
    // // debug lines
    // out.writeText("startElement select", null);
    // if (true) return;
    out.startElement("select", component);
    out.writeAttribute("name", clientId, "id");
    out.writeAttribute("id", clientId, "id");
    if (styleClass != null)
    {
        out.writeAttribute("class", styleClass, "styleClass");
    }

    Iterator iter = items.iterator();
    while (iter.hasNext())
    {
        SelectItem si = (SelectItem) iter.next();
        Integer value = (Integer) si.getValue();
        String label = si.getLabel();
        out.startElement("option", component);
        out.writeAttribute("value", value, null);
        if (value.intValue() == selected)
        {
            out.writeAttribute("selected", "selected", null);
        }
        out.writeText(label, null);
    }
    out.endElement("select");
}
 
Example 6
Source File: SeparatorRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
protected void writeSeparator(FacesContext context, ResponseWriter w, UISeparator c) throws IOException {
    w.startElement("span", c); // $NON-NLS-1$
    w.writeAttribute("class", "divider", null); // $NON-NLS-1$ $NON-NLS-2$
    w.writeAttribute("style", "margin-left: 3px; margin-right: 3px;", null); // $NON-NLS-1$ $NON-NLS-2$
    //w.writeAttribute("style", "border-color:#CCCCCC; border-left-style:solid; border-left-width:1px; margin: 0 5px 0 5px;", null);
    w.writeAttribute("role", "separator", null); // $NON-NLS-1$ $NON-NLS-2$
    w.write('|');
    w.endElement("span"); // $NON-NLS-1$
}
 
Example 7
Source File: PagerRenderer.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/** Output status display */
private static void writeStatus(ResponseWriter out, String status)
	throws IOException
{
	out.startElement("div", null);
	out.writeAttribute("class", "pager-instruction", null);
	out.writeText(status, null);
	out.endElement("div");		
}
 
Example 8
Source File: HtmlTagsRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
protected void endRenderContainer(FacesContext context, ResponseWriter writer, TreeContextImpl tree) throws IOException {
    String containerTag = getContainerTag();
    if(StringUtil.isNotEmpty(containerTag)) {
        writer.endElement(containerTag);
        JSUtil.writeln(writer);
    }
}
 
Example 9
Source File: ResponsiveAppLayoutRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
protected void writeBannerContent(FacesContext context, ResponseWriter w, UIApplicationLayout c, BasicApplicationConfigurationImpl configuration) throws IOException {
    if (DEBUG) {
        w.writeComment("Start Banner"); // $NON-NLS-1$
        newLine(w);
    }

    boolean hasChildren = c.getChildCount() > 0;
    ITree appLinks      = TreeImpl.get(configuration.getBannerApplicationLinks());
    ITree utilityLinks  = TreeImpl.get(configuration.getBannerUtilityLinks());
    boolean bannerHasContent = hasChildren || appLinks != null || utilityLinks != null;
    
    w.startElement("div", c); // $NON-NLS-1$
    w.writeAttribute("class", "navbar-header", null);       // $NON-NLS-1$ $NON-NLS-2$
    
    if(bannerHasContent) {
        writeBannerLink(context, w, c, configuration);
    }
    newLine(w);
    writeBannerProductlogo(context, w, c, configuration);
    
    w.endElement("div"); // $NON-NLS-1$
    
    w.startElement("div", c); // $NON-NLS-1$
    w.writeAttribute("class",  ExtLibUtil.concatStyleClasses((String)getProperty(PROP_BANNER_COLLAPSE_CLASS), "navbar-collapse collapse"), null); // $NON-NLS-1$ $NON-NLS-2$
    newLine(w);
    
    writeBannerApplicationLinks(context, w, c, configuration);
    newLine(w);
    writeBannerUtilityLinks(context, w, c, configuration);
    newLine(w);
    
    w.endElement("div"); // $NON-NLS-1$
    newLine(w, ""); // $NON-NLS-1$
    
    if (DEBUG) {
        w.writeComment("End Banner"); // $NON-NLS-1$
        newLine(w);
    }
}
 
Example 10
Source File: OneUIv302TitleBarTabsRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
@Override
protected void renderEntryItemContent(FacesContext context, ResponseWriter writer, TreeContextImpl tree, boolean enabled, boolean selected) throws IOException {
       boolean hasLink = false;
       boolean alwaysRenderLinks = alwaysRenderItemLink(tree, enabled, selected);
       writer.startElement("div", null); // $NON-NLS-1$
       writer.writeAttribute("class", "lotusTabWrapper", null); //$NON-NLS-1$ //$NON-NLS-2$
       if(enabled) {
           String href = tree.getNode().getHref();
           if(StringUtil.isNotEmpty(href)) {
               writer.startElement("a",null); //$NON-NLS-1$
               RenderUtil.writeLinkAttribute(context,writer,href);
               hasLink = true;
           } else {
               String onclick = findNodeOnClick(tree);
               if(StringUtil.isNotEmpty(onclick)) {
                   writer.startElement("a",null);
                   writer.writeAttribute("href","javascript:;",null); // $NON-NLS-1$ $NON-NLS-2$
                   writer.writeAttribute("onclick", "javascript:"+onclick, null); // $NON-NLS-1$ $NON-NLS-2$
                   hasLink = true;
               }
           }
       }
       if(!hasLink && alwaysRenderLinks) {
           // Render an empty link...
           writer.startElement("a",null); //$NON-NLS-1$
           hasLink = true;
       }
       if(hasLink) {
           renderEntryItemLinkAttributes(context, writer, tree, enabled, selected);
       }
       writer.startElement("span",null); //$NON-NLS-1$
          writer.writeAttribute("class","lotusTabInner", null); //$NON-NLS-1$ //$NON-NLS-2$

       String image = tree.getNode().getImage();
       boolean hasImage = StringUtil.isNotEmpty(image);
       if(hasImage) {
              writer.startElement("img",null); // $NON-NLS-1$
              writer.writeAttribute("class", "lotusIcon", null); //$NON-NLS-1$ //$NON-NLS-2$
              image = HtmlRendererUtil.getImageURL(context, image);
              writer.writeAttribute("src",image,null); // $NON-NLS-1$
              String imageAlt = tree.getNode().getImageAlt();
              if (StringUtil.isNotEmpty(imageAlt)) {
                  writer.writeAttribute("alt",imageAlt,null); // $NON-NLS-1$
              }else{
                  writer.writeAttribute("alt","",null); // $NON-NLS-1$
              }
              String imageHeight = tree.getNode().getImageHeight();
              if (StringUtil.isNotEmpty(imageHeight)) {
                  writer.writeAttribute("height",imageHeight,null); // $NON-NLS-1$
              }
              String imageWidth = tree.getNode().getImageWidth();
              if (StringUtil.isNotEmpty(imageWidth)) {
                  writer.writeAttribute("width",imageWidth,null); // $NON-NLS-1$
              }
              writer.endElement("img"); // $NON-NLS-1$
          }
       
       // Generate a regular node
       String label = tree.getNode().getLabel();
       if(StringUtil.isNotEmpty(label)) {
       	writer.writeText(label, "label"); // $NON-NLS-1$
       }
       writer.endElement("span"); //$NON-NLS-1$

       if(hasLink || alwaysRenderLinks) {
           writer.endElement("a"); //$NON-NLS-1$
           tree.markCurrentAsAction();
       }
       writer.endElement("div"); // $NON-NLS-1$
   }
 
Example 11
Source File: TreeRenderer.java    From BootsFaces-OSP with Apache License 2.0 4 votes vote down vote up
@Override
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
    if (!component.isRendered()) {
        return;
    }
    Tree tree = (Tree) component;

    String clientId = tree.getClientId();
    String jqClientId = BsfUtils.escapeJQuerySpecialCharsInSelector(clientId);
    ResponseWriter rw = context.getResponseWriter();

    final UIForm form = BsfUtils.getClosestForm(tree);
    if (form == null) {
        throw new FacesException("The tree component must be inside a form", null);
    }
    // String updateItems = BsfUtils.GetOrDefault("'" + tree.getUpdate() + "'", "null");
    String updateItems = tree.getUpdate();
    if (updateItems != null) {
        updateItems = ExpressionResolver.getComponentIDs(context, component, updateItems);
    }

    rw.startElement("script", tree);
    //# Start enclosure
    rw.writeText("$(document).ready(function() {", null);
    // build tree management javascript
    rw.writeText("function getTreeData() { "
            + "   return '" + TreeModelUtils.renderModelAsJson(tree.getValue(), tree.isRenderRoot()) + "'; "
            + "} "
            + // build tree structure
            "$('#tree_" + jqClientId + "').treeview({ "
            + (tree.isShowTags() ? "showTags: true," : "")
            + (tree.isShowIcon() ? "showIcon: true," : "")
            + (tree.isShowCheckbox() ? "showCheckbox: true," : "")
            + (tree.isEnableLinks() ? "enableLinks: true," : "")
            + (tree.isShowBorder() ? "showBorder: true," : "showBorder: false,")
            + (BsfUtils.isStringValued(tree.getCollapseIcon()) ? "collapseIcon: '" + tree.getCollapseIcon() + "'," : "")
            + (BsfUtils.isStringValued(tree.getExpandIcon()) ? "expandIcon: '" + tree.getExpandIcon() + "'," : "")
            + (BsfUtils.isStringValued(tree.getColor()) ? "color: '" + tree.getColor() + "'," : "")
            + (BsfUtils.isStringValued(tree.getHoverColor()) ? "onhoverColor: '" + tree.getHoverColor() + "'," : "")
            + (BsfUtils.isStringValued(tree.getSelectedColor()) ? "selectedColor: '" + tree.getSelectedColor() + "'," : "")
            + (BsfUtils.isStringValued(tree.getBorderColor()) ? "borderColor: '" + tree.getBorderColor() + "'," : "")
            + "   data: getTreeData(),   "
            + // enable nodeSelected event callback
            "	onNodeSelected: function(event, data) { "
            + "   	BsF.ajax.callAjax(this, event, '" + updateItems + "', '" + clientId + "', null, null, null, 'nodeSelected:' + data.nodeInternalId);"
            + "	},"
            + // enable nodeUnselected event callback
            "	onNodeUnselected: function(event, data) { "
            + "   	BsF.ajax.callAjax(this, event, '" + updateItems + "', '" + clientId + "', null, null, null, 'nodeUnselected:' + data.nodeInternalId);"
            + "	},"
            + //enable nodeChecked event callback
            "	onNodeChecked: function(event, data) { "
            + "   	BsF.ajax.callAjax(this, event, '" + updateItems + "', '" + clientId + "', null, null, null, 'nodeChecked:' + data.nodeInternalId);"
            + "	},"
            + //enable nodeUnchecked event callback
            "	onNodeUnchecked: function(event, data) { "
            + "   	BsF.ajax.callAjax(this, event, '" + updateItems + "', '" + clientId + "', null, null, null, 'nodeUnchecked:' + data.nodeInternalId);"
            + "	},"
            + // enable nodeCollapsed event callback
            "	onNodeCollapsed: function(event, data) { "
            + "   	BsF.ajax.callAjax(this, event, '" + updateItems + "', '" + clientId + "', null, null, null, 'nodeCollapsed:' + data.nodeInternalId);"
            + "	},"
            + // enable nodeExpanded event callback
            "	onNodeExpanded: function(event, data) { "
            + "   	BsF.ajax.callAjax(this, event, '" + updateItems + "', '" + clientId + "', null, null, null, 'nodeExpanded:' + data.nodeInternalId);"
            + // @all
            "	}"
            + "}); ", null);
    rw.writeText("});", null);
    rw.endElement("script");
}
 
Example 12
Source File: SortLinksRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
@Override
protected void postRenderList(FacesContext context, ResponseWriter writer, TreeContextImpl tree) throws IOException {
    super.postRenderList(context, writer, tree);
    writer.endElement("div"); // $NON-NLS-1$
}
 
Example 13
Source File: HtmlTagsRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
protected void renderEntryItemContent(FacesContext context, ResponseWriter writer, TreeContextImpl tree, boolean enabled, boolean selected) throws IOException {
    boolean hasLink = false;
    boolean alwaysRenderLinks = alwaysRenderItemLink(tree, enabled, selected);
    if(enabled) {
        String href = tree.getNode().getHref();
        if(StringUtil.isNotEmpty(href)) {
            writer.startElement("a",null);
            String role = getItemRole(tree, enabled, selected);
            if (StringUtil.isNotEmpty(role)) {
                writer.writeAttribute("role", role, null); // $NON-NLS-1$
            }
            RenderUtil.writeLinkAttribute(context,writer,href);
            hasLink = true;
        } else {
            String onclick = findNodeOnClick(tree);
            if(StringUtil.isNotEmpty(onclick)) {
                writer.startElement("a",null);
                writer.writeAttribute("href","javascript:;",null); // $NON-NLS-1$ $NON-NLS-2$
                writer.writeAttribute("onclick", "javascript:"+onclick, null); // $NON-NLS-1$ $NON-NLS-2$
                hasLink = true;
            }
        }
    }
    if(!hasLink && alwaysRenderLinks) {
        // Render an empty link...
        writer.startElement("a",null);
        hasLink = true;
    }
    if(hasLink) {
        renderEntryItemLinkAttributes(context, writer, tree, enabled, selected);
    }

    String image = tree.getNode().getImage();
    boolean hasImage = StringUtil.isNotEmpty(image);
    if(hasImage) {
        writer.startElement("img",null); // $NON-NLS-1$
        image = HtmlRendererUtil.getImageURL(context, image);
        writer.writeAttribute("src",image,null); // $NON-NLS-1$
        String imageAlt = tree.getNode().getImageAlt();
        if (StringUtil.isNotEmpty(imageAlt)) {
            writer.writeAttribute("alt",imageAlt,null); // $NON-NLS-1$
        }
        String imageHeight = tree.getNode().getImageHeight();
        if (StringUtil.isNotEmpty(imageHeight)) {
            writer.writeAttribute("height",imageHeight,null); // $NON-NLS-1$
        }
        String imageWidth = tree.getNode().getImageWidth();
        if (StringUtil.isNotEmpty(imageWidth)) {
            writer.writeAttribute("width",imageWidth,null); // $NON-NLS-1$
        }
        writer.endElement("img"); // $NON-NLS-1$
    }
    
    // Generate a regular node
    renderEntryItemLabel(context, writer, tree, enabled, selected);
    
    // Render a popup image, if any
    writePopupImage(context, writer, tree);

    if(hasLink || alwaysRenderLinks) {
        writer.endElement("a");
        tree.markCurrentAsAction();
    }
}
 
Example 14
Source File: KebabRenderer.java    From BootsFaces-OSP with Apache License 2.0 4 votes vote down vote up
/**
 * This methods generates the HTML code of the current b:kebab.
 * <code>encodeBegin</code> generates the start of the component. After the, the JSF framework calls <code>encodeChildren()</code>
 * to generate the HTML code between the beginning and the end of the component. For instance, in the case of a panel component
 * the content of the panel is generated by <code>encodeChildren()</code>. After that, <code>encodeEnd()</code> is called
 * to generate the rest of the HTML code.
 * @param context the FacesContext.
 * @param component the current b:kebab.
 * @throws IOException thrown if something goes wrong when writing the HTML code.
 */
/*
 * <div class="dropdown dropdown-kebab dropdown-kebab-pf">
       <button class="btn btn-link dropdown-toggle" type="button" id="dropdownKebab" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
         <span class="fa fa-ellipsis-v"></span>
       </button>
       <ul class="dropdown-menu " aria-labelledby="dropdownKebab">
         <li><a href="#">Action</a></li>
         <li><a href="#">Another action</a></li>
         <li><a href="#">Something else here</a></li>
         <li role="separator" class="divider"></li>
         <li><a href="#">Separated link</a></li>
       </ul>
     </div>
 */
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
    if (!component.isRendered()) {
        return;
    }
	Kebab kebab = (Kebab) component;
	ResponseWriter rw = context.getResponseWriter();
	String clientId = kebab.getClientId();

	// Kebabs are a restyled version of a dropdown and support the same feature set.
	// They look like a very tight burger menu.
	
	//<div class="dropdown dropdown-kebab dropdown-kebab-pf">
	rw.startElement("div", kebab);
	rw.writeAttribute("id", kebab.getId(), "id");
    String s="dropdown dropdown-kebab dropdown-kebab-bf dropdown-kebab-pf";
    if(kebab.getStyleClass()!=null){
    	s=s.concat(" ").concat(kebab.getStyleClass());
    }
    rw.writeAttribute("class", s, "class");
	
    if(kebab.getStyle()!=null){
    	rw.writeAttribute("style", kebab.getStyle(), "style");
    }
    
    //Button
    //<button id="dropdownKebab" class="btn btn-link dropdown-toggle" type="button" data-toggle="dropdown" 
    //aria-haspopup="true" aria-expanded="true">
    rw.startElement("button", kebab);
    rw.writeAttribute("id", kebab.getId()+"_btn", "id");
    rw.writeAttribute("class", "btn btn-link dropdown-toggle", "class");
    rw.writeAttribute("type", "button", "type");
    rw.writeAttribute("data-toggle", "dropdown", "data-toggle");
    //ARIA Attributes
    rw.writeAttribute("aria-haspopup", "true", "aria-haspopup");
    rw.writeAttribute("aria-expanded", "true", "aria-expanded");
    
    //<span class="fa fa-ellipsis-v"></span>
    rw.startElement("span", kebab);
    rw.writeAttribute("class", "fa fa-ellipsis-v", "class");
    rw.endElement("span");
    rw.endElement("button");
    
    //<ul class="dropdown-menu " aria-labelledby="dropdownKebab">
    rw.startElement("ul", kebab);
    rw.writeAttribute("class", "dropdown-menu ", "class");
    rw.writeAttribute("aria-labelledby", kebab.getId()+"_btn", "aria-labelledby");
    
	//rw.writeText("Dummy content of b:kebab", null);

}
 
Example 15
Source File: AbstractWebDataViewRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
protected void writeDetail(FacesContext context, ResponseWriter w, AbstractDataView c, ViewDefinition viewDef) throws IOException {
    if(!viewDef.hasDetail) {
        return;
    }

    String id = c.getClientId(context)+ID_DETAIL;
    
    // If the detail should not be displayed, then leave
    boolean detailVisible = viewDef.rowDetailVisible;
    if(!detailVisible && !viewDef.detailsOnClient) {
        return;
    }
    
    String hideStyle = null;
    if(!detailVisible) {
        // We must have then detailsOnClient
        // Just renders it invisible
        hideStyle = "display: none"; // $NON-NLS-1$
    } else {
        // TODO this fade effect doesn't change the tooltips and alt text from Show to Hide
        boolean dojoEffect = (Boolean)getProperty(PROP_SHOWHIDEDOJOEFFECT);
        if(dojoEffect && StringUtil.equals(c.getToggledVisibleDetail(), viewDef.rowPosition)) {
            hideStyle = "opacity: 0"; // $NON-NLS-1$
            UIScriptCollector collector = UIScriptCollector.find();
            String duration = (String)getProperty(PROP_SHOWHIDEDOJODURATION);
            StringBuilder b = new StringBuilder();
            b.append("dojo.fadeIn({node:"); // $NON-NLS-1$
            JavaScriptUtil.addString(b, id);
            b.append(", duration: "); // $NON-NLS-1$
            JavaScriptUtil.addNumber(b, Integer.parseInt(duration));
            b.append("}).play()"); // $NON-NLS-1$
            collector.addScriptOnLoad(b.toString());
        }
    }
    
    UIComponent detail = viewDef.detailFacet;  
    if(detail!=null) {
        String tagName = (String)getProperty(PROP_DETAILTAG);
        w.startElement(tagName,c);
        w.writeAttribute("id",id,null); // $NON-NLS-1$
        String style = (String)getProperty(PROP_DETAILSTYLE);
        String styleClass = (String)getProperty(PROP_DETAILCLASS);
        if(viewDef.collapsibleRows) {
            String collapsibleSize = "20px"; //(Boolean)getProperty(PROP_SHOWHIDEONCLIENT); $NON-NLS-1$
            style = ExtLibUtil.concatStyles(style, "padding-left: "+collapsibleSize); // $NON-NLS-1$
        }
        style = ExtLibUtil.concatStyles(style, hideStyle);
        if(StringUtil.isNotEmpty(style)) {
            w.writeAttribute("style",style,null); // $NON-NLS-1$
        }
        if(StringUtil.isNotEmpty(styleClass)) {
            w.writeAttribute("class",styleClass,null); // $NON-NLS-1$
        }
        FacesUtil.renderComponent(context, detail);
        w.endElement(tagName);
    }
}
 
Example 16
Source File: CalendarViewRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
@Override
public void encodeEnd(FacesContext context, UIComponent uicomponent)
        throws IOException {
    ResponseWriter w = context.getResponseWriter();
    w.endElement("div"); // $NON-NLS-1$
}
 
Example 17
Source File: JQ.java    From BootsFaces-OSP with Apache License 2.0 4 votes vote down vote up
protected static final void endInlineF(ResponseWriter rw) throws IOException {
    rw.write(END_F);
    rw.endElement(SCRIPT);
}
 
Example 18
Source File: TouchSpinRenderer.java    From BootsFaces-OSP with Apache License 2.0 4 votes vote down vote up
@Override
public void encodeEnd(FacesContext context, UIComponent component) 
throws IOException {
	super.encodeEnd(context, component);
	
	TouchSpin spin = (TouchSpin) component;
	
	ResponseWriter rw = context.getResponseWriter();
	String clientId = BsfUtils.escapeJQuerySpecialCharsInSelector(spin.getClientId());
	String fieldId = spin.getFieldId();
	if (null == fieldId) {
		fieldId = "input_" + clientId;
	}
	
	rw.startElement("script", spin);
	//# Start enclosure
	rw.writeText("$(document).ready(function() {", null);
	
	rw.writeText(
			 // build slider structure
			 "$('#" + fieldId + "').TouchSpin({ " +
					 
			 	(BsfUtils.isStringValued(spin.getInitval()) ? "initval: " + spin.getInitval() + ", " : "") +
			 	"min: " + spin.getMin() + ", " +
			 	"max: " + spin.getMax() + ", " +
			 	"step: " + spin.getStep() + ", " +
			 	(BsfUtils.isStringValued(spin.getForceStepDivisibility()) ? "forcestepdivisibility: '" + spin.getForceStepDivisibility() + "', " : "") +
			 	"decimals: " + spin.getDecimals() + ", " +
			 	"stepinterval: " + spin.getStepInterval() + ", " +
			 	"stepintervaldelay: " + spin.getStepIntervalDelay() + ", " +
			 	"verticalbuttons: " + spin.isVerticalButtons() + ", " +
			 	(BsfUtils.isStringValued(spin.getVerticalUpClass()) ? "verticalupclass: '" + spin.getVerticalUpClass() + "', " : "") +
			 	(BsfUtils.isStringValued(spin.getVerticalDownClass()) ? "verticaldownclass: '" + spin.getVerticalDownClass() + "', " : "") +
			 	(BsfUtils.isStringValued(spin.getPrefix()) ? "prefix: '" + spin.getPrefix() + "', " : "") +
			 	(BsfUtils.isStringValued(spin.getPrefixExtraClass()) ? "prefix_extraclass: '" + spin.getPrefixExtraClass() + "', " : "") +
			 	(BsfUtils.isStringValued(spin.getPostfix()) ? "postfix: '" + spin.getPostfix() + "', " : "") +
			 	(BsfUtils.isStringValued(spin.getPostfixExtraClass()) ? "postfix_extraclass: '" + spin.getPostfixExtraClass() + "', " : "") +
			 	"booster: " + spin.isBooster() + ", " +
			 	"boostat: " + spin.getBoostat() + ", " +
			 	"maxboostedstep: " + spin.getMaxBoostedStep() + "," +
			 	(BsfUtils.isStringValued(spin.getButtonDownClass()) ? "buttondown_class: '" + spin.getButtonDownClass() + "', " : "") +
			 	(BsfUtils.isStringValued(spin.getButtonUpClass()) ? "buttonup_class: '" + spin.getButtonUpClass() + "', " : "") +
			 	"mousewheel: " + spin.isMousewheel() + "" +
			 	
			 "}); ", null);	
	
	rw.writeText("});", null);
	//# End enclosure
	rw.endElement("script");
	
	new AJAXRenderer().generateBootsFacesAJAXAndJavaScriptForJQuery(context, component, rw, "#"+clientId, null);
}
 
Example 19
Source File: Datepicker.java    From BootsFaces-OSP with Apache License 2.0 3 votes vote down vote up
/**
 * Generates the default language for the date picker. Originally implemented in
 * the HeadRenderer, this code has been moved here to provide better
 * compatibility to PrimeFaces. If multiple date pickers are on the page, the
 * script is generated redundantly, but this shouldn't do no harm.
 *
 * @param fc
 *            The current FacesContext
 * @throws IOException
 */
private void encodeDefaultLanguageJS(FacesContext fc) throws IOException {
	ResponseWriter rw = fc.getResponseWriter();
	rw.startElement("script", null);
	rw.write("$.datepicker.setDefaults($.datepicker.regional['" + fc.getViewRoot().getLocale().getLanguage()
			+ "']);");
	rw.endElement("script");
}
 
Example 20
Source File: SelectBooleanCheckboxRenderer.java    From BootsFaces-OSP with Apache License 2.0 3 votes vote down vote up
/**
 * Renders the start of the input tag. This method is protected in order to
 * allow third-party frameworks to derive from it.
 *
 * @param rw
 *            the response writer
 * @param selectBooleanCheckbox
 *            the component to render
 * @throws IOException
 *             may be thrown by the response writer
 */
protected void renderInputTagHelper(ResponseWriter rw, FacesContext context,
		SelectBooleanCheckbox selectBooleanCheckbox, String clientId) throws IOException {
	rw.startElement("input", selectBooleanCheckbox);
	rw.writeAttribute("name", clientId + "_helper", null);
	rw.writeAttribute("value", "on", "value");
	rw.writeAttribute("checked", "true", "checked");
	rw.writeAttribute("type", "hidden", "type");
	rw.writeAttribute("style", "display:none", "style");
	rw.endElement("input");
}