@Override public String getEncodedUrl() { FacesContext facesContext = FacesContext.getCurrentInstance(); return facesContext.getApplication().getViewHandler().getBookmarkableURL(facesContext, this.viewId, getParametersAsMap(getParameters()), false); }
@Override protected void doEncodeBegin(javax.faces.context.ResponseWriter writer, FacesContext ctx, UIComponent component) throws IOException { UIDownload download = (UIDownload) component; if (!download.isRendered()) return; if (download.getSrc() != null) { ViewUrlBuilder builder = new ViewUrlBuilder(download.getSrc(), null); for (Object child : download.getChildren()) { if (child instanceof UIParameter) { builder.addParameter((UIParameter) child); } } writeStartTag(writer, download, builder.getEncodedUrl()); renderNonResourceChildren(ctx, download); writer.endElement(HTML.ANCHOR_ELEM); } }
@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); } }
public ViewUrlBuilder(String viewId, String fragment, boolean urlEncodeParameters) { super(fragment, FacesContext.getCurrentInstance().getResponseWriter().getCharacterEncoding(), urlEncodeParameters); if (viewId == null) { throw new NullPointerException("viewId must not be null"); } FacesContext facesContext = FacesContext.getCurrentInstance(); // will use bookmarkable URL later in getEncodeUrl() method which already knows all added Parameters //String url = facesContext.getApplication().getViewHandler().getBookmarkableURL(facesContext, viewId, null, false); String url = facesContext.getApplication().getViewHandler().getActionURL(facesContext, viewId); url = Pages.instance().encodeScheme(viewId, facesContext, url); setUrl(url); this.page = Pages.instance().getPage(viewId); this.viewId = viewId; }
ViewUrlBuilder url = new ViewUrlBuilder(viewId, getFragment()); url.addParameter((UIParameter) child); uip.setName(me.getKey()); uip.setValue(me.getValue()); url.addParameter(uip); url.addParameter(uiAction); url.addParameter(uiConversationId); uiPropagation.setType(getPropagation()); uiPropagation.setPageflow(getPageflow()); url.addParameter(uiPropagation); url.addParameter(name); url.addParameter(uiTaskId); if (uiSelection != null) url.addParameter(uiSelection); encodedUrl = url.getEncodedUrl();