public UrlBuilder(String url, String fragment, String characterEncoding) { this(fragment, characterEncoding); setUrl(url); }
/** * @return true, if an attribute was written * @throws java.io.IOException */ public static boolean renderHTMLAttributes(ResponseWriter writer, UIComponent component, String[] attributes) throws IOException { boolean somethingDone = false; for (int i = 0, len = attributes.length; i < len; i++) { String attrName = attributes[i]; if (renderHTMLAttribute(writer, component, attrName, attrName)) { somethingDone = true; } } return somethingDone; } /**
public static Integer getIntegerValue(FacesContext context, ValueExpression vb) { String value = getStringValue(context, vb); if (value == null) { return null; } return new Integer(value); }
public static void renderChildren(FacesContext facesContext, UIComponent component) throws IOException { List children = component.getChildren(); for (int j=0, size = component.getChildCount(); j<size; j++) { UIComponent child = (UIComponent) children.get(j); renderChild(facesContext, child); } }
/** * Render a Facelet */ protected void renderFacelet(FacesContext facesContext, Facelet facelet) throws IOException { UIViewRoot root = facesContext.getViewRoot(); facelet.apply(facesContext, root); JSF.renderChildren(facesContext, root); } }
public String getEncodedUrl() { String params = getParametersAsString(); if (!"".equals(params) && !url.contains("?")) { params = "?" + params.substring(1); } return url + params + getFragment(); }
@Override public String getEncodedUrl() { FacesContext facesContext = FacesContext.getCurrentInstance(); return facesContext.getApplication().getViewHandler().getBookmarkableURL(facesContext, this.viewId, getParametersAsMap(getParameters()), false); }
@Override public void addParameter(UIParameter parameter) throws UnsupportedEncodingException { String name = parameter.getName(); if (parameter.getValue() != null && !(name.equals(page.getConversationIdParameter().getParameterName()) && getParameters().containsKey(name))) { super.addParameter(parameter); } }
@Attribute public UIComponent getDecoration(String name) { return Decoration.getDecoration(name, this); }
public String getInputId() { String id = getFor(); if (id==null) { UIComponent evh = Decoration.getEditableValueHolder(this); return evh==null ? null : evh.getId(); } else { return id; } }
public void addParameter(String name, String value) throws UnsupportedEncodingException { parameters.put(name, urlEncodeParameters ? urlEncode(value) : value); }
/** * @return true, if the attribute was written * @throws java.io.IOException */ public static boolean renderHTMLAttribute(ResponseWriter writer, String componentProperty, String attrName, Object value) throws IOException { if (!isDefaultAttributeValue(value)) { // render JSF "styleClass" attribute as "class" String htmlAttrName = attrName.equals(HTML.STYLE_CLASS_ATTR) ? HTML.CLASS_ATTR : attrName; writer.writeAttribute(htmlAttrName, value, componentProperty); return true; } return false; } /**
public void addParameter(UIParameter parameter) throws UnsupportedEncodingException { String value = parameter.getValue() == null ? "" : parameter.getValue().toString(); String name = parameter.getName(); addParameter(name, value); }
public static boolean hasRequired(UIComponent component, FacesContext context) { if ( !component.isRendered() ) return false; if ( component instanceof EditableValueHolder ) { if ( ( (EditableValueHolder) component ).isRequired() ) return true; } for (Object child: component.getChildren()) { if (child instanceof UIComponent) { boolean required = hasRequired( (UIComponent) child, context ); if (required) return true; } } return false; }
@Override protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException { UILink link = (UILink) component; String url = link.getUrl(); writer.startElement(HTML.ANCHOR_ELEM, link); if (url != null && !link.isDisabled()) { writer.writeAttribute(HTML.HREF_ATTR, url, HTML.HREF_ATTR); } if (link.getId() != null) { writer.writeAttribute(HTML.ID_ATTR, link.getClientId(context), HTML.ID_ATTR); } HTML.renderHTMLAttributes(writer, link, HTML.ANCHOR_PASSTHROUGH_ATTRIBUTES); if (link.getValue() != null) { writer.writeText(link.getValue(), null); } }
public static void renderChild(FacesContext facesContext, UIComponent child) throws IOException { if ( child.isRendered() ) { child.encodeBegin(facesContext); if ( child.getRendersChildren() ) { child.encodeChildren(facesContext); } else { renderChildren(facesContext, child); } child.encodeEnd(facesContext); } }
/** * @return true, if the attribute was written * @throws java.io.IOException */ public static boolean renderHTMLAttribute(ResponseWriter writer, UIComponent component, String componentProperty, String htmlAttrName) throws IOException { Object value = component.getAttributes().get(componentProperty); return renderHTMLAttribute(writer, componentProperty, htmlAttrName, value); } /**
public static UIComponent getDecoration(String name, UIComponent component) { UIComponent dec = component.getFacet(name); if (dec!=null) return dec; if ( component.getParent()==null ) return null; return getDecoration( name, component.getParent() ); }
public static Double getDoubleValue(FacesContext context, ValueExpression vb) { String value = getStringValue(context, vb); if (value == null) { return null; } return new Double(value); }
/** * A depth-first search for an EditableValueHolder */ public static UIComponent getEditableValueHolder(UIComponent component) { for (Object child: component.getChildren()) { if (child instanceof EditableValueHolder) { UIComponent evh =(UIComponent) child; if ( evh.isRendered() ) { return evh; } } else if (child instanceof UIComponent) { UIComponent evh = getEditableValueHolder( (UIComponent) child ); if (evh!=null) return evh; } } return null; }